mirror of
https://github.com/vatesfr/xen-orchestra.git
synced 2026-12-01 11:09:10 -06:00
Compare commits
127 Commits
web-stack/
...
web-core/u
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aba06d56f6 | ||
|
|
4eed730a09 | ||
|
|
42ca53f80c | ||
|
|
6b8167a2fc | ||
|
|
780e0bbefa | ||
|
|
b2ba5abacf | ||
|
|
695b3d76e8 | ||
|
|
6f5b97f7f3 | ||
|
|
db3f702235 | ||
|
|
fb02bf07f6 | ||
|
|
9723075253 | ||
|
|
4b8cdf8043 | ||
|
|
397e8b6ed7 | ||
|
|
da332715f6 | ||
|
|
08c47da2b6 | ||
|
|
aa27e3ba46 | ||
|
|
a386680d90 | ||
|
|
6e508b03d8 | ||
|
|
2aa7c012f1 | ||
|
|
18fec2a0af | ||
|
|
be6b73dcb5 | ||
|
|
a89c31c75b | ||
|
|
51b06b1177 | ||
|
|
c0d434b612 | ||
|
|
b390f36deb | ||
|
|
1983025403 | ||
|
|
9e29c98735 | ||
|
|
66e677d7cb | ||
|
|
ecd7d624a0 | ||
|
|
5219d47fd0 | ||
|
|
b7a056dfaf | ||
|
|
a5831f8a58 | ||
|
|
ef636a9821 | ||
|
|
987e969103 | ||
|
|
7615a6c5f8 | ||
|
|
a0b1ac9388 | ||
|
|
4c6797d278 | ||
|
|
4b244daebd | ||
|
|
2994b9a327 | ||
|
|
137837cdab | ||
|
|
1fd74a29b9 | ||
|
|
877ca82600 | ||
|
|
5dbb529126 | ||
|
|
78c3b40762 | ||
|
|
47ee8799f3 | ||
|
|
8f877962f3 | ||
|
|
832634f284 | ||
|
|
6b6a9a4942 | ||
|
|
87551ca7b8 | ||
|
|
decf1ebf3e | ||
|
|
aeb22636c7 | ||
|
|
82473fdf37 | ||
|
|
f692c25638 | ||
|
|
6b30fb50c4 | ||
|
|
0ef95d9911 | ||
|
|
37aa941796 | ||
|
|
d907129e82 | ||
|
|
57fe8aec51 | ||
|
|
90188726e3 | ||
|
|
564a2af879 | ||
|
|
13488b41b1 | ||
|
|
3e335a3741 | ||
|
|
ac015305d7 | ||
|
|
936bdaac45 | ||
|
|
0960f8d8d3 | ||
|
|
6ae05398d7 | ||
|
|
e1b1fcd948 | ||
|
|
7579b3359c | ||
|
|
dfbdcd23f2 | ||
|
|
683f5f61d3 | ||
|
|
c8c9f77d45 | ||
|
|
7aa51f20c9 | ||
|
|
494ea4509f | ||
|
|
4296ca7e9b | ||
|
|
437e438672 | ||
|
|
81e7e07312 | ||
|
|
05dd9238b8 | ||
|
|
aae8b6b1d8 | ||
|
|
097aa5a584 | ||
|
|
062dd7561f | ||
|
|
2fe2ef49db | ||
|
|
7862952cf6 | ||
|
|
76c3f7472f | ||
|
|
35e8af6313 | ||
|
|
3e69d4c84b | ||
|
|
7e3b7367f1 | ||
|
|
42b32eb079 | ||
|
|
bf874bce7c | ||
|
|
989b3888ee | ||
|
|
b519e25601 | ||
|
|
2677b8ca38 | ||
|
|
5024bd765b | ||
|
|
6761274a16 | ||
|
|
512af62f7f | ||
|
|
4123ae731f | ||
|
|
90a33ead6d | ||
|
|
a49864abfb | ||
|
|
1f4ec8d0e1 | ||
|
|
3e615f725b | ||
|
|
9af58185cf | ||
|
|
2b63829e91 | ||
|
|
300bb18a64 | ||
|
|
42f205e473 | ||
|
|
fe5276217f | ||
|
|
1765600437 | ||
|
|
f0680df1e1 | ||
|
|
6d34cf67fb | ||
|
|
9c97ac903f | ||
|
|
a96d5e64de | ||
|
|
4744071098 | ||
|
|
dc9dbd9018 | ||
|
|
6405eeb1b5 | ||
|
|
7c666d1156 | ||
|
|
7ca6829c27 | ||
|
|
97cd50af44 | ||
|
|
5bfd462616 | ||
|
|
2b964576f2 | ||
|
|
d044dda59a | ||
|
|
11a4ceddce | ||
|
|
b97268727c | ||
|
|
3a21290fde | ||
|
|
299a109eb6 | ||
|
|
4235e98166 | ||
|
|
281ccbb8ba | ||
|
|
7053fc4a08 | ||
|
|
cd2f74cd63 | ||
|
|
6d836df6bf |
@@ -227,7 +227,7 @@ module.exports = {
|
||||
'@intlify/vue-i18n/no-v-html': 'error',
|
||||
'@intlify/vue-i18n/valid-message-syntax': 'error',
|
||||
'@intlify/vue-i18n/no-duplicate-keys-in-locale': 'error',
|
||||
'@intlify/vue-i18n/no-missing-keys-in-other-locales': ['error', { ignoreLocales: ['de', 'fa', 'cs'] }],
|
||||
'@intlify/vue-i18n/no-missing-keys-in-other-locales': ['error', { ignoreLocales: ['de', 'fa', 'cs', 'es' ] }],
|
||||
},
|
||||
},
|
||||
// Specific rules for XO dev-related files
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -7,6 +7,8 @@
|
||||
/@vates/*/node_modules/
|
||||
/@xen-orchestra/*/dist/
|
||||
/@xen-orchestra/*/node_modules/
|
||||
/@xen-orchestra/rest-api/open-api/spec/swagger.json
|
||||
/@xen-orchestra/rest-api/src/open-api/routes/routes.ts
|
||||
/packages/*/dist/
|
||||
/packages/*/node_modules/
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ class AggregateError extends Error {
|
||||
|
||||
/**
|
||||
* @template Item
|
||||
* @param {Iterable<Item>} iterable
|
||||
* @param {(item: Item, index: number, iterable: Iterable<Item>) => Promise<void>} iteratee
|
||||
* @param {Iterable<Item>|AsyncIterable<Item>} iterable
|
||||
* @param {(item: Item, index: number, iterable: Iterable<Item>|AsyncIterable<Item>) => Promise<void>} iteratee
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
exports.asyncEach = function asyncEach(iterable, iteratee, { concurrency = 10, signal, stopOnError = true } = {}) {
|
||||
|
||||
3
@vates/fatfs/.gitignore
vendored
3
@vates/fatfs/.gitignore
vendored
@@ -1,3 +0,0 @@
|
||||
.DS_Store
|
||||
.vscode/
|
||||
node_modules/
|
||||
1
@vates/fatfs/.npmignore
Symbolic link
1
@vates/fatfs/.npmignore
Symbolic link
@@ -0,0 +1 @@
|
||||
../../scripts/npmignore
|
||||
@@ -8,8 +8,9 @@
|
||||
"postversion": "npm publish --access public"
|
||||
},
|
||||
"repository": {
|
||||
"directory": "@vates/fatfs",
|
||||
"type": "git",
|
||||
"url": "https://github.com/vatesfr/xen-orchestra"
|
||||
"url": "https://github.com/vatesfr/xen-orchestra.git"
|
||||
},
|
||||
"keywords": [
|
||||
"filesystem",
|
||||
@@ -20,13 +21,14 @@
|
||||
],
|
||||
"author": "Vates SAS",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/vatesfr/xen-orchestra/issues"
|
||||
},
|
||||
"homepage": "https://github.com/vatesfr/xen-orchestra",
|
||||
"bugs": "https://github.com/vatesfr/xen-orchestra/issues",
|
||||
"homepage": "https://github.com/vatesfr/xen-orchestra/tree/master/@vates/fatfs",
|
||||
"dependencies": {
|
||||
"fifolock": "^1.0.0",
|
||||
"struct-fu": "^1.2.1",
|
||||
"xok": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ await mount(handler, diskId, mountPoint)
|
||||
|
||||
### cli
|
||||
|
||||
From the install folder :
|
||||
From the install folder:
|
||||
|
||||
```
|
||||
cli.mjs <remoteUrl> <vhdPathInRemote> <mountPoint>
|
||||
@@ -25,4 +25,25 @@ After installing the package
|
||||
xo-fuse-vhd <remoteUrl> <vhdPathInRemote> <mountPoint>
|
||||
```
|
||||
|
||||
remoteUrl can be found by using cli in `@xen-orchestra/fs` , for example a local remote will have a url like `file:///path/to/remote/root`
|
||||
The `remoteUrl` can be found using the following command from the XOA CLI, and then picking the right `url` property:
|
||||
|
||||
`xo-server-db ls remote`
|
||||
|
||||
The `vhdPathInRemote` follows a file structure described [here](https://github.com/vatesfr/xen-orchestra/blob/master/%40xen-orchestra/backups/docs/VM%20backups/README.md).
|
||||
|
||||
## Restore a file from a VHD using `fuse-vhd` CLI
|
||||
|
||||
1. Mount a VHD to the Filesystem (see **Usage**).
|
||||
2. Verify the VHD is Correctly Mounted:
|
||||
|
||||
`mount | grep fuse`
|
||||
|
||||
3. Get the `START` and `SIZE` of the disk whose file you want to restore. Multiply `START` by 512 (block size) to get the offset value. (`mountedVhdPath` is the `mountPoint` value from earlier, followed by `/vhd0`, for example). Depending on the partition type, you may need to do some additional setup to discover the partitions.
|
||||
|
||||
`partx --bytes --output=NR,START,SIZE,NAME,UUID,TYPE --pairs <mountedVhdPath>`
|
||||
|
||||
4. Mount the disk. Depending on the partition type, you may need to add some additionnal options. The `norecovery` option is used for ext3/ext4/xfs file systems, otherwise remove this option.
|
||||
|
||||
`mount --options=loop,ro,norecovery,sizelimit=<SIZE>,offset=<START*512> --source=<mountedVhdPath> --target=<diskMountPoint>`
|
||||
|
||||
5. Copy your files from the mounted partition, then unmount the partition.
|
||||
|
||||
@@ -29,7 +29,7 @@ await mount(handler, diskId, mountPoint)
|
||||
|
||||
### cli
|
||||
|
||||
From the install folder :
|
||||
From the install folder:
|
||||
|
||||
```
|
||||
cli.mjs <remoteUrl> <vhdPathInRemote> <mountPoint>
|
||||
@@ -41,7 +41,28 @@ After installing the package
|
||||
xo-fuse-vhd <remoteUrl> <vhdPathInRemote> <mountPoint>
|
||||
```
|
||||
|
||||
remoteUrl can be found by using cli in `@xen-orchestra/fs` , for example a local remote will have a url like `file:///path/to/remote/root`
|
||||
The `remoteUrl` can be found using the following command from the XOA CLI, and then picking the right `url` property:
|
||||
|
||||
`xo-server-db ls remote`
|
||||
|
||||
The `vhdPathInRemote` follows a file structure described [here](https://github.com/vatesfr/xen-orchestra/blob/master/%40xen-orchestra/backups/docs/VM%20backups/README.md).
|
||||
|
||||
## Restore a file from a VHD using `fuse-vhd` CLI
|
||||
|
||||
1. Mount a VHD to the Filesystem (see **Usage**).
|
||||
2. Verify the VHD is Correctly Mounted:
|
||||
|
||||
`mount | grep fuse`
|
||||
|
||||
3. Get the `START` and `SIZE` of the disk whose file you want to restore. Multiply `START` by 512 (block size) to get the offset value. (`mountedVhdPath` is the `mountPoint` value from earlier, followed by `/vhd0`, for example). Depending on the partition type, you may need to do some additional setup to discover the partitions.
|
||||
|
||||
`partx --bytes --output=NR,START,SIZE,NAME,UUID,TYPE --pairs <mountedVhdPath>`
|
||||
|
||||
4. Mount the disk. Depending on the partition type, you may need to add some additionnal options. The `norecovery` option is used for ext3/ext4/xfs file systems, otherwise remove this option.
|
||||
|
||||
`mount --options=loop,ro,norecovery,sizelimit=<SIZE>,offset=<START*512> --source=<mountedVhdPath> --target=<diskMountPoint>`
|
||||
|
||||
5. Copy your files from the mounted partition, then unmount the partition.
|
||||
|
||||
## Contributions
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
},
|
||||
"main": "./index.mjs",
|
||||
"dependencies": {
|
||||
"@xen-orchestra/fs": "^4.3.0",
|
||||
"@xen-orchestra/fs": "^4.4.0",
|
||||
"@xen-orchestra/log": "^0.7.1",
|
||||
"fuse-native": "^2.2.6",
|
||||
"lru-cache": "^7.14.0",
|
||||
|
||||
58
@vates/generator-toolbox/.USAGE.md
Normal file
58
@vates/generator-toolbox/.USAGE.md
Normal file
@@ -0,0 +1,58 @@
|
||||
A toolbox to ease the use of generator
|
||||
|
||||
### Timeout
|
||||
|
||||
wrap a source async generator to have it throw an error when timeout is reached
|
||||
timeout is a positive number in milliseconds
|
||||
|
||||
```js
|
||||
import { Timeout } from '@vates/generator-toolbox'
|
||||
|
||||
const wrappedGenerator = new Timeout(sourceGenerator, timeout)
|
||||
```
|
||||
|
||||
### Throttle
|
||||
|
||||
wrap a source async generator to have it respect a max speed ( in bytes per seconds).
|
||||
speed is either a strictly positive number or a function returning a strictly positive number. A speed change will be used for the next emitted packet.
|
||||
|
||||
The source generator must yield object with a length property.
|
||||
|
||||
Optimized for small yields regarding to the speed, since it won't split incoming packet.
|
||||
|
||||
If the generator reached the max speed it will be paused, limiting memory consumption.
|
||||
|
||||
```js
|
||||
import { Throttle } from '@vates/generator-toolbox'
|
||||
|
||||
const wrappedGenerator = new Throttle(sourceGenerator, speed)
|
||||
```
|
||||
|
||||
### Synchronized
|
||||
|
||||
Fork a generator. The rules ares:
|
||||
|
||||
- if the source returns, all the forks returns
|
||||
- if the forks errors, all the forks errors with the same error
|
||||
- if a the fork return , it is stopped, but the generator continue with the other
|
||||
- if a the fork error , it is stopped, but the generator continue with the other
|
||||
- if all the fork return , the source is stopped
|
||||
- if all the fork error , the source is errored with the last error
|
||||
- the source start producing a packet when the fastest forked ask for it
|
||||
- the source forks get the packet only when all the forks asked for it, no buffer stores in memory
|
||||
|
||||
```ts
|
||||
import { Synchronized } from '@vates/generator-toolbox'
|
||||
|
||||
async function consume(generator: AsyncGenerator) {
|
||||
for await (const val of generator) {
|
||||
console.log({ val })
|
||||
}
|
||||
}
|
||||
const forker = new Synchronized(generator)
|
||||
const first = forker.fork('first')
|
||||
const second = forker.fork('second')
|
||||
await Promise.all([consume(first), consume(second)])
|
||||
```
|
||||
|
||||
Note: you can stop early a generator by calling `generator.return()`, and you can stop in in error by calling `generator.throw(error)`
|
||||
1
@vates/generator-toolbox/.npmignore
Symbolic link
1
@vates/generator-toolbox/.npmignore
Symbolic link
@@ -0,0 +1 @@
|
||||
../../scripts/npmignore
|
||||
89
@vates/generator-toolbox/README.md
Normal file
89
@vates/generator-toolbox/README.md
Normal file
@@ -0,0 +1,89 @@
|
||||
<!-- DO NOT EDIT MANUALLY, THIS FILE HAS BEEN GENERATED -->
|
||||
|
||||
# @vates/generator-toolbox
|
||||
|
||||
[](https://npmjs.org/package/@vates/generator-toolbox)  [](https://bundlephobia.com/result?p=@vates/generator-toolbox) [](https://npmjs.org/package/@vates/generator-toolbox)
|
||||
|
||||
## Install
|
||||
|
||||
Installation of the [npm package](https://npmjs.org/package/@vates/generator-toolbox):
|
||||
|
||||
```sh
|
||||
npm install --save @vates/generator-toolbox
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
A toolbox to ease the use of generator
|
||||
|
||||
### Timeout
|
||||
|
||||
wrap a source async generator to have it throw an error when timeout is reached
|
||||
timeout is a positive number in milliseconds
|
||||
|
||||
```js
|
||||
import { Timeout } from '@vates/generator-toolbox'
|
||||
|
||||
const wrappedGenerator = new Timeout(sourceGenerator, timeout)
|
||||
```
|
||||
|
||||
### Throttle
|
||||
|
||||
wrap a source async generator to have it respect a max speed ( in bytes per seconds).
|
||||
speed is either a strictly positive number or a function returning a strictly positive number. A speed change will be used for the next emitted packet.
|
||||
|
||||
The source generator must yield object with a length property.
|
||||
|
||||
Optimized for small yields regarding to the speed, since it won't split incoming packet.
|
||||
|
||||
If the generator reached the max speed it will be paused, limiting memory consumption.
|
||||
|
||||
```js
|
||||
import { Throttle } from '@vates/generator-toolbox'
|
||||
|
||||
const wrappedGenerator = new Throttle(sourceGenerator, speed)
|
||||
```
|
||||
|
||||
### Synchronized
|
||||
|
||||
Fork a generator. The rules ares:
|
||||
|
||||
- if the source returns, all the forks returns
|
||||
- if the forks errors, all the forks errors with the same error
|
||||
- if a the fork return , it is stopped, but the generator continue with the other
|
||||
- if a the fork error , it is stopped, but the generator continue with the other
|
||||
- if all the fork return , the source is stopped
|
||||
- if all the fork error , the source is errored with the last error
|
||||
- the source start producing a packet when the fastest forked ask for it
|
||||
- the source forks get the packet only when all the forks asked for it, no buffer stores in memory
|
||||
|
||||
```ts
|
||||
import { Synchronized } from '@vates/generator-toolbox'
|
||||
|
||||
async function consume(generator: AsyncGenerator) {
|
||||
for await (const val of generator) {
|
||||
console.log({val})
|
||||
}
|
||||
}
|
||||
const forker = new Synchronized(generator)
|
||||
const first = forker.fork('first')
|
||||
const second = forker.fork('second')
|
||||
await Promise.all([consume(first), consume(second)])
|
||||
```
|
||||
|
||||
Note: you can stop early a generator by calling `generator.return()`, and you can stop in in error by calling `generator.throw(error)`
|
||||
|
||||
## Contributions
|
||||
|
||||
Contributions are _very_ welcomed, either on the documentation or on
|
||||
the code.
|
||||
|
||||
You may:
|
||||
|
||||
- report any [issue](https://github.com/vatesfr/xen-orchestra/issues)
|
||||
you've encountered;
|
||||
- fork and create a pull request.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://spdx.org/licenses/MIT) © [Vates SAS](https://vates.fr)
|
||||
6
@vates/generator-toolbox/eslint.config.mjs
Normal file
6
@vates/generator-toolbox/eslint.config.mjs
Normal file
@@ -0,0 +1,6 @@
|
||||
// @ts-check
|
||||
|
||||
import eslint from '@eslint/js'
|
||||
import tseslint from 'typescript-eslint'
|
||||
|
||||
export default tseslint.config(eslint.configs.recommended, tseslint.configs.recommended)
|
||||
33
@vates/generator-toolbox/package.json
Normal file
33
@vates/generator-toolbox/package.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "@vates/generator-toolbox",
|
||||
"version": "1.0.0",
|
||||
"main": "dist/index.mjs",
|
||||
"license": "MIT",
|
||||
"private": false,
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.19.0",
|
||||
"@types/node": "^20.6",
|
||||
"typescript": "~5.6",
|
||||
"typescript-eslint": "^8.23.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"dev": "tsc --watch",
|
||||
"test": "tsc && node --test **/*.test.mjs"
|
||||
},
|
||||
"homepage": "https://github.com/vatesfr/xen-orchestra/tree/master/@vates/generator-toolbox",
|
||||
"bugs": "https://github.com/vatesfr/xen-orchestra/issues",
|
||||
"repository": {
|
||||
"directory": "@vates/generator-toolbox",
|
||||
"type": "git",
|
||||
"url": "https://github.com/vatesfr/xen-orchestra.git"
|
||||
},
|
||||
"author": {
|
||||
"name": "Vates SAS",
|
||||
"url": "https://vates.fr"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.18"
|
||||
}
|
||||
}
|
||||
3
@vates/generator-toolbox/src/index.mts
Normal file
3
@vates/generator-toolbox/src/index.mts
Normal file
@@ -0,0 +1,3 @@
|
||||
export { Synchronized } from './synchronized.mjs'
|
||||
export { Throttle } from './throttle.mjs'
|
||||
export { Timeout } from './timeout.mjs'
|
||||
148
@vates/generator-toolbox/src/synchronized.mts
Normal file
148
@vates/generator-toolbox/src/synchronized.mts
Normal file
@@ -0,0 +1,148 @@
|
||||
import assert from 'node:assert'
|
||||
|
||||
export class Synchronized<T, TReturn, TNext> {
|
||||
#source: AsyncGenerator<T, TReturn, TNext>
|
||||
#forks = new Map<string, Forked<T, TReturn, TNext>>()
|
||||
#removedForks = new Set<string>()
|
||||
#waitingForks = new Set<string>()
|
||||
#started = false
|
||||
|
||||
#nextValueForksReady?: {
|
||||
promise: Promise<IteratorResult<T>>
|
||||
forksWaitingReject: (error: Error) => void
|
||||
forksWaitingResolve: () => void
|
||||
}
|
||||
|
||||
constructor(source: AsyncGenerator<T, TReturn, TNext>) {
|
||||
this.#source = source
|
||||
}
|
||||
|
||||
fork(uid: string): AsyncGenerator {
|
||||
assert.strictEqual(this.#started, false, `can't create a fork after consuming the data`)
|
||||
const fork = new Forked<T, TReturn, TNext>(this, uid)
|
||||
this.#forks.set(uid, fork)
|
||||
return fork
|
||||
}
|
||||
|
||||
async #resolveWhenAllForksReady(): Promise<IteratorResult<T>> {
|
||||
if (!this.#nextValueForksReady) {
|
||||
throw new Error('Can t wait forks if there are noone waiting')
|
||||
}
|
||||
const { promise, forksWaitingResolve } = this.#nextValueForksReady
|
||||
if (this.#waitingForks.size === this.#forks.size) {
|
||||
// reset value
|
||||
this.#waitingForks.clear()
|
||||
this.#nextValueForksReady = undefined
|
||||
forksWaitingResolve() // for the other forks waiting
|
||||
}
|
||||
return promise
|
||||
}
|
||||
|
||||
async next(uid: string): Promise<IteratorResult<T>> {
|
||||
if (this.#removedForks.has(uid)) {
|
||||
return { done: true, value: undefined }
|
||||
}
|
||||
if (!this.#forks.has(uid)) {
|
||||
throw new Error(`trying to advance fork ${uid} that is not a fork of this one`)
|
||||
}
|
||||
|
||||
if (this.#waitingForks.has(uid)) {
|
||||
throw new Error(`Fork ${uid} is already waiting`)
|
||||
}
|
||||
|
||||
this.#started = true
|
||||
if (this.#nextValueForksReady === undefined) {
|
||||
let forksWaitingResolve = () => {}
|
||||
let forksWaitingReject: (reason?: Error) => void = () => {}
|
||||
const next = this.#source.next().catch(async error => {
|
||||
const e = new Error(`Error in the source generator ${error.message}`, { cause: error })
|
||||
forksWaitingReject(e)
|
||||
// source has failed, kill everything, and stop the forks
|
||||
for (const uid of [...this.#forks.keys()]) {
|
||||
await this.remove(uid, error)
|
||||
}
|
||||
})
|
||||
const promise = Promise.all([
|
||||
next,
|
||||
new Promise((_resolve, _reject) => {
|
||||
forksWaitingResolve = () => _resolve(undefined)
|
||||
forksWaitingReject = _reject
|
||||
}),
|
||||
]).then(([_]) => _ as IteratorResult<T>)
|
||||
|
||||
this.#nextValueForksReady = { promise, forksWaitingResolve, forksWaitingReject }
|
||||
}
|
||||
this.#waitingForks.add(uid)
|
||||
return this.#resolveWhenAllForksReady()
|
||||
}
|
||||
|
||||
async remove(uid: string, error?: Error): Promise<IteratorResult<T>> {
|
||||
const fork = this.#forks.get(uid)
|
||||
if (fork === undefined) {
|
||||
if (this.#removedForks.has(uid)) {
|
||||
// already removed
|
||||
return { done: true, value: undefined }
|
||||
}
|
||||
throw new Error(`trying to remove fork wih uid ${uid} that is not a fork of this one`)
|
||||
}
|
||||
this.#forks.delete(uid)
|
||||
this.#waitingForks.delete(uid)
|
||||
this.#removedForks.add(uid)
|
||||
try {
|
||||
if (error === undefined) {
|
||||
await fork.return()
|
||||
} else {
|
||||
await fork.throw(error)
|
||||
}
|
||||
} catch (cleaningError) {
|
||||
console.error('Error while cleaning the forked', {
|
||||
cleaningError,
|
||||
sourceError: error,
|
||||
})
|
||||
}
|
||||
|
||||
if (this.#forks.size === 0) {
|
||||
if (error === undefined) {
|
||||
await this.#source.return(undefined as TReturn)
|
||||
} else {
|
||||
await this.#source.throw(error)
|
||||
}
|
||||
// Reject any pending forks waiting for the next value
|
||||
if (this.#nextValueForksReady) {
|
||||
this.#nextValueForksReady.forksWaitingReject(new Error('Source generator terminated.', { cause: error }))
|
||||
this.#nextValueForksReady = undefined
|
||||
}
|
||||
// clear state
|
||||
this.#removedForks.clear()
|
||||
this.#waitingForks.clear()
|
||||
} else {
|
||||
// this fork was maybe blocking the others
|
||||
if (this.#nextValueForksReady) {
|
||||
await this.#resolveWhenAllForksReady()
|
||||
}
|
||||
}
|
||||
return { done: true, value: undefined }
|
||||
}
|
||||
}
|
||||
|
||||
class Forked<T, TReturn, TNext> implements AsyncGenerator<T, TReturn, TNext> {
|
||||
#parent: Synchronized<T, TReturn, TNext>
|
||||
#uid: string
|
||||
constructor(parent: Synchronized<T, TReturn, TNext>, uid: string) {
|
||||
this.#parent = parent
|
||||
this.#uid = uid
|
||||
}
|
||||
next(): Promise<IteratorResult<T>> {
|
||||
return this.#parent.next(this.#uid)
|
||||
}
|
||||
async return(): Promise<IteratorResult<T>> {
|
||||
return this.#parent.remove(this.#uid)
|
||||
}
|
||||
async throw(e: Error): Promise<IteratorResult<T>> {
|
||||
return this.#parent.remove(this.#uid, e)
|
||||
}
|
||||
|
||||
[Symbol.asyncIterator](): AsyncGenerator<T> {
|
||||
return this
|
||||
}
|
||||
}
|
||||
142
@vates/generator-toolbox/src/synchronized.test.mts
Normal file
142
@vates/generator-toolbox/src/synchronized.test.mts
Normal file
@@ -0,0 +1,142 @@
|
||||
import assert from 'node:assert'
|
||||
import { suite, test } from 'node:test'
|
||||
import { Synchronized } from './synchronized.mjs'
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async function* makeRangeGenerator(end = Infinity, progress = { yielded: 0 }, onYielded = (val: unknown) => {}) {
|
||||
for (let i = 0; i < end; i++) {
|
||||
await new Promise(resolve => setTimeout(resolve, 10))
|
||||
yield i
|
||||
onYielded(i)
|
||||
progress.yielded = i
|
||||
}
|
||||
return progress
|
||||
}
|
||||
|
||||
async function consume(
|
||||
iterable: AsyncGenerator,
|
||||
delay = 2500,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
onConsumed = (val: unknown, iterable: AsyncGenerator) => Promise.resolve(false)
|
||||
) {
|
||||
for await (const val of iterable) {
|
||||
await new Promise(resolve => setTimeout(resolve, delay))
|
||||
if (await onConsumed(val, iterable)) {
|
||||
iterable.return(undefined)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suite('success', () => {
|
||||
test('if works with multiple consumer', async () => {
|
||||
const progress = { yielded: 0 }
|
||||
const generator = makeRangeGenerator(3, progress)
|
||||
const forker = new Synchronized(generator)
|
||||
const first = forker.fork('first')
|
||||
const second = forker.fork('second')
|
||||
await Promise.all([consume(first, 50), consume(second, 500)])
|
||||
assert.strictEqual(progress.yielded, 2)
|
||||
})
|
||||
|
||||
test('if works with one consumer returning', async () => {
|
||||
const progress = { yielded: 0 }
|
||||
const generator = makeRangeGenerator(10, progress)
|
||||
const forker = new Synchronized(generator)
|
||||
const first = forker.fork('first')
|
||||
const second = forker.fork('second')
|
||||
await new Promise(resolve => setTimeout(resolve, 500))
|
||||
await Promise.all([
|
||||
consume(first, 1),
|
||||
consume(second, 1, async (val: unknown) => {
|
||||
return Promise.resolve(val === 2)
|
||||
}),
|
||||
])
|
||||
assert.strictEqual(progress.yielded, 9)
|
||||
})
|
||||
test('if works with all consumers returning', async () => {
|
||||
const progress = { yielded: 0 }
|
||||
const generator = makeRangeGenerator(10, progress)
|
||||
const forker = new Synchronized(generator)
|
||||
const first = forker.fork('first')
|
||||
const second = forker.fork('second')
|
||||
await new Promise(resolve => setTimeout(resolve, 500))
|
||||
await Promise.all([
|
||||
consume(first, 1, async (val: unknown) => {
|
||||
return Promise.resolve(val === 5)
|
||||
}),
|
||||
consume(second, 1, async (val: unknown) => {
|
||||
return Promise.resolve(val === 2)
|
||||
}),
|
||||
])
|
||||
assert.strictEqual(progress.yielded, 4)
|
||||
})
|
||||
})
|
||||
|
||||
suite('error', () => {
|
||||
test('it fails all if error on source', async () => {
|
||||
const progress = { yielded: 0 }
|
||||
const generator = makeRangeGenerator(5, progress, (val: unknown) => {
|
||||
if (val === 2) {
|
||||
throw new Error('source stop')
|
||||
}
|
||||
})
|
||||
const forker = new Synchronized(generator)
|
||||
const first = forker.fork('first')
|
||||
const second = forker.fork('second')
|
||||
await assert.rejects(Promise.all([consume(first, 1), consume(second, 1)]))
|
||||
|
||||
assert.strictEqual(progress.yielded, 1)
|
||||
})
|
||||
test('it flows until the end if one consumer throws', async () => {
|
||||
const progress = { yielded: 0 }
|
||||
const generator = makeRangeGenerator(10, progress)
|
||||
const forker = new Synchronized(generator)
|
||||
const first = forker.fork('first')
|
||||
const second = forker.fork('second')
|
||||
|
||||
const firstConsume = consume(first, 1)
|
||||
|
||||
const secondConsume = assert.rejects(() =>
|
||||
consume(second, 1, async (val: unknown, iterable) => {
|
||||
if (val === 1) {
|
||||
await iterable.throw(new Error('error on second'))
|
||||
}
|
||||
return false
|
||||
})
|
||||
)
|
||||
await Promise.allSettled([firstConsume, secondConsume])
|
||||
assert.strictEqual(progress.yielded, 9)
|
||||
})
|
||||
test('it throw if ALL consumer throws', async () => {
|
||||
const progress = { yielded: 0 }
|
||||
const generator = makeRangeGenerator(5, progress)
|
||||
const forker = new Synchronized(generator)
|
||||
const first = forker.fork('first')
|
||||
const second = forker.fork('second')
|
||||
|
||||
const firstConsume = consume(first, 1, async (val: unknown, iterable) => {
|
||||
if (val === 3) {
|
||||
await iterable.throw(new Error('error on first'))
|
||||
}
|
||||
return false
|
||||
})
|
||||
const secondConsume = consume(second, 1, async (val: unknown, iterable) => {
|
||||
if (val === 1) {
|
||||
await iterable.throw(new Error('error on second'))
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
await assert.rejects(Promise.all([firstConsume, secondConsume]))
|
||||
assert.strictEqual(progress.yielded, 2)
|
||||
})
|
||||
|
||||
test('It should not allow a new fork after the start', async () => {
|
||||
const progress = { yielded: 0 }
|
||||
const generator = makeRangeGenerator(5, progress)
|
||||
const forker = new Synchronized(generator)
|
||||
const first = forker.fork('first')
|
||||
await first.next()
|
||||
assert.throws(() => forker.fork('second'))
|
||||
})
|
||||
})
|
||||
66
@vates/generator-toolbox/src/throttle.mts
Normal file
66
@vates/generator-toolbox/src/throttle.mts
Normal file
@@ -0,0 +1,66 @@
|
||||
import assert from 'node:assert'
|
||||
|
||||
/**
|
||||
*
|
||||
* This class will throttle the production of a group of generators
|
||||
*
|
||||
* limits: depends on the event loop, so don't expect it to be very precise
|
||||
* works better with more small blocks
|
||||
* The source generator must yield object with a length property
|
||||
* Changing the speed will only be takin into account fot the next packets asked
|
||||
*/
|
||||
export class Throttle {
|
||||
#previousSlot = 0
|
||||
#bytesPerSecond: number | (() => number)
|
||||
get speed(): number {
|
||||
let speed: number
|
||||
if (typeof this.#bytesPerSecond === 'function') {
|
||||
speed = this.#bytesPerSecond()
|
||||
} else {
|
||||
speed = this.#bytesPerSecond
|
||||
}
|
||||
assert.ok(speed > 0, `speed must be greater than zero, ${speed} computed`)
|
||||
return speed
|
||||
}
|
||||
constructor(speed: number | (() => number)) {
|
||||
this.#bytesPerSecond = speed
|
||||
}
|
||||
|
||||
getNextSlot(length: number): { timeout?: ReturnType<typeof setTimeout>; promise?: Promise<unknown> } {
|
||||
assert.notStrictEqual(length, undefined, `throttled stream need to expose a length property }`)
|
||||
assert.ok(length > 0, `throttled stream must expose a positive length property , ${length} given }`)
|
||||
|
||||
const previous = this.#previousSlot
|
||||
const nextSlot = Math.round(previous + (length * 1000) / this.speed)
|
||||
if (nextSlot < Date.now()) {
|
||||
// we're above the limit, go now
|
||||
this.#previousSlot = Date.now()
|
||||
return {}
|
||||
}
|
||||
this.#previousSlot = nextSlot
|
||||
// wait till the next slot
|
||||
// it won't be extremely precise since the event loop is not
|
||||
let timeout: ReturnType<typeof setTimeout> | undefined = undefined
|
||||
const promise = new Promise(function (resolve) {
|
||||
timeout = setTimeout(resolve, nextSlot - Date.now())
|
||||
})
|
||||
return { promise, timeout }
|
||||
}
|
||||
|
||||
async *createThrottledGenerator(source: AsyncGenerator<{ length: number }>): AsyncGenerator<{ length: number }> {
|
||||
let timeout: ReturnType<typeof setTimeout> | undefined
|
||||
try {
|
||||
for await (const value of source) {
|
||||
const res = this.getNextSlot(value.length)
|
||||
timeout = res.timeout
|
||||
// wait for the time slot before yielding the data
|
||||
if (res.promise !== undefined) {
|
||||
await res.promise
|
||||
}
|
||||
yield value
|
||||
}
|
||||
} finally {
|
||||
clearTimeout(timeout)
|
||||
}
|
||||
}
|
||||
}
|
||||
63
@vates/generator-toolbox/src/throttle.test.mts
Normal file
63
@vates/generator-toolbox/src/throttle.test.mts
Normal file
@@ -0,0 +1,63 @@
|
||||
import { Throttle } from './throttle.mjs'
|
||||
import { suite, test } from 'node:test'
|
||||
import assert from 'node:assert'
|
||||
|
||||
async function* makeGenerator(chunkSize = 1024 * 1024, nbChunks = 100) {
|
||||
for (let i = 0; i < nbChunks; i++) {
|
||||
yield Buffer.allocUnsafe(chunkSize)
|
||||
}
|
||||
}
|
||||
|
||||
async function consumes(generator: AsyncGenerator) {
|
||||
// eslint-disable-next-line no-empty,@typescript-eslint/no-unused-vars
|
||||
for await (const data of generator) {
|
||||
}
|
||||
}
|
||||
|
||||
suite('it throttle one', () => {
|
||||
test('base test', async () => {
|
||||
// 10MB/s
|
||||
const throttler = new Throttle(10 * 1024 * 1024)
|
||||
const throttled = throttler.createThrottledGenerator(makeGenerator(1024 * 1024, 20))
|
||||
|
||||
const start = Date.now()
|
||||
await consumes(throttled)
|
||||
const end = Date.now()
|
||||
assert.strictEqual(Math.round((end - start) / 1000), 2)
|
||||
})
|
||||
test('variable speed test', async () => {
|
||||
// 10MB/s
|
||||
const throttler = new Throttle(() => 10 * 1024 * 1024)
|
||||
const throttled = throttler.createThrottledGenerator(makeGenerator(1024 * 1024, 20))
|
||||
|
||||
const start = Date.now()
|
||||
await consumes(throttled)
|
||||
const end = Date.now()
|
||||
assert.strictEqual(Math.round((end - start) / 1000), 2)
|
||||
})
|
||||
test('multiple generator test', async () => {
|
||||
// 10MB/s
|
||||
const throttler = new Throttle(10 * 1024 * 1024)
|
||||
const first = throttler.createThrottledGenerator(makeGenerator(1024 * 1024, 10))
|
||||
const second = throttler.createThrottledGenerator(makeGenerator(1024 * 1024, 10))
|
||||
const start = Date.now()
|
||||
|
||||
await Promise.all([consumes(first), consumes(second)])
|
||||
const end = Date.now()
|
||||
assert.strictEqual(Math.round((end - start) / 1000), 2)
|
||||
})
|
||||
test(`it doesn't accept negative value`, async () => {
|
||||
// 10MB/s
|
||||
let throttler = new Throttle(-10 * 1024 * 1024)
|
||||
let generator = throttler.createThrottledGenerator(makeGenerator(1024 * 1024, 10))
|
||||
await assert.rejects(() => consumes(generator))
|
||||
|
||||
let index = 5
|
||||
throttler = new Throttle(() => {
|
||||
index--
|
||||
return index > 0 ? 10 * 1024 * 1024 : -10 * 1024 * 1024
|
||||
})
|
||||
generator = throttler.createThrottledGenerator(makeGenerator(1024 * 1024, 10))
|
||||
await assert.rejects(() => consumes(generator))
|
||||
})
|
||||
})
|
||||
37
@vates/generator-toolbox/src/timeout.mts
Normal file
37
@vates/generator-toolbox/src/timeout.mts
Normal file
@@ -0,0 +1,37 @@
|
||||
import assert from 'node:assert'
|
||||
export class Timeout<T> implements AsyncGenerator {
|
||||
#source: AsyncGenerator<T>
|
||||
#timeout: number
|
||||
constructor(source: AsyncGenerator<T>, timeout: number) {
|
||||
assert.ok(timeout > 0, `Timeout value must be positive, ${timeout} received`)
|
||||
this.#source = source
|
||||
this.#timeout = timeout
|
||||
}
|
||||
async next(): Promise<IteratorResult<T>> {
|
||||
let timeout: ReturnType<typeof setTimeout>
|
||||
const promiseTimeout = new Promise((_, reject) => {
|
||||
timeout = setTimeout(() => {
|
||||
reject(new Error('Timeout reached '))
|
||||
}, this.#timeout)
|
||||
})
|
||||
const promiseNext = new Promise((resolve, reject) => {
|
||||
this.#source.next().then(res => {
|
||||
// ensure timetout won't fire later
|
||||
clearTimeout(timeout)
|
||||
resolve(res)
|
||||
}, reject)
|
||||
})
|
||||
// promiseTimeout will never resolve
|
||||
return Promise.race([promiseNext, promiseTimeout]) as Promise<IteratorResult<T>>
|
||||
}
|
||||
return(): Promise<IteratorResult<T>> {
|
||||
return this.#source.return(undefined)
|
||||
}
|
||||
throw(e: Error): Promise<IteratorResult<T>> {
|
||||
return this.#source.throw(e)
|
||||
}
|
||||
|
||||
[Symbol.asyncIterator](): AsyncGenerator<T> {
|
||||
return this
|
||||
}
|
||||
}
|
||||
67
@vates/generator-toolbox/src/timeout.test.mts
Normal file
67
@vates/generator-toolbox/src/timeout.test.mts
Normal file
@@ -0,0 +1,67 @@
|
||||
import { describe, it } from 'node:test'
|
||||
import assert from 'node:assert'
|
||||
import { Timeout } from './timeout.mjs'
|
||||
|
||||
describe('Timeout class', () => {
|
||||
it('should reject a timeout with a negative or zero value ', async () => {
|
||||
// Create a mock async generator that never resolves
|
||||
const mockGenerator = (async function* () {
|
||||
yield 1
|
||||
})()
|
||||
|
||||
assert.throws(() => new Timeout(mockGenerator, 0))
|
||||
assert.throws(() => new Timeout(mockGenerator, -10))
|
||||
})
|
||||
it('should resolve with the value from the source generator if it completes before the timeout', async () => {
|
||||
// Create a mock async generator that resolves immediately
|
||||
const mockGenerator = (async function* () {
|
||||
yield 1
|
||||
})()
|
||||
|
||||
const timeout = new Timeout(mockGenerator, 100) // 100ms timeout
|
||||
|
||||
const result = await timeout.next()
|
||||
assert.strictEqual(result.value, 1)
|
||||
assert.strictEqual(result.done, false)
|
||||
})
|
||||
|
||||
it('should reject with a timeout error if the source generator takes too long', async () => {
|
||||
// Create a mock async generator that never resolves
|
||||
// eslint-disable-next-line require-yield
|
||||
const mockGenerator = (async function* () {
|
||||
await new Promise(() => {}) // Never resolves
|
||||
})()
|
||||
|
||||
const timeout = new Timeout(mockGenerator, 10) // 10ms timeout
|
||||
|
||||
await assert.rejects(timeout.next(), 'Expected timeout error was not thrown')
|
||||
})
|
||||
it('should allow iteration using for-await-of', async () => {
|
||||
// Create a mock async generator that yields values
|
||||
const mockGenerator: AsyncGenerator<number> = (async function* () {
|
||||
yield 1
|
||||
yield 2
|
||||
yield 3
|
||||
})()
|
||||
|
||||
const timeout = new Timeout(mockGenerator, 100) // 100ms timeout
|
||||
|
||||
const results: Array<number> = []
|
||||
for await (const value of timeout) {
|
||||
results.push(value as number)
|
||||
}
|
||||
|
||||
assert.deepStrictEqual(results, [1, 2, 3])
|
||||
})
|
||||
|
||||
it('should handle the throw method correctly', async () => {
|
||||
// Create a mock async generator with a throw method
|
||||
const mockGenerator = (async function* () {
|
||||
yield 1
|
||||
})()
|
||||
|
||||
const timeout = new Timeout(mockGenerator, 100) // 100ms timeout
|
||||
|
||||
await assert.rejects(timeout.throw(new Error('Test error')), 'Expected error was not thrown')
|
||||
})
|
||||
})
|
||||
12
@vates/generator-toolbox/tsconfig.json
Normal file
12
@vates/generator-toolbox/tsconfig.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2023",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"strict": true,
|
||||
"declaration": true, // Generates `.d.ts` files for type safety
|
||||
"outDir": "dist" // Outputs compiled code to the `dist` directory
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
@@ -29,7 +29,7 @@ class Task {
|
||||
static get abortSignal() {
|
||||
const task = getTask()
|
||||
if (task !== undefined) {
|
||||
return task.#abortController.signal
|
||||
return task._abortController.signal
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,8 +65,11 @@ class Task {
|
||||
}
|
||||
}
|
||||
|
||||
#abortController = new AbortController()
|
||||
#onProgress
|
||||
// These two properties should not be used outside the class
|
||||
//
|
||||
// To ensure compatibility between multiple versions of this lib, they are kept public for now
|
||||
_abortController = new AbortController()
|
||||
_onProgress
|
||||
|
||||
get id() {
|
||||
return (this.id = Math.random().toString(36).slice(2))
|
||||
@@ -86,23 +89,23 @@ class Task {
|
||||
this.#startData = { properties }
|
||||
|
||||
if (onProgress !== undefined) {
|
||||
this.#onProgress = onProgress
|
||||
this._onProgress = onProgress
|
||||
} else {
|
||||
const parent = getTask()
|
||||
if (parent !== undefined) {
|
||||
const { signal } = parent.#abortController
|
||||
const { signal } = parent._abortController
|
||||
signal.addEventListener('abort', () => {
|
||||
this.#abortController.abort(signal.reason)
|
||||
this._abortController.abort(signal.reason)
|
||||
})
|
||||
|
||||
this.#onProgress = parent.#onProgress
|
||||
this._onProgress = parent._onProgress
|
||||
this.#startData.parentId = parent.id
|
||||
} else {
|
||||
this.#onProgress = noop
|
||||
this._onProgress = noop
|
||||
}
|
||||
}
|
||||
|
||||
const { signal } = this.#abortController
|
||||
const { signal } = this._abortController
|
||||
signal.addEventListener('abort', () => {
|
||||
if (this.status === PENDING) {
|
||||
this.#maybeStart()
|
||||
@@ -117,7 +120,7 @@ class Task {
|
||||
}
|
||||
|
||||
abort(reason) {
|
||||
this.#abortController.abort(reason)
|
||||
this._abortController.abort(reason)
|
||||
}
|
||||
|
||||
#emit(type, data) {
|
||||
@@ -126,7 +129,7 @@ class Task {
|
||||
data.id = this.id
|
||||
data.timestamp = Date.now()
|
||||
data.type = type
|
||||
this.#onProgress(data)
|
||||
this._onProgress(data)
|
||||
}
|
||||
|
||||
#end(status, result) {
|
||||
@@ -134,7 +137,7 @@ class Task {
|
||||
assert.equal(this.#running, false)
|
||||
|
||||
this.#emit('end', { status, result })
|
||||
this.#onProgress = alreadyEnded
|
||||
this._onProgress = alreadyEnded
|
||||
this.#status = status
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"url": "https://vates.fr"
|
||||
},
|
||||
"license": "ISC",
|
||||
"version": "0.6.0",
|
||||
"version": "0.6.1",
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
|
||||
1
@vates/types/.npmignore
Symbolic link
1
@vates/types/.npmignore
Symbolic link
@@ -0,0 +1 @@
|
||||
../../scripts/npmignore
|
||||
8
@vates/types/eslint.config.mjs
Normal file
8
@vates/types/eslint.config.mjs
Normal file
@@ -0,0 +1,8 @@
|
||||
// @ts-check
|
||||
|
||||
import eslint from '@eslint/js'
|
||||
import tseslint from 'typescript-eslint'
|
||||
|
||||
export default tseslint.config(eslint.configs.recommended, tseslint.configs.recommended, {
|
||||
ignores: ['dist'],
|
||||
})
|
||||
44
@vates/types/package.json
Normal file
44
@vates/types/package.json
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "@vates/types",
|
||||
"private": false,
|
||||
"version": "1.0.0",
|
||||
"main": "./dist/index.mjs",
|
||||
"exports": {
|
||||
".": {
|
||||
"default": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.mts"
|
||||
},
|
||||
"./xo": "./dist/xo.d.mts",
|
||||
"./xen-api": "./dist/xen-api.d.mts",
|
||||
"./common": {
|
||||
"default": "./dist/common.mjs",
|
||||
"types": "./dist/common.d.mts"
|
||||
}
|
||||
},
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.19.0",
|
||||
"typescript": "~5.6.3",
|
||||
"typescript-eslint": "^8.23.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"prepublishOnly": "yarn run build",
|
||||
"postversion": "npm publish --access public"
|
||||
},
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"homepage": "https://github.com/vatesfr/xen-orchestra/tree/master/@vates/types",
|
||||
"bugs": "https://github.com/vatesfr/xen-orchestra/issues",
|
||||
"repository": {
|
||||
"directory": "@vates/types",
|
||||
"type": "git",
|
||||
"url": "https://github.com/vatesfr/xen-orchestra.git"
|
||||
},
|
||||
"author": {
|
||||
"name": "Vates SAS",
|
||||
"url": "https://vates.fr"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.18"
|
||||
}
|
||||
}
|
||||
638
@vates/types/src/common.mts
Normal file
638
@vates/types/src/common.mts
Normal file
@@ -0,0 +1,638 @@
|
||||
declare const __brand: unique symbol
|
||||
|
||||
export type Branded<TBrand extends string, TType = string> = TType & { [__brand]: TBrand }
|
||||
|
||||
export const TASK_ALLOWED_OPERATIONS = {
|
||||
CANCEL: 'cancel',
|
||||
DESTROY: 'destroy',
|
||||
} as const
|
||||
|
||||
export type TASK_ALLOWED_OPERATIONS = (typeof TASK_ALLOWED_OPERATIONS)[keyof typeof TASK_ALLOWED_OPERATIONS]
|
||||
|
||||
export const TASK_STATUS_TYPE = {
|
||||
CANCELLED: 'cancelled',
|
||||
CANCELLING: 'cancelling',
|
||||
FAILURE: 'failure',
|
||||
PENDING: 'pending',
|
||||
SUCCESS: 'success',
|
||||
} as const
|
||||
|
||||
export type TASK_STATUS_TYPE = (typeof TASK_STATUS_TYPE)[keyof typeof TASK_STATUS_TYPE]
|
||||
|
||||
export const EVENT_OPERATION = {
|
||||
ADD: 'add',
|
||||
DEL: 'del',
|
||||
MOD: 'mod',
|
||||
} as const
|
||||
|
||||
export type EVENT_OPERATION = (typeof EVENT_OPERATION)[keyof typeof EVENT_OPERATION]
|
||||
|
||||
export const POOL_ALLOWED_OPERATIONS = {
|
||||
APPLY_UPDATES: 'apply_updates',
|
||||
CERT_REFRESH: 'cert_refresh',
|
||||
CLUSTER_CREATE: 'cluster_create',
|
||||
CONFIGURE_REPOSITORIES: 'configure_repositories',
|
||||
COPY_PRIMARY_HOST_CERTS: 'copy_primary_host_certs',
|
||||
DESIGNATE_NEW_MASTER: 'designate_new_master',
|
||||
EJECT: 'eject',
|
||||
EXCHANGE_CA_CERTIFICATES_ON_JOIN: 'exchange_ca_certificates_on_join',
|
||||
EXCHANGE_CERTIFICATES_ON_JOIN: 'exchange_certificates_on_join',
|
||||
GET_UPDATES: 'get_updates',
|
||||
HA_DISABLE: 'ha_disable',
|
||||
HA_ENABLE: 'ha_enable',
|
||||
SYNC_UPDATES: 'sync_updates',
|
||||
TLS_VERIFICATION_ENABLE: 'tls_verification_enable',
|
||||
} as const
|
||||
|
||||
export type POOL_ALLOWED_OPERATIONS = (typeof POOL_ALLOWED_OPERATIONS)[keyof typeof POOL_ALLOWED_OPERATIONS]
|
||||
|
||||
export const TELEMETRY_FREQUENCY = {
|
||||
DAILY: 'daily',
|
||||
MONTHLY: 'monthly',
|
||||
WEEKLY: 'weekly',
|
||||
} as const
|
||||
|
||||
export type TELEMETRY_FREQUENCY = (typeof TELEMETRY_FREQUENCY)[keyof typeof TELEMETRY_FREQUENCY]
|
||||
|
||||
export const UPDATE_SYNC_FREQUENCY = {
|
||||
DAILY: 'daily',
|
||||
WEEKLY: 'weekly',
|
||||
} as const
|
||||
|
||||
export type UPDATE_SYNC_FREQUENCY = (typeof UPDATE_SYNC_FREQUENCY)[keyof typeof UPDATE_SYNC_FREQUENCY]
|
||||
|
||||
export const AFTER_APPLY_GUIDANCE = {
|
||||
RESTART_HOST: 'restartHost',
|
||||
RESTART_HVM: 'restartHVM',
|
||||
RESTART_PV: 'restartPV',
|
||||
RESTART_XAPI: 'restartXAPI',
|
||||
} as const
|
||||
|
||||
export type AFTER_APPLY_GUIDANCE = (typeof AFTER_APPLY_GUIDANCE)[keyof typeof AFTER_APPLY_GUIDANCE]
|
||||
|
||||
export const UPDATE_AFTER_APPLY_GUIDANCE = {
|
||||
RESTART_HOST: 'restartHost',
|
||||
RESTART_HVM: 'restartHVM',
|
||||
RESTART_PV: 'restartPV',
|
||||
RESTART_XAPI: 'restartXAPI',
|
||||
} as const
|
||||
|
||||
export type UPDATE_AFTER_APPLY_GUIDANCE = (typeof UPDATE_AFTER_APPLY_GUIDANCE)[keyof typeof UPDATE_AFTER_APPLY_GUIDANCE]
|
||||
|
||||
export const LIVEPATCH_STATUS = {
|
||||
OK: 'ok',
|
||||
OK_LIVEPATCH_COMPLETE: 'ok_livepatch_complete',
|
||||
OK_LIVEPATCH_INCOMPLETE: 'ok_livepatch_incomplete',
|
||||
} as const
|
||||
|
||||
export type LIVEPATCH_STATUS = (typeof LIVEPATCH_STATUS)[keyof typeof LIVEPATCH_STATUS]
|
||||
|
||||
export const VM_POWER_STATE = {
|
||||
HALTED: 'Halted',
|
||||
PAUSED: 'Paused',
|
||||
RUNNING: 'Running',
|
||||
SUSPENDED: 'Suspended',
|
||||
} as const
|
||||
|
||||
export type VM_POWER_STATE = (typeof VM_POWER_STATE)[keyof typeof VM_POWER_STATE]
|
||||
|
||||
export const UPDATE_GUIDANCES = {
|
||||
REBOOT_HOST: 'reboot_host',
|
||||
REBOOT_HOST_ON_KERNEL_LIVEPATCH_FAILURE: 'reboot_host_on_kernel_livepatch_failure',
|
||||
REBOOT_HOST_ON_LIVEPATCH_FAILURE: 'reboot_host_on_livepatch_failure',
|
||||
REBOOT_HOST_ON_XEN_LIVEPATCH_FAILURE: 'reboot_host_on_xen_livepatch_failure',
|
||||
RESTART_DEVICE_MODEL: 'restart_device_model',
|
||||
RESTART_TOOLSTACK: 'restart_toolstack',
|
||||
RESTART_VM: 'restart_vm',
|
||||
} as const
|
||||
|
||||
export type UPDATE_GUIDANCES = (typeof UPDATE_GUIDANCES)[keyof typeof UPDATE_GUIDANCES]
|
||||
|
||||
export const ON_SOFTREBOOT_BEHAVIOR = {
|
||||
DESTROY: 'destroy',
|
||||
PRESERVE: 'preserve',
|
||||
RESTART: 'restart',
|
||||
SOFT_REBOOT: 'soft_reboot',
|
||||
} as const
|
||||
|
||||
export type ON_SOFTREBOOT_BEHAVIOR = (typeof ON_SOFTREBOOT_BEHAVIOR)[keyof typeof ON_SOFTREBOOT_BEHAVIOR]
|
||||
|
||||
export const ON_NORMAL_EXIT = {
|
||||
DESTROY: 'destroy',
|
||||
RESTART: 'restart',
|
||||
} as const
|
||||
|
||||
export type ON_NORMAL_EXIT = (typeof ON_NORMAL_EXIT)[keyof typeof ON_NORMAL_EXIT]
|
||||
|
||||
export const VM_OPERATIONS = {
|
||||
ASSERT_OPERATION_VALID: 'assert_operation_valid',
|
||||
AWAITING_MEMORY_LIVE: 'awaiting_memory_live',
|
||||
CALL_PLUGIN: 'call_plugin',
|
||||
CHANGING_DYNAMIC_RANGE: 'changing_dynamic_range',
|
||||
CHANGING_MEMORY_LIMITS: 'changing_memory_limits',
|
||||
CHANGING_MEMORY_LIVE: 'changing_memory_live',
|
||||
CHANGING_NVRAM: 'changing_NVRAM',
|
||||
CHANGING_SHADOW_MEMORY: 'changing_shadow_memory',
|
||||
CHANGING_SHADOW_MEMORY_LIVE: 'changing_shadow_memory_live',
|
||||
CHANGING_STATIC_RANGE: 'changing_static_range',
|
||||
CHANGING_VCPUS: 'changing_VCPUs',
|
||||
CHANGING_VCPUS_LIVE: 'changing_VCPUs_live',
|
||||
CHECKPOINT: 'checkpoint',
|
||||
CLEAN_REBOOT: 'clean_reboot',
|
||||
CLEAN_SHUTDOWN: 'clean_shutdown',
|
||||
CLONE: 'clone',
|
||||
COPY: 'copy',
|
||||
CREATE_TEMPLATE: 'create_template',
|
||||
CREATE_VTPM: 'create_vtpm',
|
||||
CSVM: 'csvm',
|
||||
DATA_SOURCE_OP: 'data_source_op',
|
||||
DESTROY: 'destroy',
|
||||
EXPORT: 'export',
|
||||
GET_BOOT_RECORD: 'get_boot_record',
|
||||
HARD_REBOOT: 'hard_reboot',
|
||||
HARD_SHUTDOWN: 'hard_shutdown',
|
||||
IMPORT: 'import',
|
||||
MAKE_INTO_TEMPLATE: 'make_into_template',
|
||||
METADATA_EXPORT: 'metadata_export',
|
||||
MIGRATE_SEND: 'migrate_send',
|
||||
PAUSE: 'pause',
|
||||
POOL_MIGRATE: 'pool_migrate',
|
||||
POWER_STATE_RESET: 'power_state_reset',
|
||||
PROVISION: 'provision',
|
||||
QUERY_SERVICES: 'query_services',
|
||||
RESUME: 'resume',
|
||||
RESUME_ON: 'resume_on',
|
||||
REVERT: 'revert',
|
||||
REVERTING: 'reverting',
|
||||
SEND_SYSRQ: 'send_sysrq',
|
||||
SEND_TRIGGER: 'send_trigger',
|
||||
SHUTDOWN: 'shutdown',
|
||||
SNAPSHOT: 'snapshot',
|
||||
SNAPSHOT_WITH_QUIESCE: 'snapshot_with_quiesce',
|
||||
START: 'start',
|
||||
START_ON: 'start_on',
|
||||
SUSPEND: 'suspend',
|
||||
UNPAUSE: 'unpause',
|
||||
UPDATE_ALLOWED_OPERATIONS: 'update_allowed_operations',
|
||||
} as const
|
||||
|
||||
export type VM_OPERATIONS = (typeof VM_OPERATIONS)[keyof typeof VM_OPERATIONS]
|
||||
|
||||
export const ON_CRASH_BEHAVIOUR = {
|
||||
COREDUMP_AND_DESTROY: 'coredump_and_destroy',
|
||||
COREDUMP_AND_RESTART: 'coredump_and_restart',
|
||||
DESTROY: 'destroy',
|
||||
PRESERVE: 'preserve',
|
||||
RENAME_RESTART: 'rename_restart',
|
||||
RESTART: 'restart',
|
||||
} as const
|
||||
|
||||
export type ON_CRASH_BEHAVIOUR = (typeof ON_CRASH_BEHAVIOUR)[keyof typeof ON_CRASH_BEHAVIOUR]
|
||||
|
||||
export const DOMAIN_TYPE = {
|
||||
HVM: 'hvm',
|
||||
PV: 'pv',
|
||||
PVH: 'pvh',
|
||||
PV_IN_PVH: 'pv_in_pvh',
|
||||
UNSPECIFIED: 'unspecified',
|
||||
} as const
|
||||
|
||||
export type DOMAIN_TYPE = (typeof DOMAIN_TYPE)[keyof typeof DOMAIN_TYPE]
|
||||
|
||||
export const TRISTATE_TYPE = {
|
||||
NO: 'no',
|
||||
UNSPECIFIED: 'unspecified',
|
||||
YES: 'yes',
|
||||
} as const
|
||||
|
||||
export type TRISTATE_TYPE = (typeof TRISTATE_TYPE)[keyof typeof TRISTATE_TYPE]
|
||||
|
||||
export const VMPP_BACKUP_TYPE = {
|
||||
CHECKPOINT: 'checkpoint',
|
||||
SNAPSHOT: 'snapshot',
|
||||
} as const
|
||||
|
||||
export type VMPP_BACKUP_TYPE = (typeof VMPP_BACKUP_TYPE)[keyof typeof VMPP_BACKUP_TYPE]
|
||||
|
||||
export const VMPP_BACKUP_FREQUENCY = {
|
||||
DAILY: 'daily',
|
||||
HOURLY: 'hourly',
|
||||
WEEKLY: 'weekly',
|
||||
} as const
|
||||
|
||||
export type VMPP_BACKUP_FREQUENCY = (typeof VMPP_BACKUP_FREQUENCY)[keyof typeof VMPP_BACKUP_FREQUENCY]
|
||||
|
||||
export const VMPP_ARCHIVE_FREQUENCY = {
|
||||
ALWAYS_AFTER_BACKUP: 'always_after_backup',
|
||||
DAILY: 'daily',
|
||||
NEVER: 'never',
|
||||
WEEKLY: 'weekly',
|
||||
} as const
|
||||
|
||||
export type VMPP_ARCHIVE_FREQUENCY = (typeof VMPP_ARCHIVE_FREQUENCY)[keyof typeof VMPP_ARCHIVE_FREQUENCY]
|
||||
|
||||
export const VMPP_ARCHIVE_TARGET_TYPE = {
|
||||
CIFS: 'cifs',
|
||||
NFS: 'nfs',
|
||||
NONE: 'none',
|
||||
} as const
|
||||
|
||||
export type VMPP_ARCHIVE_TARGET_TYPE = (typeof VMPP_ARCHIVE_TARGET_TYPE)[keyof typeof VMPP_ARCHIVE_TARGET_TYPE]
|
||||
|
||||
export const VMSS_FREQUENCY = {
|
||||
DAILY: 'daily',
|
||||
HOURLY: 'hourly',
|
||||
WEEKLY: 'weekly',
|
||||
} as const
|
||||
|
||||
export type VMSS_FREQUENCY = (typeof VMSS_FREQUENCY)[keyof typeof VMSS_FREQUENCY]
|
||||
|
||||
export const VMSS_TYPE = {
|
||||
CHECKPOINT: 'checkpoint',
|
||||
SNAPSHOT: 'snapshot',
|
||||
SNAPSHOT_WITH_QUIESCE: 'snapshot_with_quiesce',
|
||||
} as const
|
||||
|
||||
export type VMSS_TYPE = (typeof VMSS_TYPE)[keyof typeof VMSS_TYPE]
|
||||
|
||||
export const VM_APPLIANCE_OPERATION = {
|
||||
CLEAN_SHUTDOWN: 'clean_shutdown',
|
||||
HARD_SHUTDOWN: 'hard_shutdown',
|
||||
SHUTDOWN: 'shutdown',
|
||||
START: 'start',
|
||||
} as const
|
||||
|
||||
export type VM_APPLIANCE_OPERATION = (typeof VM_APPLIANCE_OPERATION)[keyof typeof VM_APPLIANCE_OPERATION]
|
||||
|
||||
export const HOST_ALLOWED_OPERATIONS = {
|
||||
APPLY_UPDATES: 'apply_updates',
|
||||
ENABLE: 'enable',
|
||||
EVACUATE: 'evacuate',
|
||||
POWER_ON: 'power_on',
|
||||
PROVISION: 'provision',
|
||||
REBOOT: 'reboot',
|
||||
SHUTDOWN: 'shutdown',
|
||||
VM_MIGRATE: 'vm_migrate',
|
||||
VM_RESUME: 'vm_resume',
|
||||
VM_START: 'vm_start',
|
||||
} as const
|
||||
|
||||
export type HOST_ALLOWED_OPERATIONS = (typeof HOST_ALLOWED_OPERATIONS)[keyof typeof HOST_ALLOWED_OPERATIONS]
|
||||
|
||||
export const LATEST_SYNCED_UPDATES_APPLIED_STATE = {
|
||||
NO: 'no',
|
||||
UNKNOWN: 'unknown',
|
||||
YES: 'yes',
|
||||
} as const
|
||||
|
||||
export type LATEST_SYNCED_UPDATES_APPLIED_STATE =
|
||||
(typeof LATEST_SYNCED_UPDATES_APPLIED_STATE)[keyof typeof LATEST_SYNCED_UPDATES_APPLIED_STATE]
|
||||
|
||||
export const HOST_DISPLAY = {
|
||||
DISABLED: 'disabled',
|
||||
DISABLE_ON_REBOOT: 'disable_on_reboot',
|
||||
ENABLED: 'enabled',
|
||||
ENABLE_ON_REBOOT: 'enable_on_reboot',
|
||||
} as const
|
||||
|
||||
export type HOST_DISPLAY = (typeof HOST_DISPLAY)[keyof typeof HOST_DISPLAY]
|
||||
|
||||
export const HOST_SCHED_GRAN = {
|
||||
CORE: 'core',
|
||||
CPU: 'cpu',
|
||||
SOCKET: 'socket',
|
||||
} as const
|
||||
|
||||
export type HOST_SCHED_GRAN = (typeof HOST_SCHED_GRAN)[keyof typeof HOST_SCHED_GRAN]
|
||||
|
||||
export const HOST_NUMA_AFFINITY_POLICY = {
|
||||
ANY: 'any',
|
||||
BEST_EFFORT: 'best_effort',
|
||||
DEFAULT_POLICY: 'default_policy',
|
||||
} as const
|
||||
|
||||
export type HOST_NUMA_AFFINITY_POLICY = (typeof HOST_NUMA_AFFINITY_POLICY)[keyof typeof HOST_NUMA_AFFINITY_POLICY]
|
||||
|
||||
export const NETWORK_OPERATIONS = {
|
||||
ATTACHING: 'attaching',
|
||||
} as const
|
||||
|
||||
export type NETWORK_OPERATIONS = (typeof NETWORK_OPERATIONS)[keyof typeof NETWORK_OPERATIONS]
|
||||
|
||||
export const NETWORK_DEFAULT_LOCKING_MODE = {
|
||||
DISABLED: 'disabled',
|
||||
UNLOCKED: 'unlocked',
|
||||
} as const
|
||||
|
||||
export type NETWORK_DEFAULT_LOCKING_MODE =
|
||||
(typeof NETWORK_DEFAULT_LOCKING_MODE)[keyof typeof NETWORK_DEFAULT_LOCKING_MODE]
|
||||
|
||||
export const NETWORK_PURPOSE = {
|
||||
INSECURE_NBD: 'insecure_nbd',
|
||||
NBD: 'nbd',
|
||||
} as const
|
||||
|
||||
export type NETWORK_PURPOSE = (typeof NETWORK_PURPOSE)[keyof typeof NETWORK_PURPOSE]
|
||||
|
||||
export const VIF_OPERATIONS = {
|
||||
ATTACH: 'attach',
|
||||
PLUG: 'plug',
|
||||
UNPLUG: 'unplug',
|
||||
} as const
|
||||
|
||||
export type VIF_OPERATIONS = (typeof VIF_OPERATIONS)[keyof typeof VIF_OPERATIONS]
|
||||
|
||||
export const VIF_LOCKING_MODE = {
|
||||
DISABLED: 'disabled',
|
||||
LOCKED: 'locked',
|
||||
NETWORK_DEFAULT: 'network_default',
|
||||
UNLOCKED: 'unlocked',
|
||||
} as const
|
||||
|
||||
export type VIF_LOCKING_MODE = (typeof VIF_LOCKING_MODE)[keyof typeof VIF_LOCKING_MODE]
|
||||
|
||||
export const VIF_IPV4_CONFIGURATION_MODE = {
|
||||
NONE: 'None',
|
||||
STATIC: 'Static',
|
||||
} as const
|
||||
|
||||
export type VIF_IPV4_CONFIGURATION_MODE = (typeof VIF_IPV4_CONFIGURATION_MODE)[keyof typeof VIF_IPV4_CONFIGURATION_MODE]
|
||||
|
||||
export const VIF_IPV6_CONFIGURATION_MODE = {
|
||||
NONE: 'None',
|
||||
STATIC: 'Static',
|
||||
} as const
|
||||
|
||||
export type VIF_IPV6_CONFIGURATION_MODE = (typeof VIF_IPV6_CONFIGURATION_MODE)[keyof typeof VIF_IPV6_CONFIGURATION_MODE]
|
||||
|
||||
export const PIF_IGMP_STATUS = {
|
||||
DISABLED: 'disabled',
|
||||
ENABLED: 'enabled',
|
||||
UNKNOWN: 'unknown',
|
||||
} as const
|
||||
|
||||
export type PIF_IGMP_STATUS = (typeof PIF_IGMP_STATUS)[keyof typeof PIF_IGMP_STATUS]
|
||||
|
||||
export const IP_CONFIGURATION_MODE = {
|
||||
DHCP: 'DHCP',
|
||||
NONE: 'None',
|
||||
STATIC: 'Static',
|
||||
} as const
|
||||
|
||||
export type IP_CONFIGURATION_MODE = (typeof IP_CONFIGURATION_MODE)[keyof typeof IP_CONFIGURATION_MODE]
|
||||
|
||||
export const IPV6_CONFIGURATION_MODE = {
|
||||
AUTOCONF: 'Autoconf',
|
||||
DHCP: 'DHCP',
|
||||
NONE: 'None',
|
||||
STATIC: 'Static',
|
||||
} as const
|
||||
|
||||
export type IPV6_CONFIGURATION_MODE = (typeof IPV6_CONFIGURATION_MODE)[keyof typeof IPV6_CONFIGURATION_MODE]
|
||||
|
||||
export const PRIMARY_ADDRESS_TYPE = {
|
||||
IPV4: 'IPv4',
|
||||
IPV6: 'IPv6',
|
||||
} as const
|
||||
|
||||
export type PRIMARY_ADDRESS_TYPE = (typeof PRIMARY_ADDRESS_TYPE)[keyof typeof PRIMARY_ADDRESS_TYPE]
|
||||
|
||||
export const BOND_MODE = {
|
||||
ACTIVE_BACKUP: 'active-backup',
|
||||
BALANCE_SLB: 'balance-slb',
|
||||
LACP: 'lacp',
|
||||
} as const
|
||||
|
||||
export type BOND_MODE = (typeof BOND_MODE)[keyof typeof BOND_MODE]
|
||||
|
||||
export const STORAGE_OPERATIONS = {
|
||||
DESTROY: 'destroy',
|
||||
FORGET: 'forget',
|
||||
PBD_CREATE: 'pbd_create',
|
||||
PBD_DESTROY: 'pbd_destroy',
|
||||
PLUG: 'plug',
|
||||
SCAN: 'scan',
|
||||
UNPLUG: 'unplug',
|
||||
UPDATE: 'update',
|
||||
VDI_CLONE: 'vdi_clone',
|
||||
VDI_CREATE: 'vdi_create',
|
||||
VDI_DATA_DESTROY: 'vdi_data_destroy',
|
||||
VDI_DESTROY: 'vdi_destroy',
|
||||
VDI_DISABLE_CBT: 'vdi_disable_cbt',
|
||||
VDI_ENABLE_CBT: 'vdi_enable_cbt',
|
||||
VDI_INTRODUCE: 'vdi_introduce',
|
||||
VDI_LIST_CHANGED_BLOCKS: 'vdi_list_changed_blocks',
|
||||
VDI_MIRROR: 'vdi_mirror',
|
||||
VDI_RESIZE: 'vdi_resize',
|
||||
VDI_SET_ON_BOOT: 'vdi_set_on_boot',
|
||||
VDI_SNAPSHOT: 'vdi_snapshot',
|
||||
} as const
|
||||
|
||||
export type STORAGE_OPERATIONS = (typeof STORAGE_OPERATIONS)[keyof typeof STORAGE_OPERATIONS]
|
||||
|
||||
export const SR_HEALTH = {
|
||||
HEALTHY: 'healthy',
|
||||
RECOVERING: 'recovering',
|
||||
} as const
|
||||
|
||||
export type SR_HEALTH = (typeof SR_HEALTH)[keyof typeof SR_HEALTH]
|
||||
|
||||
export const VDI_OPERATIONS = {
|
||||
BLOCKED: 'blocked',
|
||||
CLONE: 'clone',
|
||||
COPY: 'copy',
|
||||
DATA_DESTROY: 'data_destroy',
|
||||
DESTROY: 'destroy',
|
||||
DISABLE_CBT: 'disable_cbt',
|
||||
ENABLE_CBT: 'enable_cbt',
|
||||
FORCE_UNLOCK: 'force_unlock',
|
||||
FORGET: 'forget',
|
||||
GENERATE_CONFIG: 'generate_config',
|
||||
LIST_CHANGED_BLOCKS: 'list_changed_blocks',
|
||||
MIRROR: 'mirror',
|
||||
RESIZE: 'resize',
|
||||
RESIZE_ONLINE: 'resize_online',
|
||||
SET_ON_BOOT: 'set_on_boot',
|
||||
SNAPSHOT: 'snapshot',
|
||||
UPDATE: 'update',
|
||||
} as const
|
||||
|
||||
export type VDI_OPERATIONS = (typeof VDI_OPERATIONS)[keyof typeof VDI_OPERATIONS]
|
||||
|
||||
export const VDI_TYPE = {
|
||||
CBT_METADATA: 'cbt_metadata',
|
||||
CRASHDUMP: 'crashdump',
|
||||
EPHEMERAL: 'ephemeral',
|
||||
HA_STATEFILE: 'ha_statefile',
|
||||
METADATA: 'metadata',
|
||||
PVS_CACHE: 'pvs_cache',
|
||||
REDO_LOG: 'redo_log',
|
||||
RRD: 'rrd',
|
||||
SUSPEND: 'suspend',
|
||||
SYSTEM: 'system',
|
||||
USER: 'user',
|
||||
} as const
|
||||
|
||||
export type VDI_TYPE = (typeof VDI_TYPE)[keyof typeof VDI_TYPE]
|
||||
|
||||
export const ON_BOOT = {
|
||||
PERSIST: 'persist',
|
||||
RESET: 'reset',
|
||||
} as const
|
||||
|
||||
export type ON_BOOT = (typeof ON_BOOT)[keyof typeof ON_BOOT]
|
||||
|
||||
export const VBD_OPERATIONS = {
|
||||
ATTACH: 'attach',
|
||||
EJECT: 'eject',
|
||||
INSERT: 'insert',
|
||||
PAUSE: 'pause',
|
||||
PLUG: 'plug',
|
||||
UNPAUSE: 'unpause',
|
||||
UNPLUG: 'unplug',
|
||||
UNPLUG_FORCE: 'unplug_force',
|
||||
} as const
|
||||
|
||||
export type VBD_OPERATIONS = (typeof VBD_OPERATIONS)[keyof typeof VBD_OPERATIONS]
|
||||
|
||||
export const VBD_TYPE = {
|
||||
CD: 'CD',
|
||||
DISK: 'Disk',
|
||||
FLOPPY: 'Floppy',
|
||||
} as const
|
||||
|
||||
export type VBD_TYPE = (typeof VBD_TYPE)[keyof typeof VBD_TYPE]
|
||||
|
||||
export const VBD_MODE = {
|
||||
RO: 'RO',
|
||||
RW: 'RW',
|
||||
} as const
|
||||
|
||||
export type VBD_MODE = (typeof VBD_MODE)[keyof typeof VBD_MODE]
|
||||
|
||||
export const VTPM_OPERATIONS = {
|
||||
DESTROY: 'destroy',
|
||||
} as const
|
||||
|
||||
export type VTPM_OPERATIONS = (typeof VTPM_OPERATIONS)[keyof typeof VTPM_OPERATIONS]
|
||||
|
||||
export const PERSISTENCE_BACKEND = {
|
||||
XAPI: 'xapi',
|
||||
} as const
|
||||
|
||||
export type PERSISTENCE_BACKEND = (typeof PERSISTENCE_BACKEND)[keyof typeof PERSISTENCE_BACKEND]
|
||||
|
||||
export const CONSOLE_PROTOCOL = {
|
||||
RDP: 'rdp',
|
||||
RFB: 'rfb',
|
||||
VT100: 'vt100',
|
||||
} as const
|
||||
|
||||
export type CONSOLE_PROTOCOL = (typeof CONSOLE_PROTOCOL)[keyof typeof CONSOLE_PROTOCOL]
|
||||
|
||||
export const CLS = {
|
||||
CERTIFICATE: 'Certificate',
|
||||
HOST: 'Host',
|
||||
POOL: 'Pool',
|
||||
PVS_PROXY: 'PVS_proxy',
|
||||
SR: 'SR',
|
||||
VDI: 'VDI',
|
||||
VM: 'VM',
|
||||
VMPP: 'VMPP',
|
||||
VMSS: 'VMSS',
|
||||
} as const
|
||||
|
||||
export type CLS = (typeof CLS)[keyof typeof CLS]
|
||||
|
||||
export const TUNNEL_PROTOCOL = {
|
||||
GRE: 'gre',
|
||||
VXLAN: 'vxlan',
|
||||
} as const
|
||||
|
||||
export type TUNNEL_PROTOCOL = (typeof TUNNEL_PROTOCOL)[keyof typeof TUNNEL_PROTOCOL]
|
||||
|
||||
export const SRIOV_CONFIGURATION_MODE = {
|
||||
MANUAL: 'manual',
|
||||
MODPROBE: 'modprobe',
|
||||
SYSFS: 'sysfs',
|
||||
UNKNOWN: 'unknown',
|
||||
} as const
|
||||
|
||||
export type SRIOV_CONFIGURATION_MODE = (typeof SRIOV_CONFIGURATION_MODE)[keyof typeof SRIOV_CONFIGURATION_MODE]
|
||||
|
||||
export const PGPU_DOM0_ACCESS = {
|
||||
DISABLED: 'disabled',
|
||||
DISABLE_ON_REBOOT: 'disable_on_reboot',
|
||||
ENABLED: 'enabled',
|
||||
ENABLE_ON_REBOOT: 'enable_on_reboot',
|
||||
} as const
|
||||
|
||||
export type PGPU_DOM0_ACCESS = (typeof PGPU_DOM0_ACCESS)[keyof typeof PGPU_DOM0_ACCESS]
|
||||
|
||||
export const ALLOCATION_ALGORITHM = {
|
||||
BREADTH_FIRST: 'breadth_first',
|
||||
DEPTH_FIRST: 'depth_first',
|
||||
} as const
|
||||
|
||||
export type ALLOCATION_ALGORITHM = (typeof ALLOCATION_ALGORITHM)[keyof typeof ALLOCATION_ALGORITHM]
|
||||
|
||||
export const VGPU_TYPE_IMPLEMENTATION = {
|
||||
GVT_G: 'gvt_g',
|
||||
MXGPU: 'mxgpu',
|
||||
NVIDIA: 'nvidia',
|
||||
NVIDIA_SRIOV: 'nvidia_sriov',
|
||||
PASSTHROUGH: 'passthrough',
|
||||
} as const
|
||||
|
||||
export type VGPU_TYPE_IMPLEMENTATION = (typeof VGPU_TYPE_IMPLEMENTATION)[keyof typeof VGPU_TYPE_IMPLEMENTATION]
|
||||
|
||||
export const PVS_PROXY_STATUS = {
|
||||
CACHING: 'caching',
|
||||
INCOMPATIBLE_PROTOCOL_VERSION: 'incompatible_protocol_version',
|
||||
INCOMPATIBLE_WRITE_CACHE_MODE: 'incompatible_write_cache_mode',
|
||||
INITIALISED: 'initialised',
|
||||
STOPPED: 'stopped',
|
||||
} as const
|
||||
|
||||
export type PVS_PROXY_STATUS = (typeof PVS_PROXY_STATUS)[keyof typeof PVS_PROXY_STATUS]
|
||||
|
||||
export const SDN_CONTROLLER_PROTOCOL = {
|
||||
PSSL: 'pssl',
|
||||
SSL: 'ssl',
|
||||
} as const
|
||||
|
||||
export type SDN_CONTROLLER_PROTOCOL = (typeof SDN_CONTROLLER_PROTOCOL)[keyof typeof SDN_CONTROLLER_PROTOCOL]
|
||||
|
||||
export const VUSB_OPERATIONS = {
|
||||
ATTACH: 'attach',
|
||||
PLUG: 'plug',
|
||||
UNPLUG: 'unplug',
|
||||
} as const
|
||||
|
||||
export type VUSB_OPERATIONS = (typeof VUSB_OPERATIONS)[keyof typeof VUSB_OPERATIONS]
|
||||
|
||||
export const CLUSTER_OPERATION = {
|
||||
ADD: 'add',
|
||||
DESTROY: 'destroy',
|
||||
DISABLE: 'disable',
|
||||
ENABLE: 'enable',
|
||||
REMOVE: 'remove',
|
||||
} as const
|
||||
|
||||
export type CLUSTER_OPERATION = (typeof CLUSTER_OPERATION)[keyof typeof CLUSTER_OPERATION]
|
||||
|
||||
export const CLUSTER_HOST_OPERATION = {
|
||||
DESTROY: 'destroy',
|
||||
DISABLE: 'disable',
|
||||
ENABLE: 'enable',
|
||||
} as const
|
||||
|
||||
export type CLUSTER_HOST_OPERATION = (typeof CLUSTER_HOST_OPERATION)[keyof typeof CLUSTER_HOST_OPERATION]
|
||||
|
||||
export const CERTIFICATE_TYPE = {
|
||||
CA: 'ca',
|
||||
HOST: 'host',
|
||||
HOST_INTERNAL: 'host_internal',
|
||||
} as const
|
||||
|
||||
export type CERTIFICATE_TYPE = (typeof CERTIFICATE_TYPE)[keyof typeof CERTIFICATE_TYPE]
|
||||
3
@vates/types/src/index.mts
Normal file
3
@vates/types/src/index.mts
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './common.mjs'
|
||||
export * from './xen-api.mjs'
|
||||
export * from './xo.mjs'
|
||||
1367
@vates/types/src/xen-api.mts
Normal file
1367
@vates/types/src/xen-api.mts
Normal file
File diff suppressed because it is too large
Load Diff
202
@vates/types/src/xo.mts
Normal file
202
@vates/types/src/xo.mts
Normal file
@@ -0,0 +1,202 @@
|
||||
// Types based on xapi-object-to-xo
|
||||
|
||||
import { Branded, DOMAIN_TYPE, VM_OPERATIONS, VM_POWER_STATE } from './common.mjs'
|
||||
|
||||
type BaseXoVm = {
|
||||
$VBDs: XoVbd['id'][]
|
||||
$VGPUs: XoVgpu['id'][]
|
||||
|
||||
$container: XoPool['id'] | XoHost['id']
|
||||
$pool: XoPool['id']
|
||||
/**
|
||||
* @deprecated use $pool instead
|
||||
*/
|
||||
$poolId: XoPool['id']
|
||||
|
||||
_xapiRef: string
|
||||
|
||||
CPUs: {
|
||||
max: number
|
||||
number: number
|
||||
}
|
||||
PV_args?: string
|
||||
VGPUs: XoVgpu['id'][]
|
||||
VIFs: XoVif['id'][]
|
||||
VTPMs: XoVtpm['id'][]
|
||||
|
||||
addresses: Record<string, string>
|
||||
affinityHost?: XoHost['id']
|
||||
attachedPcis?: string[]
|
||||
auto_poweron: boolean
|
||||
bios_strings: Record<string, string>
|
||||
blockedOperations: Record<VM_OPERATIONS, string>
|
||||
boot: Record<string, string>
|
||||
coresPerSocket?: number
|
||||
cpuCap?: number | null
|
||||
cpuMask?: (number | null)[]
|
||||
cpuWeight?: number | null
|
||||
creation: Record<string, string>
|
||||
current_operations: Record<string, VM_OPERATIONS>
|
||||
docker?: {
|
||||
containers?: string[]
|
||||
enabled: boolean
|
||||
info?: string
|
||||
process?: string
|
||||
version?: string
|
||||
}
|
||||
expNestedHvm: boolean
|
||||
hasVendorDevice: boolean
|
||||
high_availability: string
|
||||
installTime?: number | null
|
||||
isFirmwareSupported: boolean
|
||||
memory: {
|
||||
dynamic: number[]
|
||||
size: number
|
||||
static: number[]
|
||||
usage?: number
|
||||
}
|
||||
mainIpAddress?: string
|
||||
managementAgentDetected?: boolean
|
||||
name_description: string
|
||||
name_label: string
|
||||
needsVtpm: boolean
|
||||
nicType?: string
|
||||
notes?: string
|
||||
os_version: Record<string, string> | null
|
||||
other: Record<string, string>
|
||||
parent?: XoVm['id']
|
||||
power_state: VM_POWER_STATE
|
||||
pvDriversDetected?: boolean
|
||||
pvDriversUpToDate?: boolean
|
||||
pvDriversVersion?: string
|
||||
resourceSet?: string
|
||||
secureBoot: boolean
|
||||
snapshots: XoVmSnapshot['id'][]
|
||||
startDelay: number
|
||||
startTime?: number | null
|
||||
suspendSr?: XoSr['id']
|
||||
tags: string[]
|
||||
vga?: string
|
||||
videoram?: number
|
||||
viridian: boolean
|
||||
virtualizationMode: DOMAIN_TYPE
|
||||
xenStoreData: Record<string, string>
|
||||
/**
|
||||
* @deprecated use pvDriversVersion instead
|
||||
*/
|
||||
xentools?:
|
||||
| false
|
||||
| {
|
||||
major: null | number
|
||||
minor: null | number
|
||||
version: null | string
|
||||
}
|
||||
}
|
||||
|
||||
export type XoGroup = {
|
||||
id: Branded<'group'>
|
||||
name: string
|
||||
users: XoUser['id'][]
|
||||
}
|
||||
|
||||
export type XoHost = {
|
||||
id: Branded<'host'>
|
||||
type: 'host'
|
||||
}
|
||||
|
||||
export type XoPool = {
|
||||
id: Branded<'pool'>
|
||||
type: 'pool'
|
||||
}
|
||||
|
||||
export type XoSr = {
|
||||
id: Branded<'SR'>
|
||||
type: 'SR'
|
||||
}
|
||||
|
||||
export type XoUser = {
|
||||
authProviders?: Record<string, string>
|
||||
email: string
|
||||
groups: XoGroup['id'][]
|
||||
id: Branded<'user'>
|
||||
name: string
|
||||
permission: string
|
||||
pw_hash: string
|
||||
preferences: Record<string, string>
|
||||
}
|
||||
|
||||
export type XoVbd = {
|
||||
id: Branded<'VBD'>
|
||||
type: 'VBD'
|
||||
}
|
||||
|
||||
export type XoVdi = {
|
||||
id: Branded<'VDI'>
|
||||
type: 'VDI'
|
||||
}
|
||||
|
||||
export type XoVgpu = {
|
||||
id: Branded<'VGPU'>
|
||||
type: 'VGPU'
|
||||
}
|
||||
|
||||
export type XoVif = {
|
||||
id: Branded<'VIF'>
|
||||
type: 'VIF'
|
||||
}
|
||||
|
||||
export type XoVm = BaseXoVm & {
|
||||
id: Branded<'VM'>
|
||||
type: 'VM'
|
||||
}
|
||||
|
||||
export type XoVmController = BaseXoVm & {
|
||||
id: Branded<'VM-controller'>
|
||||
type: 'VM-controller'
|
||||
}
|
||||
|
||||
export type XoVmSnapshot = BaseXoVm & {
|
||||
$snapshot_of: XoVm['id']
|
||||
|
||||
id: Branded<'VM-snapshot'>
|
||||
snapshot_time: number
|
||||
suspendVdi?: XoVdi['id']
|
||||
type: 'VM-snapshot'
|
||||
}
|
||||
|
||||
export type XoVmTemplate = BaseXoVm & {
|
||||
id: Branded<'VM-template'>
|
||||
isDefaultTemplate: boolean
|
||||
template_info: {
|
||||
arch?: string
|
||||
disks: {
|
||||
bootable: true
|
||||
size: number
|
||||
SR: string
|
||||
type: string
|
||||
}[]
|
||||
install_methods: string[]
|
||||
install_repository?: string
|
||||
}
|
||||
type: 'VM-template'
|
||||
}
|
||||
|
||||
export type XoVtpm = {
|
||||
id: Branded<'VTPM'>
|
||||
type: 'VTPM'
|
||||
}
|
||||
|
||||
export type XapiXoRecord =
|
||||
| XoHost
|
||||
| XoPool
|
||||
| XoSr
|
||||
| XoVbd
|
||||
| XoVdi
|
||||
| XoVgpu
|
||||
| XoVif
|
||||
| XoVm
|
||||
| XoVmController
|
||||
| XoVmSnapshot
|
||||
| XoVtpm
|
||||
|
||||
export type XoRecord = XapiXoRecord | XoGroup | XoUser
|
||||
12
@vates/types/tsconfig.json
Normal file
12
@vates/types/tsconfig.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist",
|
||||
"declaration": true,
|
||||
"strict": true,
|
||||
"module": "ESNext",
|
||||
"target": "ES2022",
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
@@ -7,8 +7,8 @@
|
||||
"bugs": "https://github.com/vatesfr/xen-orchestra/issues",
|
||||
"dependencies": {
|
||||
"@xen-orchestra/async-map": "^0.1.2",
|
||||
"@xen-orchestra/backups": "^0.57.0",
|
||||
"@xen-orchestra/fs": "^4.3.0",
|
||||
"@xen-orchestra/backups": "^0.58.1",
|
||||
"@xen-orchestra/fs": "^4.4.0",
|
||||
"filenamify": "^6.0.0",
|
||||
"getopts": "^2.2.5",
|
||||
"lodash": "^4.17.15",
|
||||
@@ -27,7 +27,7 @@
|
||||
"scripts": {
|
||||
"postversion": "npm publish --access public"
|
||||
},
|
||||
"version": "1.0.28",
|
||||
"version": "1.0.29",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"author": {
|
||||
"name": "Vates SAS",
|
||||
|
||||
@@ -700,7 +700,11 @@ export class RemoteAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
async outputStream(path, input, { checksum = true, maxStreamLength, streamLength, validator = noop } = {}) {
|
||||
async outputStream(
|
||||
path,
|
||||
input,
|
||||
{ checksum = !this._handler.isEncrypted, maxStreamLength, streamLength, validator = noop } = {}
|
||||
) {
|
||||
const container = watchStreamSize(input)
|
||||
await this._handler.outputStream(path, input, {
|
||||
checksum,
|
||||
|
||||
@@ -288,8 +288,7 @@ test('it finish unterminated merge ', async () => {
|
||||
|
||||
// each of the vhd can be a file, a directory, an alias to a file or an alias to a directory
|
||||
// the message an resulting files should be identical to the output with vhd files which is tested independantly
|
||||
|
||||
describe('tests multiple combination ', () => {
|
||||
describe('tests multiple combination ', { concurrency: 1 }, () => {
|
||||
for (const useAlias of [true, false]) {
|
||||
for (const vhdMode of ['file', 'directory']) {
|
||||
test(`alias : ${useAlias}, mode: ${vhdMode}`, async () => {
|
||||
@@ -431,7 +430,6 @@ describe('tests multiple combination ', () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
test('it cleans orphan merge states ', async () => {
|
||||
await handler.writeFile(`${basePath}/.orphan.vhd.merge.json`, '')
|
||||
|
||||
|
||||
@@ -133,6 +133,7 @@ export async function checkAliases(
|
||||
await handler.unlink(alias)
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if (!isVhdFile(target)) {
|
||||
@@ -575,7 +576,7 @@ export async function cleanVm(
|
||||
if (mergedSize) {
|
||||
// all disks are now key disk
|
||||
metadata.isVhdDifferencing = {}
|
||||
for (const id of Object.values(metadata.vdis ?? {})) {
|
||||
for (const id of Object.keys(metadata.vdis ?? {})) {
|
||||
metadata.isVhdDifferencing[`${id}.vhd`] = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ const LTR_DEFINITIONS = {
|
||||
copy.date(date.date() - firstDayOfWeek)
|
||||
// warning, the year in term of week may different from YYYY
|
||||
// since the computation of the first week of a year is timezone dependant
|
||||
return copy.format('gggg-WW')
|
||||
return copy.format('gggg-ww')
|
||||
}
|
||||
},
|
||||
ancestor: 'daily',
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
│ └─ <YYYYMMDD>T<HHmmss>.vhd
|
||||
├─ <YYYYMMDD>T<HHmmss>.json // backup metadata
|
||||
├─ <YYYYMMDD>T<HHmmss>.xva
|
||||
└─ <YYYYMMDD>T<HHmmss>.xva.checksum
|
||||
└─ <YYYYMMDD>T<HHmmss>.xva.checksum // only on backup before 01/02/2025 or non encrypted
|
||||
```
|
||||
|
||||
### with vhd directories
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/vatesfr/xen-orchestra.git"
|
||||
},
|
||||
"version": "0.57.0",
|
||||
"version": "0.58.1",
|
||||
"engines": {
|
||||
"node": ">=14.18"
|
||||
},
|
||||
@@ -28,7 +28,7 @@
|
||||
"@vates/nbd-client": "^3.1.2",
|
||||
"@vates/parse-duration": "^0.1.1",
|
||||
"@xen-orchestra/async-map": "^0.1.2",
|
||||
"@xen-orchestra/fs": "^4.3.0",
|
||||
"@xen-orchestra/fs": "^4.4.0",
|
||||
"@xen-orchestra/log": "^0.7.1",
|
||||
"@xen-orchestra/template": "^0.1.0",
|
||||
"app-conf": "^3.0.0",
|
||||
@@ -59,7 +59,7 @@
|
||||
"tmp": "^0.2.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@xen-orchestra/xapi": "^7.10.0"
|
||||
"@xen-orchestra/xapi": "^8.0.0"
|
||||
},
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"author": {
|
||||
|
||||
@@ -4,10 +4,22 @@ import { fork } from 'child_process'
|
||||
const { warn } = createLogger('xo:backups:backupWorker')
|
||||
|
||||
const PATH = new URL('_backupWorker.mjs', import.meta.url).pathname
|
||||
const DEFAULT_INSPECTOR_PORT = 9229
|
||||
|
||||
export function runBackupWorker(params, onLog) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const worker = fork(PATH)
|
||||
// run Node inspector on port+1 if --inspect or --inspect-brk
|
||||
const inspectArg = process.execArgv.find(arg => arg.startsWith('--inspect') || arg.startsWith('--inspect-brk'))
|
||||
const execArgv = inspectArg
|
||||
? [
|
||||
inspectArg.replace(/^(--inspect(-brk)?)(=([^:]+:)?(\d+))?$/, (_, prefix, brk, _fullMatch, host, port) => {
|
||||
const basePort = port ? parseInt(port) : DEFAULT_INSPECTOR_PORT
|
||||
return `${prefix}=${host || ''}${basePort + 1}`
|
||||
}),
|
||||
]
|
||||
: []
|
||||
|
||||
const worker = fork(PATH, [], { execArgv })
|
||||
|
||||
worker.on('exit', (code, signal) => reject(new Error(`worker exited with code ${code} and signal ${signal}`)))
|
||||
worker.on('error', reject)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": false,
|
||||
"name": "@xen-orchestra/fs",
|
||||
"version": "4.3.0",
|
||||
"version": "4.4.0",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"description": "The File System for Xen Orchestra backups.",
|
||||
"homepage": "https://github.com/vatesfr/xen-orchestra/tree/master/@xen-orchestra/fs",
|
||||
|
||||
@@ -2,8 +2,11 @@ const { pipeline } = require('node:stream')
|
||||
const { readChunk } = require('@vates/read-chunk')
|
||||
const crypto = require('crypto')
|
||||
|
||||
export const DEFAULT_ENCRYPTION_ALGORITHM = 'aes-256-gcm'
|
||||
const CHACHA20 = 'chacha20-poly1305'
|
||||
const AES256 = 'aes-256-gcm'
|
||||
export const DEFAULT_ENCRYPTION_ALGORITHM = CHACHA20
|
||||
export const UNENCRYPTED_ALGORITHM = 'none'
|
||||
export const SUPPORTED_ALGORITHM = new Set([UNENCRYPTED_ALGORITHM, AES256, CHACHA20, DEFAULT_ENCRYPTION_ALGORITHM])
|
||||
|
||||
export function isLegacyEncryptionAlgorithm(algorithm) {
|
||||
return algorithm !== UNENCRYPTED_ALGORITHM && algorithm !== DEFAULT_ENCRYPTION_ALGORITHM
|
||||
@@ -33,7 +36,7 @@ function getEncryptor(algorithm = DEFAULT_ENCRYPTION_ALGORITHM, key) {
|
||||
throw error
|
||||
}
|
||||
const { ivLength, mode } = info
|
||||
const authTagLength = ['gcm', 'ccm', 'ocb'].includes(mode) ? 16 : 0
|
||||
const authTagLength = ['gcm', 'ccm', 'ocb'].includes(mode) || algorithm === CHACHA20 ? 16 : 0
|
||||
|
||||
function encryptStream(input) {
|
||||
return pipeline(
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
"xo-lift-remote-immutability": "./liftProtection.mjs"
|
||||
},
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"version": "1.0.16",
|
||||
"version": "1.0.17",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vates/async-each": "^1.0.0",
|
||||
"@xen-orchestra/backups": "^0.57.0",
|
||||
"@xen-orchestra/backups": "^0.58.1",
|
||||
"@xen-orchestra/log": "^0.7.1",
|
||||
"app-conf": "^3.0.0",
|
||||
"chokidar": "^3.5.3",
|
||||
|
||||
@@ -1,8 +1,19 @@
|
||||
# ChangeLog
|
||||
|
||||
## **next**
|
||||
## **0.7.1** (2025-02-04)
|
||||
|
||||
- [Host/Console] Fix console sometimes not correctly displayed (PR [#8305](https://github.com/vatesfr/xen-orchestra/pull/8305))
|
||||
|
||||
## **0.7.0** (2025-01-30)
|
||||
|
||||
- Fix persistent scrollbar on the right (PR [#8191](https://github.com/vatesfr/xen-orchestra/pull/8191))
|
||||
- [Console]: Displays a loader when the console is loading (PR [#8226](https://github.com/vatesfr/xen-orchestra/pull/8226))
|
||||
- [i18n] Add Spanish translation (contribution made by [@DSJ2](https://github.com/DSJ2)) (PR [#8220](https://github.com/vatesfr/xen-orchestra/pull/8220))
|
||||
- [Console]: Adding a border when console is focused (PR [#8235](https://github.com/vatesfr/xen-orchestra/pull/8235))
|
||||
- [Pool/Network]: Display networks and host internal networks lists in pool view (PR [#8147](https://github.com/vatesfr/xen-orchestra/pull/8147))
|
||||
- [Host/Network]: Display pifs list in host view (PR [#8180](https://github.com/vatesfr/xen-orchestra/pull/8180))
|
||||
- [Host/Network]: Fix issue with wording in host pif table (PR [8285](https://github.com/vatesfr/xen-orchestra/pull/8285))
|
||||
- [Pool/Network]: Fix issue with network status (PR [#8284](https://github.com/vatesfr/xen-orchestra/pull/8284))
|
||||
|
||||
## **0.6.0** (2024-11-29)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@xen-orchestra/lite",
|
||||
"version": "0.6.0",
|
||||
"version": "0.7.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "GIT_HEAD=$(git rev-parse HEAD) vite",
|
||||
@@ -32,11 +32,10 @@
|
||||
"@vueuse/core": "^10.7.1",
|
||||
"@vueuse/math": "^10.7.1",
|
||||
"@vueuse/shared": "^10.7.1",
|
||||
"@xen-orchestra/web-core": "^0.10.0",
|
||||
"@xen-orchestra/web-core": "^0.14.0",
|
||||
"complex-matcher": "^0.7.1",
|
||||
"d3-time-format": "^4.1.0",
|
||||
"decorator-synchronized": "^0.6.0",
|
||||
"echarts": "^5.4.3",
|
||||
"file-saver": "^2.0.5",
|
||||
"highlight.js": "^11.9.0",
|
||||
"human-format": "^1.2.1",
|
||||
@@ -58,10 +57,9 @@
|
||||
"typescript": "~5.6.3",
|
||||
"vite": "^5.4.10",
|
||||
"vue": "~3.5.12",
|
||||
"vue-echarts": "^6.6.8",
|
||||
"vue-i18n": "^9.9.0",
|
||||
"vue-router": "^4.4.0",
|
||||
"vue-tsc": "^2.1.10",
|
||||
"vue-tsc": "~2.1.10",
|
||||
"zx": "^7.2.3"
|
||||
},
|
||||
"private": true,
|
||||
|
||||
@@ -138,6 +138,17 @@ const ghApiUploadReleaseAsset = async (releaseId, assetName, file) => {
|
||||
return JSON.parse(await res.text())
|
||||
}
|
||||
|
||||
const getChangelogForVersion = async (version, changelogPath = './CHANGELOG.md') => {
|
||||
const changelog = await fs.readFile(changelogPath, 'utf8')
|
||||
const escapeRegex = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
||||
const escapedVersion = escapeRegex(version)
|
||||
|
||||
const versionRegex = new RegExp(`## \\*\\*${escapedVersion}\\*\\*.*?(?=\\n## \\*\\*|$)`, 's')
|
||||
|
||||
const match = changelog.match(versionRegex)
|
||||
return match ? match[0].trim() : undefined
|
||||
}
|
||||
|
||||
// Validate args and assign defaults -------------------------------------------
|
||||
|
||||
const headSha = (await $`git rev-parse HEAD`).stdout.trim()
|
||||
@@ -331,22 +342,31 @@ if (ghRelease) {
|
||||
|
||||
let release = (await ghApiCall('/releases')).find(release => release.tag_name === tag)
|
||||
|
||||
if (release !== undefined) {
|
||||
if (
|
||||
release !== undefined &&
|
||||
(await no(
|
||||
`Release with tag ${tag} already exists on GitHub (${chalk.blue(
|
||||
release.html_url
|
||||
)}). Skip and proceed with upload?`
|
||||
))
|
||||
) {
|
||||
stop()
|
||||
}
|
||||
if (release === undefined) {
|
||||
const releaseNotes = await getChangelogForVersion(version)
|
||||
|
||||
if (
|
||||
await no(
|
||||
`Release with tag ${tag} already exists on GitHub (${chalk.blue(
|
||||
release.html_url
|
||||
)}). Skip and proceed with upload?`
|
||||
)
|
||||
releaseNotes === undefined &&
|
||||
(await no(`Could not find changelog for version ${version}. Create release without changelog?`))
|
||||
) {
|
||||
stop()
|
||||
}
|
||||
} else {
|
||||
release = await ghApiCall('/releases', 'POST', {
|
||||
tag_name: tag,
|
||||
target_commitish: headSha,
|
||||
name: tag,
|
||||
draft: true,
|
||||
body: releaseNotes,
|
||||
})
|
||||
|
||||
console.log(`Created GitHub release ${tag}: ${chalk.blue(release.html_url)}`)
|
||||
|
||||
@@ -20,11 +20,11 @@ import AppHeader from '@/components/AppHeader.vue'
|
||||
import AppLogin from '@/components/AppLogin.vue'
|
||||
import AppNavigation from '@/components/AppNavigation.vue'
|
||||
import ModalList from '@/components/ui/modals/ModalList.vue'
|
||||
import { useChartTheme } from '@/composables/chart-theme.composable'
|
||||
import { useUnreachableHosts } from '@/composables/unreachable-hosts.composable'
|
||||
import { usePoolStore } from '@/stores/xen-api/pool.store'
|
||||
import { useXenApiStore } from '@/stores/xen-api.store'
|
||||
import VtsTooltipList from '@core/components/tooltip-list/VtsTooltipList.vue'
|
||||
import { useChartTheme } from '@core/composables/chart-theme.composable'
|
||||
import { useUiStore } from '@core/stores/ui.store'
|
||||
import { useActiveElement, useMagicKeys, whenever } from '@vueuse/core'
|
||||
import { logicAnd } from '@vueuse/math'
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<FormCheckbox v-model="rememberMe" />
|
||||
{{ $t('keep-me-logged') }}
|
||||
</label>
|
||||
<UiButton size="medium" accent="info" variant="primary" type="submit" :busy="isConnecting">
|
||||
<UiButton size="medium" accent="brand" variant="primary" type="submit" :busy="isConnecting">
|
||||
{{ $t('login') }}
|
||||
</UiButton>
|
||||
</template>
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
<template>
|
||||
<div ref="vmConsoleContainer" class="vm-console" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { useXenApiStore } from '@/stores/xen-api.store'
|
||||
import VncClient from '@novnc/novnc/lib/rfb'
|
||||
import { promiseTimeout } from '@vueuse/shared'
|
||||
import { fibonacci } from 'iterable-backoff'
|
||||
import { computed, onBeforeUnmount, ref, watchEffect } from 'vue'
|
||||
|
||||
const props = defineProps<{
|
||||
location: string
|
||||
isConsoleAvailable: boolean
|
||||
}>()
|
||||
|
||||
const N_TOTAL_TRIES = 8
|
||||
const FIBONACCI_MS_ARRAY: number[] = Array.from(fibonacci().toMs().take(N_TOTAL_TRIES))
|
||||
|
||||
const vmConsoleContainer = ref<HTMLDivElement>()
|
||||
const xenApiStore = useXenApiStore()
|
||||
const url = computed(() => {
|
||||
if (xenApiStore.currentSessionId == null) {
|
||||
return
|
||||
}
|
||||
const _url = new URL(props.location)
|
||||
_url.protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'
|
||||
_url.searchParams.set('session_id', xenApiStore.currentSessionId)
|
||||
return _url
|
||||
})
|
||||
|
||||
let vncClient: VncClient | undefined
|
||||
let nConnectionAttempts = 0
|
||||
|
||||
function handleDisconnectionEvent() {
|
||||
clearVncClient()
|
||||
|
||||
if (props.isConsoleAvailable) {
|
||||
nConnectionAttempts++
|
||||
|
||||
if (nConnectionAttempts > N_TOTAL_TRIES) {
|
||||
console.error('The number of reconnection attempts has been exceeded for:', props.location)
|
||||
return
|
||||
}
|
||||
|
||||
console.error(
|
||||
`Connection lost for the remote console: ${props.location}. New attempt in ${
|
||||
FIBONACCI_MS_ARRAY[nConnectionAttempts - 1]
|
||||
}ms`
|
||||
)
|
||||
createVncConnection()
|
||||
}
|
||||
}
|
||||
|
||||
function handleConnectionEvent() {
|
||||
nConnectionAttempts = 0
|
||||
}
|
||||
|
||||
function clearVncClient() {
|
||||
if (vncClient === undefined) {
|
||||
return
|
||||
}
|
||||
|
||||
vncClient.removeEventListener('disconnect', handleDisconnectionEvent)
|
||||
vncClient.removeEventListener('connect', handleConnectionEvent)
|
||||
|
||||
vncClient.disconnect()
|
||||
|
||||
vncClient = undefined
|
||||
}
|
||||
|
||||
async function createVncConnection() {
|
||||
if (nConnectionAttempts !== 0) {
|
||||
await promiseTimeout(FIBONACCI_MS_ARRAY[nConnectionAttempts - 1])
|
||||
|
||||
if (vncClient !== undefined) {
|
||||
// New VNC Client may have been created in the meantime
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
vncClient = new VncClient(vmConsoleContainer.value!, url.value!.toString(), {
|
||||
wsProtocols: ['binary'],
|
||||
})
|
||||
vncClient.scaleViewport = true
|
||||
|
||||
vncClient.addEventListener('disconnect', handleDisconnectionEvent)
|
||||
vncClient.addEventListener('connect', handleConnectionEvent)
|
||||
}
|
||||
|
||||
watchEffect(() => {
|
||||
if (url.value === undefined || vmConsoleContainer.value === undefined || !props.isConsoleAvailable) {
|
||||
return
|
||||
}
|
||||
|
||||
nConnectionAttempts = 0
|
||||
|
||||
clearVncClient()
|
||||
createVncConnection()
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
clearVncClient()
|
||||
})
|
||||
|
||||
defineExpose({
|
||||
sendCtrlAltDel: () => vncClient?.sendCtrlAltDel(),
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="postcss" scoped>
|
||||
.vm-console {
|
||||
flex: 1;
|
||||
max-width: 100%;
|
||||
|
||||
& > :deep(div) {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
|
||||
/* Required because the library adds "margin: auto" to the canvas which makes the canvas centered in space and not aligned to the rest of the layout */
|
||||
:deep(canvas) {
|
||||
margin: 0 auto !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -13,17 +13,13 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import TabItem from '@core/components/tab/TabItem.vue'
|
||||
import { useContext } from '@core/composables/context.composable'
|
||||
import { DisabledContext } from '@core/context'
|
||||
import { useDisabled } from '@core/composables/disabled.composable'
|
||||
import type { RouteLocationRaw } from 'vue-router'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
to: RouteLocationRaw
|
||||
disabled?: boolean
|
||||
}>(),
|
||||
{ disabled: undefined }
|
||||
)
|
||||
const props = defineProps<{
|
||||
to: RouteLocationRaw
|
||||
disabled?: boolean
|
||||
}>()
|
||||
|
||||
const isDisabled = useContext(DisabledContext, () => props.disabled)
|
||||
const isDisabled = useDisabled(() => props.disabled)
|
||||
</script>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<UiButton
|
||||
v-if="xoaFound"
|
||||
size="medium"
|
||||
accent="info"
|
||||
accent="brand"
|
||||
variant="primary"
|
||||
:left-icon="faArrowUpRightFromSquare"
|
||||
class="xoa-button"
|
||||
@@ -13,7 +13,7 @@
|
||||
<UiButton
|
||||
v-else
|
||||
size="medium"
|
||||
accent="info"
|
||||
accent="brand"
|
||||
variant="primary"
|
||||
:left-icon="faDownload"
|
||||
class="xoa-button"
|
||||
|
||||
@@ -1,53 +1,61 @@
|
||||
<template>
|
||||
<UiAccountMenuButton
|
||||
v-tooltip="menu.$isOpen ? false : { content: $t('settings'), placement: 'left' }"
|
||||
size="medium"
|
||||
v-bind="omit(menu.$trigger, ['as', 'submenu'])"
|
||||
/>
|
||||
|
||||
<VtsMenuList border v-bind="menu.$target">
|
||||
<VtsMenuItem :icon="faGear" v-bind="menu.settings">{{ $t('settings') }}</VtsMenuItem>
|
||||
<VtsMenuItem :icon="faBook" v-bind="menu.documentation">
|
||||
<MenuList placement="bottom-end">
|
||||
<template #trigger="{ open, isOpen }">
|
||||
<UiAccountMenuButton
|
||||
v-tooltip="isOpen ? false : { content: $t('settings'), placement: 'left' }"
|
||||
:selected="isOpen"
|
||||
size="medium"
|
||||
@click="open($event)"
|
||||
/>
|
||||
</template>
|
||||
<MenuItem :icon="faGear" @click="openSettings">{{ $t('settings') }}</MenuItem>
|
||||
<MenuItem :icon="faBook" @click="openUrl('https://docs.xcp-ng.org?utm_campaign=xolite&utm_term=xcpdoc')">
|
||||
{{ $t('documentation-name', { name: 'XCP-ng' }) }}
|
||||
</VtsMenuItem>
|
||||
<VtsMenuItem :icon="faHeadset" v-bind="menu.support">{{ $t('professional-support') }}</VtsMenuItem>
|
||||
<VtsMenuItem :icon="faComments" v-bind="menu.forum">{{ $t('access-forum') }}</VtsMenuItem>
|
||||
<VtsMenuItem :icon="faArrowRightFromBracket" class="menu-item-logout" v-bind="menu.logout">
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
:icon="faHeadset"
|
||||
@click="openUrl('https://vates.tech/pricing-and-support?utm_campaign=xolite&utm_term=pricing')"
|
||||
>
|
||||
{{ $t('professional-support') }}
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
:icon="faComments"
|
||||
@click="openUrl('https://xcp-ng.org/forum/topic/4731/xen-orchestra-lite?utm_campaign=xolite&utm_term=forum')"
|
||||
>
|
||||
{{ $t('access-forum') }}
|
||||
</MenuItem>
|
||||
<MenuItem :icon="faArrowRightFromBracket" class="menu-item-logout" @click="logout">
|
||||
{{ $t('log-out') }}
|
||||
</VtsMenuItem>
|
||||
</VtsMenuList>
|
||||
</MenuItem>
|
||||
</MenuList>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { useXenApiStore } from '@/stores/xen-api.store'
|
||||
import VtsMenuItem from '@core/components/menu/VtsMenuItem.vue'
|
||||
import VtsMenuList from '@core/components/menu/VtsMenuList.vue'
|
||||
import MenuItem from '@core/components/menu/MenuItem.vue'
|
||||
import MenuList from '@core/components/menu/MenuList.vue'
|
||||
import UiAccountMenuButton from '@core/components/ui/account-menu-button/UiAccountMenuButton.vue'
|
||||
import { vTooltip } from '@core/directives/tooltip.directive'
|
||||
import { action, link, routerLink, useMenuToggle } from '@core/packages/menu'
|
||||
import { faArrowRightFromBracket, faBook, faComments, faGear, faHeadset } from '@fortawesome/free-solid-svg-icons'
|
||||
import { objectOmit as omit } from '@vueuse/shared'
|
||||
import { nextTick } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const menu = useMenuToggle({
|
||||
placement: 'bottom-end',
|
||||
items: {
|
||||
settings: routerLink({ name: 'settings' }),
|
||||
documentation: link('https://docs.xcp-ng.org?utm_campaign=xolite&utm_term=xcpdoc'),
|
||||
support: link('https://vates.tech/pricing-and-support?utm_campaign=xolite&utm_term=pricing'),
|
||||
forum: link('https://xcp-ng.org/forum/topic/4731/xen-orchestra-lite?utm_campaign=xolite&utm_term=forum'),
|
||||
logout: action(async () => {
|
||||
await useXenApiStore().disconnect()
|
||||
void router.push({ name: 'home' })
|
||||
}),
|
||||
},
|
||||
})
|
||||
const logout = () => {
|
||||
const xenApiStore = useXenApiStore()
|
||||
xenApiStore.disconnect()
|
||||
nextTick(() => router.push({ name: 'home' }))
|
||||
}
|
||||
|
||||
const openUrl = (url: string) => {
|
||||
window.open(url, '_blank', 'noopener noreferrer')
|
||||
}
|
||||
const openSettings = () => router.push({ name: 'settings' })
|
||||
</script>
|
||||
|
||||
<style lang="postcss" scoped>
|
||||
:deep(.menu-item-logout) {
|
||||
.menu-item-logout {
|
||||
color: var(--color-danger-txt-base);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -7,23 +7,23 @@
|
||||
v-if="unreadEventsCount > 0"
|
||||
:value="unreadEventsCount"
|
||||
accent="success"
|
||||
size="small"
|
||||
variant="primary"
|
||||
size="small"
|
||||
/>
|
||||
</TabItem>
|
||||
<TabItem v-bind="tab(TAB.SLOTS, slotParams)">Slots</TabItem>
|
||||
<TabItem v-bind="tab(TAB.SETTINGS, settingParams)">Settings</TabItem>
|
||||
<TabItem class="preset-tab" v-bind="presetMenu.$trigger">
|
||||
<UiIcon :icon="faSliders" />
|
||||
Presets
|
||||
</TabItem>
|
||||
<Teleport to="body">
|
||||
<VtsMenuList border v-bind="presetMenu.$target">
|
||||
<VtsMenuItem v-for="(preset, label) in presets" :key="label" v-bind="presetMenu[label]">
|
||||
{{ label }}
|
||||
</VtsMenuItem>
|
||||
</VtsMenuList>
|
||||
</Teleport>
|
||||
<MenuList placement="bottom">
|
||||
<template #trigger="{ open, isOpen }">
|
||||
<TabItem :active="isOpen" :disabled="presets === undefined" class="preset-tab" @click="open">
|
||||
<UiIcon :icon="faSliders" />
|
||||
Presets
|
||||
</TabItem>
|
||||
</template>
|
||||
<MenuItem v-for="(preset, label) in presets" :key="label" @click="applyPreset(preset)">
|
||||
{{ label }}
|
||||
</MenuItem>
|
||||
</MenuList>
|
||||
</TabList>
|
||||
|
||||
<div :class="{ 'full-width': fullWidthComponent }" class="tabs">
|
||||
@@ -43,8 +43,8 @@
|
||||
<template #right>
|
||||
<UiButton
|
||||
v-if="eventsLog.length > 0"
|
||||
accent="info"
|
||||
size="medium"
|
||||
accent="brand"
|
||||
variant="tertiary"
|
||||
@click="eventsLog = []"
|
||||
>
|
||||
@@ -91,13 +91,12 @@ import {
|
||||
ModelParam,
|
||||
type Param,
|
||||
} from '@/libs/story/story-param'
|
||||
import VtsMenuItem from '@core/components/menu/VtsMenuItem.vue'
|
||||
import VtsMenuList from '@core/components/menu/VtsMenuList.vue'
|
||||
import MenuItem from '@core/components/menu/MenuItem.vue'
|
||||
import MenuList from '@core/components/menu/MenuList.vue'
|
||||
import TabItem from '@core/components/tab/TabItem.vue'
|
||||
import TabList from '@core/components/tab/TabList.vue'
|
||||
import UiButton from '@core/components/ui/button/UiButton.vue'
|
||||
import UiCounter from '@core/components/ui/counter/UiCounter.vue'
|
||||
import { action, useMenuToggle } from '@core/packages/menu'
|
||||
import { faSliders } from '@fortawesome/free-solid-svg-icons'
|
||||
import 'highlight.js/styles/github-dark.css'
|
||||
import { uniqueId, upperFirst } from 'lodash-es'
|
||||
@@ -267,17 +266,6 @@ const applyPreset = (preset: { props?: Record<string, any>; settings?: Record<st
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const presetMenu = useMenuToggle({
|
||||
placement: 'bottom-end',
|
||||
items: computed(() =>
|
||||
Object.fromEntries(
|
||||
Object.entries(props.presets ?? {}).map(([label, preset]) => {
|
||||
return [label, action(() => applyPreset(preset))]
|
||||
})
|
||||
)
|
||||
),
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="postcss" scoped>
|
||||
|
||||
@@ -16,23 +16,19 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import UiIcon from '@/components/ui/icon/UiIcon.vue'
|
||||
import { useContext } from '@/composables/context.composable'
|
||||
import { DisabledContext } from '@/context'
|
||||
import { IK_CHECKBOX_TYPE, IK_FORM_HAS_LABEL } from '@/types/injection-keys'
|
||||
import { useDisabled } from '@core/composables/disabled.composable'
|
||||
import { faCheck, faCircle, faMinus } from '@fortawesome/free-solid-svg-icons'
|
||||
import { useVModel } from '@vueuse/core'
|
||||
import { computed, type HTMLAttributes, inject, useAttrs } from 'vue'
|
||||
|
||||
defineOptions({ inheritAttrs: false })
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
modelValue?: unknown
|
||||
disabled?: boolean
|
||||
wrapperAttrs?: HTMLAttributes
|
||||
}>(),
|
||||
{ disabled: undefined }
|
||||
)
|
||||
const props = defineProps<{
|
||||
modelValue?: unknown
|
||||
disabled?: boolean
|
||||
wrapperAttrs?: HTMLAttributes
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [value: boolean]
|
||||
@@ -46,7 +42,7 @@ const hasLabel = inject(
|
||||
IK_FORM_HAS_LABEL,
|
||||
computed(() => false)
|
||||
)
|
||||
const isDisabled = useContext(DisabledContext, () => props.disabled)
|
||||
const isDisabled = useDisabled(() => props.disabled)
|
||||
const icon = computed(() => {
|
||||
if (type !== 'checkbox') {
|
||||
return faCircle
|
||||
|
||||
@@ -53,9 +53,10 @@
|
||||
<script lang="ts" setup>
|
||||
import UiIcon from '@/components/ui/icon/UiIcon.vue'
|
||||
import { useContext } from '@/composables/context.composable'
|
||||
import { ColorContext, DisabledContext } from '@/context'
|
||||
import { ColorContext } from '@/context'
|
||||
import type { Color } from '@/types'
|
||||
import { IK_INPUT_ID, IK_INPUT_TYPE } from '@/types/injection-keys'
|
||||
import { useDisabled } from '@core/composables/disabled.composable'
|
||||
import type { IconDefinition } from '@fortawesome/fontawesome-common-types'
|
||||
import { faAngleDown } from '@fortawesome/free-solid-svg-icons'
|
||||
import { useTextareaAutosize, useVModel } from '@vueuse/core'
|
||||
@@ -63,22 +64,19 @@ import { computed, type HTMLAttributes, inject, nextTick, ref, useAttrs, watch }
|
||||
|
||||
defineOptions({ inheritAttrs: false })
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
id?: string
|
||||
modelValue?: any
|
||||
color?: Color
|
||||
before?: IconDefinition | string
|
||||
after?: IconDefinition | string
|
||||
beforeWidth?: string
|
||||
afterWidth?: string
|
||||
disabled?: boolean
|
||||
required?: boolean
|
||||
right?: boolean
|
||||
wrapperAttrs?: HTMLAttributes
|
||||
}>(),
|
||||
{ disabled: undefined }
|
||||
)
|
||||
const props = defineProps<{
|
||||
id?: string
|
||||
modelValue?: any
|
||||
color?: Color
|
||||
before?: IconDefinition | string
|
||||
after?: IconDefinition | string
|
||||
beforeWidth?: string
|
||||
afterWidth?: string
|
||||
disabled?: boolean
|
||||
required?: boolean
|
||||
right?: boolean
|
||||
wrapperAttrs?: HTMLAttributes
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [value: any]
|
||||
@@ -94,7 +92,7 @@ const value = useVModel(props, 'modelValue', emit)
|
||||
const isEmpty = computed(() => props.modelValue == null || String(props.modelValue).trim() === '')
|
||||
const inputType = inject(IK_INPUT_TYPE, 'input')
|
||||
|
||||
const isDisabled = useContext(DisabledContext, () => props.disabled)
|
||||
const isDisabled = useDisabled(() => props.disabled)
|
||||
|
||||
const wrapperClass = computed(() => [
|
||||
`form-${inputType}`,
|
||||
|
||||
@@ -36,28 +36,26 @@
|
||||
<script lang="ts" setup>
|
||||
import UiIcon from '@/components/ui/icon/UiIcon.vue'
|
||||
import { useContext } from '@/composables/context.composable'
|
||||
import { ColorContext, DisabledContext } from '@/context'
|
||||
import { ColorContext } from '@/context'
|
||||
import type { Color } from '@/types'
|
||||
import { IK_FORM_HAS_LABEL, IK_INPUT_ID } from '@/types/injection-keys'
|
||||
import { useDisabled } from '@core/composables/disabled.composable'
|
||||
import type { IconDefinition } from '@fortawesome/fontawesome-common-types'
|
||||
import { faInfoCircle } from '@fortawesome/free-solid-svg-icons'
|
||||
import { uniqueId } from 'lodash-es'
|
||||
import { computed, provide } from 'vue'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
label?: string
|
||||
id?: string
|
||||
icon?: IconDefinition
|
||||
learnMoreUrl?: string
|
||||
warning?: string
|
||||
error?: string
|
||||
help?: string
|
||||
disabled?: boolean
|
||||
light?: boolean
|
||||
}>(),
|
||||
{ disabled: undefined }
|
||||
)
|
||||
const props = defineProps<{
|
||||
label?: string
|
||||
id?: string
|
||||
icon?: IconDefinition
|
||||
learnMoreUrl?: string
|
||||
warning?: string
|
||||
error?: string
|
||||
help?: string
|
||||
disabled?: boolean
|
||||
light?: boolean
|
||||
}>()
|
||||
|
||||
const id = computed(() => props.id ?? uniqueId('form-input-'))
|
||||
provide(IK_INPUT_ID, id)
|
||||
@@ -80,7 +78,7 @@ provide(
|
||||
)
|
||||
|
||||
useContext(ColorContext, color)
|
||||
useContext(DisabledContext, () => props.disabled)
|
||||
useDisabled(() => props.disabled)
|
||||
</script>
|
||||
|
||||
<style lang="postcss" scoped>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<RouterTab :to="{ name: 'host.console', params: { uuid } }">
|
||||
{{ $t('console') }}
|
||||
</RouterTab>
|
||||
<RouterTab :to="{ name: 'host.network', params: { uuid } }" disabled>
|
||||
<RouterTab :to="{ name: 'host.network', params: { uuid } }">
|
||||
{{ $t('network') }}
|
||||
</RouterTab>
|
||||
<RouterTab :to="{ name: 'host.tasks', params: { uuid } }" disabled>
|
||||
|
||||
291
@xen-orchestra/lite/src/components/host/network/HostPifTable.vue
Normal file
291
@xen-orchestra/lite/src/components/host/network/HostPifTable.vue
Normal file
@@ -0,0 +1,291 @@
|
||||
<template>
|
||||
<div class="host-pif-table">
|
||||
<UiTitle>
|
||||
{{ $t('pifs') }}
|
||||
<template #actions>
|
||||
<UiButton
|
||||
v-tooltip="$t('coming-soon')"
|
||||
disabled
|
||||
:left-icon="faPlus"
|
||||
variant="secondary"
|
||||
accent="brand"
|
||||
size="medium"
|
||||
>
|
||||
{{ $t('scan-pifs') }}
|
||||
</UiButton>
|
||||
</template>
|
||||
</UiTitle>
|
||||
<div class="container">
|
||||
<div class="table-actions">
|
||||
<UiQuerySearchBar @search="(value: string) => (searchQuery = value)" />
|
||||
<UiTableActions :title="$t('table-actions')">
|
||||
<UiButton
|
||||
v-tooltip="$t('coming-soon')"
|
||||
disabled
|
||||
:left-icon="faEdit"
|
||||
variant="tertiary"
|
||||
accent="brand"
|
||||
size="medium"
|
||||
>
|
||||
{{ $t('edit') }}
|
||||
</UiButton>
|
||||
<UiButton
|
||||
v-tooltip="$t('coming-soon')"
|
||||
disabled
|
||||
:left-icon="faTrash"
|
||||
variant="tertiary"
|
||||
accent="danger"
|
||||
size="medium"
|
||||
>
|
||||
{{ $t('delete') }}
|
||||
</UiButton>
|
||||
</UiTableActions>
|
||||
<UiTopBottomTable :selected-items="0" :total-items="0" />
|
||||
</div>
|
||||
<VtsDataTable :is-ready :has-error :no-data-message="pifs.length === 0 ? $t('no-pif-detected') : undefined">
|
||||
<template #thead>
|
||||
<tr>
|
||||
<template v-for="column of visibleColumns" :key="column.id">
|
||||
<th v-if="column.id === 'checkbox'" class="checkbox">
|
||||
<div v-tooltip="$t('coming-soon')">
|
||||
<UiCheckbox disabled :v-model="areAllSelected" accent="brand" />
|
||||
</div>
|
||||
</th>
|
||||
<th v-else-if="column.id === 'more'" class="more">
|
||||
<UiButtonIcon v-tooltip="$t('coming-soon')" :icon="faEllipsis" accent="brand" disabled size="small" />
|
||||
</th>
|
||||
<th v-else>
|
||||
<div v-tooltip class="text-ellipsis">
|
||||
<VtsIcon accent="brand" :icon="headerIcon[column.id]" />
|
||||
{{ column.label }}
|
||||
</div>
|
||||
</th>
|
||||
</template>
|
||||
</tr>
|
||||
</template>
|
||||
<template #tbody>
|
||||
<tr
|
||||
v-for="row of rows"
|
||||
:key="row.id"
|
||||
:class="{ selected: selectedPifId === row.id }"
|
||||
@click="selectedPifId = row.id"
|
||||
>
|
||||
<td
|
||||
v-for="column of row.visibleColumns"
|
||||
:key="column.id"
|
||||
class="typo p2-regular"
|
||||
:class="{ checkbox: column.id === 'checkbox' }"
|
||||
>
|
||||
<div v-if="column.id === 'checkbox'" v-tooltip="$t('coming-soon')">
|
||||
<UiCheckbox v-model="selected" disabled accent="brand" :value="row.id" />
|
||||
</div>
|
||||
<UiButtonIcon
|
||||
v-else-if="column.id === 'more'"
|
||||
v-tooltip="$t('coming-soon')"
|
||||
:icon="faEllipsis"
|
||||
accent="brand"
|
||||
disabled
|
||||
size="small"
|
||||
/>
|
||||
<div v-else-if="column.id === 'status'" v-tooltip>
|
||||
<VtsConnectionStatus :status="column.value" />
|
||||
</div>
|
||||
<div v-else-if="column.id === 'network'" class="network">
|
||||
<!-- TODO Remove the span when the link works and the icon is fixed -->
|
||||
<!--
|
||||
<UiComplexIcon size="medium" class="icon">
|
||||
<VtsIcon :icon="faNetworkWired" accent="current" />
|
||||
<VtsIcon accent="success" :icon="faCircle" :overlay-icon="faCheck" />
|
||||
</UiComplexIcon>
|
||||
<a v-tooltip href="" class="text-ellipsis name">{{ column.value.name }}</a>
|
||||
-->
|
||||
<span v-tooltip class="text-ellipsis name">{{ column.value.name }}</span>
|
||||
<VtsIcon
|
||||
v-if="column.value.management"
|
||||
v-tooltip="$t('management')"
|
||||
accent="warning"
|
||||
:icon="faCircle"
|
||||
:overlay-icon="faStar"
|
||||
/>
|
||||
</div>
|
||||
<div v-else v-tooltip="{ placement: 'bottom-end' }" class="text-ellipsis">
|
||||
{{ column.value }}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
</VtsDataTable>
|
||||
<VtsStateHero v-if="searchQuery && filteredPifs.length === 0" type="table" image="no-result">
|
||||
<div>{{ $t('no-result') }}</div>
|
||||
</VtsStateHero>
|
||||
<UiTopBottomTable :selected-items="0" :total-items="0" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import useMultiSelect from '@/composables/multi-select.composable'
|
||||
import type { XenApiHost, XenApiNetwork, XenApiPif } from '@/libs/xen-api/xen-api.types'
|
||||
import { useHostStore } from '@/stores/xen-api/host.store'
|
||||
import { useNetworkStore } from '@/stores/xen-api/network.store'
|
||||
import { usePifMetricsStore } from '@/stores/xen-api/pif-metrics.store'
|
||||
import { usePifStore } from '@/stores/xen-api/pif.store'
|
||||
import VtsConnectionStatus from '@core/components/connection-status/VtsConnectionStatus.vue'
|
||||
import VtsDataTable from '@core/components/data-table/VtsDataTable.vue'
|
||||
import VtsIcon from '@core/components/icon/VtsIcon.vue'
|
||||
import VtsStateHero from '@core/components/state-hero/VtsStateHero.vue'
|
||||
import UiButton from '@core/components/ui/button/UiButton.vue'
|
||||
import UiButtonIcon from '@core/components/ui/button-icon/UiButtonIcon.vue'
|
||||
import UiCheckbox from '@core/components/ui/checkbox/UiCheckbox.vue'
|
||||
import UiQuerySearchBar from '@core/components/ui/query-search-bar/UiQuerySearchBar.vue'
|
||||
import UiTableActions from '@core/components/ui/table-actions/UiTableActions.vue'
|
||||
import UiTitle from '@core/components/ui/title/UiTitle.vue'
|
||||
import UiTopBottomTable from '@core/components/ui/top-bottom-table/UiTopBottomTable.vue'
|
||||
import { useRouteQuery } from '@core/composables/route-query.composable'
|
||||
import { useTable } from '@core/composables/table.composable'
|
||||
import { vTooltip } from '@core/directives/tooltip.directive'
|
||||
import type { IconDefinition } from '@fortawesome/fontawesome-common-types'
|
||||
import {
|
||||
faAlignLeft,
|
||||
faAt,
|
||||
faCaretDown,
|
||||
faCircle,
|
||||
faEdit,
|
||||
faEllipsis,
|
||||
faPlus,
|
||||
faPowerOff,
|
||||
faStar,
|
||||
faTrash,
|
||||
} from '@fortawesome/free-solid-svg-icons'
|
||||
import { noop } from '@vueuse/shared'
|
||||
import { computed, ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useRoute } from 'vue-router'
|
||||
|
||||
const { records, isReady, hasError } = usePifStore().subscribe()
|
||||
const { getByOpaqueRef: getHostOpaqueRef } = useHostStore().subscribe()
|
||||
const { getByOpaqueRef: getNetworkOpaqueRef } = useNetworkStore().subscribe()
|
||||
const { getPifCarrier } = usePifMetricsStore().subscribe()
|
||||
|
||||
const { t } = useI18n()
|
||||
const selectedPifId = useRouteQuery('id')
|
||||
const searchQuery = ref('')
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
const hostId = route.params.uuid as XenApiHost['uuid']
|
||||
|
||||
const pifs = computed(() => {
|
||||
return records.value.filter(pif => {
|
||||
const host = getHostOpaqueRef(pif.host)
|
||||
|
||||
return host?.uuid === hostId
|
||||
})
|
||||
})
|
||||
|
||||
// TODO change to match with network name
|
||||
const filteredPifs = computed(() => {
|
||||
const searchTerm = searchQuery.value.trim().toLocaleLowerCase()
|
||||
|
||||
if (!searchTerm) {
|
||||
return pifs.value
|
||||
}
|
||||
|
||||
return pifs.value.filter(pif =>
|
||||
Object.values(pif).some(value => String(value).toLocaleLowerCase().includes(searchTerm))
|
||||
)
|
||||
})
|
||||
|
||||
const pifsUuids = computed(() => pifs.value.map(pif => pif.uuid))
|
||||
|
||||
const { selected, areAllSelected } = useMultiSelect(pifsUuids)
|
||||
|
||||
const getNetworkName = (networkRef: XenApiNetwork['$ref']) => {
|
||||
const network = getNetworkOpaqueRef(networkRef)
|
||||
|
||||
return network?.name_label ? network.name_label : ''
|
||||
}
|
||||
|
||||
const getVlanData = (vlan: number) => (vlan !== -1 ? vlan : t('none'))
|
||||
|
||||
const getPifStatus = (pif: XenApiPif) => {
|
||||
const carrier = getPifCarrier(pif)
|
||||
const isCurrentlyAttached = pif.currently_attached
|
||||
|
||||
if (!isCurrentlyAttached) {
|
||||
return 'disconnected'
|
||||
}
|
||||
|
||||
if (!carrier) {
|
||||
return 'disconnected-from-physical-device'
|
||||
}
|
||||
|
||||
return 'connected'
|
||||
}
|
||||
|
||||
const { visibleColumns, rows } = useTable('pifs', filteredPifs, {
|
||||
rowId: record => record.uuid,
|
||||
columns: define => [
|
||||
define('checkbox', noop, { label: '', isHideable: false }),
|
||||
define(
|
||||
'network',
|
||||
record => ({
|
||||
name: getNetworkName(record.network),
|
||||
management: record.management,
|
||||
}),
|
||||
{ label: t('network') }
|
||||
),
|
||||
define('device', { label: t('device') }),
|
||||
define('status', record => getPifStatus(record), { label: t('status') }),
|
||||
define('VLAN', record => getVlanData(record.VLAN), { label: t('vlan') }),
|
||||
define('IP', { label: t('ip-addresses') }),
|
||||
define('MAC', { label: t('mac-addresses') }),
|
||||
define('ip_configuration_mode', { label: t('ip-mode') }),
|
||||
define('more', noop, { label: '', isHideable: false }),
|
||||
],
|
||||
})
|
||||
type PifHeader = 'network' | 'device' | 'status' | 'VLAN' | 'IP' | 'MAC' | 'ip_configuration_mode'
|
||||
const headerIcon: Record<PifHeader, IconDefinition> = {
|
||||
network: faAlignLeft,
|
||||
device: faAlignLeft,
|
||||
status: faPowerOff,
|
||||
VLAN: faAlignLeft,
|
||||
IP: faAt,
|
||||
MAC: faAt,
|
||||
ip_configuration_mode: faCaretDown,
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="postcss">
|
||||
.host-pif-table,
|
||||
.table-actions,
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.host-pif-table {
|
||||
gap: 2.4rem;
|
||||
|
||||
.container,
|
||||
.table-actions {
|
||||
gap: 0.8rem;
|
||||
}
|
||||
|
||||
.network {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1.8rem;
|
||||
}
|
||||
|
||||
.checkbox,
|
||||
.more {
|
||||
width: 4.8rem;
|
||||
}
|
||||
|
||||
.checkbox {
|
||||
text-align: center;
|
||||
line-height: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -3,12 +3,12 @@
|
||||
<UiTreeItemLabel :icon="faServer" :route="{ name: 'host.console', params: { uuid: host.uuid } }" @toggle="toggle()">
|
||||
{{ host.name_label || '(Host)' }}
|
||||
<template #addons>
|
||||
<UiIcon v-if="isPoolMaster" v-tooltip="$t('master')" :icon="faStar" accent="warning" />
|
||||
<VtsIcon v-if="isPoolMaster" v-tooltip="$t('master')" accent="info" :icon="faCircle" :overlay-icon="faStar" />
|
||||
<UiCounter
|
||||
v-if="isReady"
|
||||
v-tooltip="$t('running-vm', { count: vmCount })"
|
||||
:value="vmCount"
|
||||
accent="info"
|
||||
accent="brand"
|
||||
variant="secondary"
|
||||
size="small"
|
||||
/>
|
||||
@@ -28,13 +28,13 @@ import type { XenApiHost } from '@/libs/xen-api/xen-api.types'
|
||||
import { useHostStore } from '@/stores/xen-api/host.store'
|
||||
import { usePoolStore } from '@/stores/xen-api/pool.store'
|
||||
import { useVmStore } from '@/stores/xen-api/vm.store'
|
||||
import UiIcon from '@core/components/icon/VtsIcon.vue'
|
||||
import VtsIcon from '@core/components/icon/VtsIcon.vue'
|
||||
import VtsTreeItem from '@core/components/tree/VtsTreeItem.vue'
|
||||
import VtsTreeList from '@core/components/tree/VtsTreeList.vue'
|
||||
import UiCounter from '@core/components/ui/counter/UiCounter.vue'
|
||||
import UiTreeItemLabel from '@core/components/ui/tree-item-label/UiTreeItemLabel.vue'
|
||||
import { vTooltip } from '@core/directives/tooltip.directive'
|
||||
import { faServer, faStar } from '@fortawesome/free-solid-svg-icons'
|
||||
import { faCircle, faServer, faStar } from '@fortawesome/free-solid-svg-icons'
|
||||
import { useToggle } from '@vueuse/shared'
|
||||
import { computed } from 'vue'
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
</template>
|
||||
|
||||
<template #buttons>
|
||||
<UiButton size="medium" accent="info" variant="tertiary" @click="addNewFilter()">
|
||||
<UiButton size="medium" accent="brand" variant="tertiary" @click="addNewFilter()">
|
||||
{{ $t('add-or') }}
|
||||
</UiButton>
|
||||
<ModalDeclineButton />
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
</template>
|
||||
|
||||
<template #buttons>
|
||||
<UiButton size="medium" accent="info" variant="tertiary" @click="formatJson()">
|
||||
<UiButton size="medium" accent="brand" variant="tertiary" @click="formatJson()">
|
||||
{{ $t('reformat') }}
|
||||
</UiButton>
|
||||
<ModalDeclineButton />
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<RouterTab :to="{ name: 'pool.system', params: { uuid: pool?.uuid } }" disabled>
|
||||
{{ $t('system') }}
|
||||
</RouterTab>
|
||||
<RouterTab :to="{ name: 'pool.network', params: { uuid: pool?.uuid } }" disabled>
|
||||
<RouterTab :to="{ name: 'pool.network', params: { uuid: pool?.uuid } }">
|
||||
{{ $t('network') }}
|
||||
</RouterTab>
|
||||
<RouterTab :to="{ name: 'pool.storage', params: { uuid: pool?.uuid } }" disabled>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<p class="text typo h4-medium">
|
||||
{{ $t('click-to-display-alarms') }}
|
||||
</p>
|
||||
<UiButton size="medium" accent="info" variant="primary" @click="start">{{ $t('load-now') }}</UiButton>
|
||||
<UiButton size="medium" accent="brand" variant="primary" @click="start">{{ $t('load-now') }}</UiButton>
|
||||
</div>
|
||||
<div>
|
||||
<img alt="" src="@/assets/server-status.svg" />
|
||||
|
||||
@@ -19,16 +19,16 @@ import { formatSize } from '@/libs/utils'
|
||||
import { RRD_STEP_FROM_STRING } from '@/libs/xapi-stats'
|
||||
import type { HostStats } from '@/libs/xapi-stats'
|
||||
import { useHostStore } from '@/stores/xen-api/host.store'
|
||||
import type { LinearChartData } from '@/types/chart'
|
||||
import { UiCardTitleLevel } from '@/types/enums'
|
||||
import { IK_HOST_LAST_WEEK_STATS } from '@/types/injection-keys'
|
||||
import type { LinearChartData } from '@core/types/chart'
|
||||
import { map } from 'lodash-es'
|
||||
import { computed, defineAsyncComponent, inject } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const LinearChart = defineAsyncComponent(() => import('@/components/charts/LinearChart.vue'))
|
||||
const LinearChart = defineAsyncComponent(() => import('@core/components/charts/LinearChart.vue'))
|
||||
|
||||
const hostLastWeekStats = inject(IK_HOST_LAST_WEEK_STATS)
|
||||
const { hasError, isFetching } = useHostStore().subscribe()
|
||||
|
||||
@@ -18,14 +18,14 @@ import UiCardTitle from '@/components/ui/UiCardTitle.vue'
|
||||
import type { HostStats } from '@/libs/xapi-stats'
|
||||
import { RRD_STEP_FROM_STRING } from '@/libs/xapi-stats'
|
||||
import { useHostStore } from '@/stores/xen-api/host.store'
|
||||
import type { LinearChartData, ValueFormatter } from '@/types/chart'
|
||||
import { UiCardTitleLevel } from '@/types/enums'
|
||||
import { IK_HOST_LAST_WEEK_STATS } from '@/types/injection-keys'
|
||||
import type { LinearChartData, ValueFormatter } from '@core/types/chart'
|
||||
import { sumBy } from 'lodash-es'
|
||||
import { computed, defineAsyncComponent, inject } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const LinearChart = defineAsyncComponent(() => import('@/components/charts/LinearChart.vue'))
|
||||
const LinearChart = defineAsyncComponent(() => import('@core/components/charts/LinearChart.vue'))
|
||||
|
||||
const { t, n } = useI18n()
|
||||
|
||||
|
||||
@@ -21,14 +21,14 @@ import { formatSize } from '@/libs/utils'
|
||||
import { RRD_STEP_FROM_STRING } from '@/libs/xapi-stats'
|
||||
import { useHostMetricsStore } from '@/stores/xen-api/host-metrics.store'
|
||||
import { useHostStore } from '@/stores/xen-api/host.store'
|
||||
import type { LinearChartData } from '@/types/chart'
|
||||
import { UiCardTitleLevel } from '@/types/enums'
|
||||
import { IK_HOST_LAST_WEEK_STATS } from '@/types/injection-keys'
|
||||
import type { LinearChartData } from '@core/types/chart'
|
||||
import { sumBy } from 'lodash-es'
|
||||
import { computed, defineAsyncComponent, inject } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const LinearChart = defineAsyncComponent(() => import('@/components/charts/LinearChart.vue'))
|
||||
const LinearChart = defineAsyncComponent(() => import('@core/components/charts/LinearChart.vue'))
|
||||
|
||||
const { runningHosts, isFetching, hasError } = useHostStore().subscribe()
|
||||
const { getHostMemory } = useHostMetricsStore().subscribe()
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
<template>
|
||||
<div class="pool-host-internal-networks-table">
|
||||
<UiTitle>
|
||||
{{ $t('host-internal-networks') }}
|
||||
<template #actions>
|
||||
<UiButton
|
||||
v-tooltip="$t('coming-soon')"
|
||||
disabled
|
||||
:left-icon="faPlus"
|
||||
variant="secondary"
|
||||
accent="brand"
|
||||
size="medium"
|
||||
>
|
||||
{{ $t('new') }}
|
||||
</UiButton>
|
||||
</template>
|
||||
</UiTitle>
|
||||
<div class="container">
|
||||
<div class="table-actions">
|
||||
<UiQuerySearchBar @search="value => (searchQuery = value)" />
|
||||
<UiTableActions :title="t('table-actions')">
|
||||
<UiButton
|
||||
v-tooltip="$t('coming-soon')"
|
||||
disabled
|
||||
:left-icon="faEdit"
|
||||
variant="tertiary"
|
||||
accent="brand"
|
||||
size="medium"
|
||||
>
|
||||
{{ $t('edit') }}
|
||||
</UiButton>
|
||||
<UiButton
|
||||
v-tooltip="$t('coming-soon')"
|
||||
disabled
|
||||
:left-icon="faTrash"
|
||||
variant="tertiary"
|
||||
accent="danger"
|
||||
size="medium"
|
||||
>
|
||||
{{ $t('delete') }}
|
||||
</UiButton>
|
||||
</UiTableActions>
|
||||
<UiTopBottomTable :selected-items="0" :total-items="0" @toggle-select-all="toggleSelect" />
|
||||
</div>
|
||||
<VtsDataTable
|
||||
:is-ready
|
||||
:has-error
|
||||
:no-data-message="networks.length === 0 ? $t('no-network-detected') : undefined"
|
||||
>
|
||||
<template #thead>
|
||||
<tr>
|
||||
<template v-for="column of visibleColumns" :key="column.id">
|
||||
<th v-if="column.id === 'checkbox'" class="checkbox">
|
||||
<div v-tooltip="$t('coming-soon')">
|
||||
<UiCheckbox disabled :v-model="areAllSelected" accent="brand" @update:model-value="toggleSelect" />
|
||||
</div>
|
||||
</th>
|
||||
<th v-else-if="column.id === 'more'" class="more">
|
||||
<UiButtonIcon v-tooltip="$t('coming-soon')" :icon="faEllipsis" accent="brand" disabled size="small" />
|
||||
</th>
|
||||
<th v-else>
|
||||
<div v-tooltip class="text-ellipsis">
|
||||
<VtsIcon accent="brand" :icon="headerIcon[column.id]" />
|
||||
{{ column.label }}
|
||||
</div>
|
||||
</th>
|
||||
</template>
|
||||
</tr>
|
||||
</template>
|
||||
<template #tbody>
|
||||
<tr
|
||||
v-for="row of rows"
|
||||
:key="row.id"
|
||||
:class="{ selected: selectedNetworkId === row.id }"
|
||||
@click="selectedNetworkId = row.id"
|
||||
>
|
||||
<td
|
||||
v-for="column of row.visibleColumns"
|
||||
:key="column.id"
|
||||
class="typo p2-regular"
|
||||
:class="{ checkbox: column.id === 'checkbox' }"
|
||||
>
|
||||
<div v-if="column.id === 'checkbox'" v-tooltip="$t('coming-soon')">
|
||||
<UiCheckbox v-model="selected" disabled accent="brand" :value="row.id" />
|
||||
</div>
|
||||
<UiButtonIcon
|
||||
v-else-if="column.id === 'more'"
|
||||
v-tooltip="$t('coming-soon')"
|
||||
:icon="faEllipsis"
|
||||
accent="brand"
|
||||
disabled
|
||||
size="small"
|
||||
/>
|
||||
<div v-else v-tooltip="{ placement: 'bottom-end' }" class="text-ellipsis">
|
||||
{{ column.value }}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
</VtsDataTable>
|
||||
<VtsStateHero v-if="searchQuery && filteredNetworks.length === 0" type="table" image="no-result">
|
||||
<div>{{ $t('no-result') }}</div>
|
||||
</VtsStateHero>
|
||||
<UiTopBottomTable :selected-items="0" :total-items="0" @toggle-select-all="toggleSelect" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import useMultiSelect from '@/composables/multi-select.composable'
|
||||
import { useNetworkStore } from '@/stores/xen-api/network.store'
|
||||
import VtsDataTable from '@core/components/data-table/VtsDataTable.vue'
|
||||
import VtsIcon from '@core/components/icon/VtsIcon.vue'
|
||||
import VtsStateHero from '@core/components/state-hero/VtsStateHero.vue'
|
||||
import UiButton from '@core/components/ui/button/UiButton.vue'
|
||||
import UiButtonIcon from '@core/components/ui/button-icon/UiButtonIcon.vue'
|
||||
import UiCheckbox from '@core/components/ui/checkbox/UiCheckbox.vue'
|
||||
import UiQuerySearchBar from '@core/components/ui/query-search-bar/UiQuerySearchBar.vue'
|
||||
import UiTableActions from '@core/components/ui/table-actions/UiTableActions.vue'
|
||||
import UiTitle from '@core/components/ui/title/UiTitle.vue'
|
||||
import UiTopBottomTable from '@core/components/ui/top-bottom-table/UiTopBottomTable.vue'
|
||||
import { useRouteQuery } from '@core/composables/route-query.composable'
|
||||
import { useTable } from '@core/composables/table.composable'
|
||||
import { vTooltip } from '@core/directives/tooltip.directive'
|
||||
import type { IconDefinition } from '@fortawesome/fontawesome-common-types'
|
||||
import {
|
||||
faAlignLeft,
|
||||
faCaretDown,
|
||||
faEdit,
|
||||
faEllipsis,
|
||||
faHashtag,
|
||||
faPlus,
|
||||
faTrash,
|
||||
} from '@fortawesome/free-solid-svg-icons'
|
||||
import { noop } from '@vueuse/shared'
|
||||
import { computed, ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const { networksWithoutPifs: networks, isReady, hasError } = useNetworkStore().subscribe()
|
||||
|
||||
const { t } = useI18n()
|
||||
const searchQuery = ref('')
|
||||
const selectedNetworkId = useRouteQuery('id')
|
||||
|
||||
const filteredNetworks = computed(() => {
|
||||
const searchTerm = searchQuery.value.trim().toLocaleLowerCase()
|
||||
if (!searchTerm) {
|
||||
return networks.value
|
||||
}
|
||||
return networks.value.filter(network =>
|
||||
Object.values(network).some(value => String(value).toLocaleLowerCase().includes(searchTerm))
|
||||
)
|
||||
})
|
||||
|
||||
const networkUuids = computed(() => networks.value.map(network => network.uuid))
|
||||
|
||||
const { selected, areAllSelected } = useMultiSelect(networkUuids)
|
||||
|
||||
const toggleSelect = () => {
|
||||
selected.value = selected.value.length === 0 ? networkUuids.value : []
|
||||
}
|
||||
|
||||
const getLockingMode = (lockingMode: string) => (lockingMode === 'disabled' ? t('disabled') : t('unlocked'))
|
||||
|
||||
const { visibleColumns, rows } = useTable('networks', filteredNetworks, {
|
||||
rowId: record => record.uuid,
|
||||
columns: define => [
|
||||
define('checkbox', noop, { label: '', isHideable: false }),
|
||||
define('name_label', { label: t('name') }),
|
||||
define('name_description', { label: t('description') }),
|
||||
define('MTU', { label: t('mtu') }),
|
||||
define('default_locking_mode', record => getLockingMode(record.default_locking_mode), {
|
||||
label: t('default-locking-mode'),
|
||||
}),
|
||||
define('more', noop, { label: '', isHideable: false }),
|
||||
],
|
||||
})
|
||||
|
||||
type NetworkHeader = 'name_label' | 'name_description' | 'MTU' | 'default_locking_mode'
|
||||
|
||||
const headerIcon: Record<NetworkHeader, IconDefinition> = {
|
||||
name_label: faAlignLeft,
|
||||
name_description: faAlignLeft,
|
||||
MTU: faHashtag,
|
||||
default_locking_mode: faCaretDown,
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="postcss">
|
||||
.pool-host-internal-networks-table,
|
||||
.table-actions,
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.pool-host-internal-networks-table {
|
||||
gap: 2.4rem;
|
||||
|
||||
.container,
|
||||
.table-actions {
|
||||
gap: 0.8rem;
|
||||
}
|
||||
|
||||
.checkbox,
|
||||
.more {
|
||||
width: 4.8rem;
|
||||
}
|
||||
|
||||
.checkbox {
|
||||
text-align: center;
|
||||
line-height: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,258 @@
|
||||
<template>
|
||||
<div class="pool-networks-table">
|
||||
<UiTitle>
|
||||
{{ $t('networks') }}
|
||||
<template #actions>
|
||||
<UiDropdownButton v-tooltip="$t('coming-soon')" disabled>
|
||||
{{ $t('new') }}
|
||||
</UiDropdownButton>
|
||||
</template>
|
||||
</UiTitle>
|
||||
<div class="container">
|
||||
<div class="table-actions">
|
||||
<UiQuerySearchBar @search="value => (searchQuery = value)" />
|
||||
<UiTableActions :title="t('table-actions')">
|
||||
<UiButton
|
||||
v-tooltip="$t('coming-soon')"
|
||||
disabled
|
||||
:left-icon="faEdit"
|
||||
variant="tertiary"
|
||||
accent="brand"
|
||||
size="medium"
|
||||
>
|
||||
{{ $t('edit') }}
|
||||
</UiButton>
|
||||
<UiButton
|
||||
v-tooltip="$t('coming-soon')"
|
||||
disabled
|
||||
:left-icon="faCopy"
|
||||
variant="tertiary"
|
||||
accent="brand"
|
||||
size="medium"
|
||||
>
|
||||
{{ $t('copy-info-json') }}
|
||||
</UiButton>
|
||||
<UiButton
|
||||
v-tooltip="$t('coming-soon')"
|
||||
disabled
|
||||
:left-icon="faTrash"
|
||||
variant="tertiary"
|
||||
accent="danger"
|
||||
size="medium"
|
||||
>
|
||||
{{ $t('delete') }}
|
||||
</UiButton>
|
||||
</UiTableActions>
|
||||
<UiTopBottomTable :selected-items="0" :total-items="0" @toggle-select-all="toggleSelect" />
|
||||
</div>
|
||||
<VtsDataTable
|
||||
:is-ready
|
||||
:has-error
|
||||
:no-data-message="networks.length === 0 ? $t('no-network-detected') : undefined"
|
||||
>
|
||||
<template #thead>
|
||||
<tr>
|
||||
<template v-for="column of visibleColumns" :key="column.id">
|
||||
<th v-if="column.id === 'checkbox'" class="checkbox">
|
||||
<div v-tooltip="$t('coming-soon')">
|
||||
<UiCheckbox disabled :v-model="areAllSelected" accent="brand" @update:model-value="toggleSelect" />
|
||||
</div>
|
||||
</th>
|
||||
<th v-else-if="column.id === 'more'" class="more">
|
||||
<UiButtonIcon v-tooltip="$t('coming-soon')" :icon="faEllipsis" accent="brand" disabled size="small" />
|
||||
</th>
|
||||
<th v-else>
|
||||
<div v-tooltip class="text-ellipsis">
|
||||
<VtsIcon accent="brand" :icon="headerIcon[column.id]" />
|
||||
{{ column.label }}
|
||||
</div>
|
||||
</th>
|
||||
</template>
|
||||
</tr>
|
||||
</template>
|
||||
<template #tbody>
|
||||
<tr
|
||||
v-for="row of rows"
|
||||
:key="row.id"
|
||||
:class="{ selected: selectedNetworkId === row.id }"
|
||||
@click="selectedNetworkId = row.id"
|
||||
>
|
||||
<td
|
||||
v-for="column of row.visibleColumns"
|
||||
:key="column.id"
|
||||
class="typo p2-regular"
|
||||
:class="{ checkbox: column.id === 'checkbox' }"
|
||||
>
|
||||
<div v-if="column.id === 'checkbox'" v-tooltip="$t('coming-soon')">
|
||||
<UiCheckbox v-model="selected" disabled accent="brand" :value="row.id" />
|
||||
</div>
|
||||
<UiButtonIcon
|
||||
v-else-if="column.id === 'more'"
|
||||
v-tooltip="$t('coming-soon')"
|
||||
:icon="faEllipsis"
|
||||
accent="brand"
|
||||
disabled
|
||||
size="small"
|
||||
/>
|
||||
<VtsConnectionStatus v-else-if="column.id === 'status'" :status="column.value" />
|
||||
<div v-else v-tooltip="{ placement: 'bottom-end' }" class="text-ellipsis">
|
||||
{{ column.value }}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
</VtsDataTable>
|
||||
<VtsStateHero v-if="searchQuery && filteredNetworks.length === 0" type="table" image="no-result">
|
||||
<div>{{ $t('no-result') }}</div>
|
||||
</VtsStateHero>
|
||||
<UiTopBottomTable :selected-items="0" :total-items="0" @toggle-select-all="toggleSelect" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import useMultiSelect from '@/composables/multi-select.composable'
|
||||
import type { XenApiNetwork } from '@/libs/xen-api/xen-api.types'
|
||||
import { useNetworkStore } from '@/stores/xen-api/network.store'
|
||||
import { usePifMetricsStore } from '@/stores/xen-api/pif-metrics.store'
|
||||
import { usePifStore } from '@/stores/xen-api/pif.store'
|
||||
import VtsConnectionStatus from '@core/components/connection-status/VtsConnectionStatus.vue'
|
||||
import VtsDataTable from '@core/components/data-table/VtsDataTable.vue'
|
||||
import VtsIcon from '@core/components/icon/VtsIcon.vue'
|
||||
import VtsStateHero from '@core/components/state-hero/VtsStateHero.vue'
|
||||
import UiButton from '@core/components/ui/button/UiButton.vue'
|
||||
import UiButtonIcon from '@core/components/ui/button-icon/UiButtonIcon.vue'
|
||||
import UiCheckbox from '@core/components/ui/checkbox/UiCheckbox.vue'
|
||||
import UiDropdownButton from '@core/components/ui/dropdown-button/UiDropdownButton.vue'
|
||||
import UiQuerySearchBar from '@core/components/ui/query-search-bar/UiQuerySearchBar.vue'
|
||||
import UiTableActions from '@core/components/ui/table-actions/UiTableActions.vue'
|
||||
import UiTitle from '@core/components/ui/title/UiTitle.vue'
|
||||
import UiTopBottomTable from '@core/components/ui/top-bottom-table/UiTopBottomTable.vue'
|
||||
import { useRouteQuery } from '@core/composables/route-query.composable'
|
||||
import { useTable } from '@core/composables/table.composable'
|
||||
import { vTooltip } from '@core/directives/tooltip.directive'
|
||||
import type { IconDefinition } from '@fortawesome/fontawesome-common-types'
|
||||
import {
|
||||
faAlignLeft,
|
||||
faCaretDown,
|
||||
faCopy,
|
||||
faEdit,
|
||||
faEllipsis,
|
||||
faHashtag,
|
||||
faPowerOff,
|
||||
faTrash,
|
||||
} from '@fortawesome/free-solid-svg-icons'
|
||||
import { noop } from '@vueuse/shared'
|
||||
import { computed, ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const { networksWithPifs: networks, isReady, hasError } = useNetworkStore().subscribe()
|
||||
const { records: pifs } = usePifStore().subscribe()
|
||||
const { getPifCarrier } = usePifMetricsStore().subscribe()
|
||||
|
||||
const { t } = useI18n()
|
||||
const searchQuery = ref('')
|
||||
const selectedNetworkId = useRouteQuery('id')
|
||||
|
||||
const filteredNetworks = computed(() => {
|
||||
const searchTerm = searchQuery.value.trim().toLocaleLowerCase()
|
||||
if (!searchTerm) {
|
||||
return networks.value
|
||||
}
|
||||
|
||||
return networks.value.filter(network =>
|
||||
Object.values(network).some(value => String(value).toLocaleLowerCase().includes(searchTerm))
|
||||
)
|
||||
})
|
||||
|
||||
const networkUuids = computed(() => networks.value.map(network => network.uuid))
|
||||
|
||||
const { selected, areAllSelected } = useMultiSelect(networkUuids)
|
||||
|
||||
const toggleSelect = () => {
|
||||
selected.value = selected.value.length === 0 ? networkUuids.value : []
|
||||
}
|
||||
|
||||
const getNetworkVlan = (network: XenApiNetwork) => {
|
||||
const networkPIFs = pifs.value.filter(pif => network.PIFs?.includes(pif.$ref))
|
||||
if (networkPIFs.length > 0) {
|
||||
return networkPIFs[0].VLAN !== -1 ? networkPIFs[0].VLAN.toString() : t('none')
|
||||
}
|
||||
}
|
||||
|
||||
const getNetworkStatus = (network: XenApiNetwork) => {
|
||||
const networkPIFs = pifs.value.filter(pif => network.PIFs?.includes(pif.$ref))
|
||||
|
||||
if (networkPIFs.length === 0) {
|
||||
return 'disconnected'
|
||||
}
|
||||
|
||||
const isConnected = networkPIFs.map(pif => pif.currently_attached && getPifCarrier(pif))
|
||||
if (isConnected.every(Boolean)) {
|
||||
return 'connected'
|
||||
}
|
||||
|
||||
if (isConnected.some(Boolean)) {
|
||||
return 'partially-connected'
|
||||
}
|
||||
|
||||
return 'disconnected'
|
||||
}
|
||||
|
||||
const getLockingMode = (lockingMode: string) => (lockingMode === 'disabled' ? t('disabled') : t('unlocked'))
|
||||
|
||||
const { visibleColumns, rows } = useTable('networks', filteredNetworks, {
|
||||
rowId: record => record.uuid,
|
||||
columns: define => [
|
||||
define('checkbox', noop, { label: '', isHideable: false }),
|
||||
define('name_label', { label: t('name') }),
|
||||
define('name_description', { label: t('description') }),
|
||||
define('status', record => getNetworkStatus(record), { label: t('pifs-status') }),
|
||||
define('vlan', record => getNetworkVlan(record), { label: t('vlan') }),
|
||||
define('MTU', { label: t('mtu') }),
|
||||
define('default_locking_mode', record => getLockingMode(record.default_locking_mode), {
|
||||
label: t('default-locking-mode'),
|
||||
}),
|
||||
define('more', noop, { label: '', isHideable: false }),
|
||||
],
|
||||
})
|
||||
|
||||
type NetworkHeader = 'name_label' | 'name_description' | 'status' | 'vlan' | 'MTU' | 'default_locking_mode'
|
||||
|
||||
const headerIcon: Record<NetworkHeader, IconDefinition> = {
|
||||
name_label: faAlignLeft,
|
||||
name_description: faAlignLeft,
|
||||
status: faPowerOff,
|
||||
vlan: faAlignLeft,
|
||||
MTU: faHashtag,
|
||||
default_locking_mode: faCaretDown,
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="postcss">
|
||||
.pool-networks-table,
|
||||
.table-actions,
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.pool-networks-table {
|
||||
gap: 2.4rem;
|
||||
|
||||
.container,
|
||||
.table-actions {
|
||||
gap: 0.8rem;
|
||||
}
|
||||
|
||||
.checkbox,
|
||||
.more {
|
||||
width: 4.8rem;
|
||||
}
|
||||
|
||||
.checkbox {
|
||||
text-align: center;
|
||||
line-height: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -17,21 +17,17 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import UiIcon from '@/components/ui/icon/UiIcon.vue'
|
||||
import { useContext } from '@/composables/context.composable'
|
||||
import { DisabledContext } from '@/context'
|
||||
import { useDisabled } from '@core/composables/disabled.composable'
|
||||
import type { IconDefinition } from '@fortawesome/fontawesome-common-types'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
busy?: boolean
|
||||
disabled?: boolean
|
||||
icon?: IconDefinition
|
||||
active?: boolean
|
||||
}>(),
|
||||
{ disabled: undefined }
|
||||
)
|
||||
const props = defineProps<{
|
||||
busy?: boolean
|
||||
disabled?: boolean
|
||||
icon?: IconDefinition
|
||||
active?: boolean
|
||||
}>()
|
||||
|
||||
const isDisabled = useContext(DisabledContext, () => props.disabled)
|
||||
const isDisabled = useDisabled(() => props.disabled)
|
||||
</script>
|
||||
|
||||
<style lang="postcss" scoped>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<UiButton size="medium" accent="info" variant="primary" :busy="modal.isBusy" type="submit">
|
||||
<UiButton size="medium" accent="brand" variant="primary" :busy="modal.isBusy" type="submit">
|
||||
<slot />
|
||||
</UiButton>
|
||||
</template>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<UiButton size="medium" accent="info" variant="secondary" :busy="modal.isBusy" @click="modal.decline()">
|
||||
<UiButton size="medium" accent="brand" variant="secondary" :busy="modal.isBusy" @click="modal.decline()">
|
||||
<slot>{{ $t('cancel') }}</slot>
|
||||
</UiButton>
|
||||
</template>
|
||||
|
||||
@@ -8,9 +8,10 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { useContext } from '@/composables/context.composable'
|
||||
import { ColorContext, DisabledContext } from '@/context'
|
||||
import { ColorContext } from '@/context'
|
||||
import type { Color } from '@/types'
|
||||
import { IK_MODAL } from '@/types/injection-keys'
|
||||
import { useDisabled } from '@core/composables/disabled.composable'
|
||||
import { useMagicKeys, whenever } from '@vueuse/core'
|
||||
import { inject, useAttrs } from 'vue'
|
||||
|
||||
@@ -28,7 +29,7 @@ const attrs = useAttrs()
|
||||
const modal = inject(IK_MODAL)!
|
||||
|
||||
useContext(ColorContext, () => props.color)
|
||||
useContext(DisabledContext, () => props.disabled || modal.isBusy)
|
||||
useDisabled(() => props.disabled || modal.isBusy)
|
||||
|
||||
const { escape } = useMagicKeys()
|
||||
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
<template>
|
||||
<VtsMenuItem :icon="faCopy" v-bind="menuItem">
|
||||
<MenuItem
|
||||
v-tooltip="!areAllSelectedVmsHalted && $t(isSingleAction ? 'vm-is-running' : 'selected-vms-in-execution')"
|
||||
:busy="areSomeSelectedVmsCloning"
|
||||
:disabled="isDisabled"
|
||||
:icon="faCopy"
|
||||
@click="handleCopy"
|
||||
>
|
||||
{{ $t('copy') }}
|
||||
</VtsMenuItem>
|
||||
</MenuItem>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
@@ -10,42 +16,41 @@ import { VM_OPERATION, VM_POWER_STATE } from '@/libs/xen-api/xen-api.enums'
|
||||
import type { XenApiVm } from '@/libs/xen-api/xen-api.types'
|
||||
import { useVmStore } from '@/stores/xen-api/vm.store'
|
||||
import { useXenApiStore } from '@/stores/xen-api.store'
|
||||
import VtsMenuItem from '@core/components/menu/VtsMenuItem.vue'
|
||||
import { type MenuLike, useMenuAction } from '@core/packages/menu'
|
||||
import MenuItem from '@core/components/menu/MenuItem.vue'
|
||||
import { vTooltip } from '@core/directives/tooltip.directive'
|
||||
import { faCopy } from '@fortawesome/free-solid-svg-icons'
|
||||
import { computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const props = defineProps<{
|
||||
menu: MenuLike
|
||||
selectedRefs: XenApiVm['$ref'][]
|
||||
isSingleAction?: boolean
|
||||
}>()
|
||||
|
||||
const { t } = useI18n()
|
||||
const { getByOpaqueRef } = useVmStore().subscribe()
|
||||
|
||||
const { getByOpaqueRefs } = useVmStore().subscribe()
|
||||
|
||||
const selectedVms = computed(() => getByOpaqueRefs(props.selectedRefs))
|
||||
|
||||
const vmRefsToClone = computed(() =>
|
||||
Object.fromEntries(selectedVms.value.map(vm => [vm.$ref, `${vm.name_label} (COPY)`]))
|
||||
const selectedVms = computed(() =>
|
||||
props.selectedRefs.map(vmRef => getByOpaqueRef(vmRef)).filter((vm): vm is XenApiVm => vm !== undefined)
|
||||
)
|
||||
|
||||
const menuItem = useMenuAction({
|
||||
parent: props.menu,
|
||||
handler: () => useXenApiStore().getXapi().vm.clone(vmRefsToClone.value),
|
||||
disabled: () => {
|
||||
if (props.selectedRefs.length === 0) {
|
||||
return true
|
||||
}
|
||||
const areAllSelectedVmsHalted = computed(
|
||||
() =>
|
||||
selectedVms.value.length > 0 &&
|
||||
selectedVms.value.every(selectedVm => selectedVm.power_state === VM_POWER_STATE.HALTED)
|
||||
)
|
||||
|
||||
if (!selectedVms.value.every(selectedVm => selectedVm.power_state === VM_POWER_STATE.HALTED)) {
|
||||
return props.isSingleAction ? t('vm-is-running') : t('selected-vms-in-execution')
|
||||
}
|
||||
const areSomeSelectedVmsCloning = computed(() =>
|
||||
selectedVms.value.some(vm => isVmOperationPending(vm, VM_OPERATION.CLONE))
|
||||
)
|
||||
|
||||
return false
|
||||
},
|
||||
busy: computed(() => selectedVms.value.some(vm => isVmOperationPending(vm, VM_OPERATION.CLONE))),
|
||||
const isDisabled = computed(() => {
|
||||
return selectedVms.value.length === 0 || !areAllSelectedVmsHalted.value
|
||||
})
|
||||
|
||||
const handleCopy = async () => {
|
||||
const xapiStore = useXenApiStore()
|
||||
|
||||
const vmRefsToClone = Object.fromEntries(selectedVms.value.map(vm => [vm.$ref, `${vm.name_label} (COPY)`]))
|
||||
|
||||
await xapiStore.getXapi().vm.clone(vmRefsToClone)
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
<template>
|
||||
<VtsMenuItem :icon="faTrashCan" v-bind="menuItem">
|
||||
<MenuItem
|
||||
v-tooltip="areSomeVmsInExecution && $t('selected-vms-in-execution')"
|
||||
:disabled="isDisabled"
|
||||
:icon="faTrashCan"
|
||||
@click="openDeleteModal"
|
||||
>
|
||||
{{ $t('delete') }}
|
||||
</VtsMenuItem>
|
||||
</MenuItem>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
@@ -9,39 +14,25 @@ import { useModal } from '@/composables/modal.composable'
|
||||
import { VM_POWER_STATE } from '@/libs/xen-api/xen-api.enums'
|
||||
import type { XenApiVm } from '@/libs/xen-api/xen-api.types'
|
||||
import { useVmStore } from '@/stores/xen-api/vm.store'
|
||||
import VtsMenuItem from '@core/components/menu/VtsMenuItem.vue'
|
||||
import { type MenuLike, useMenuAction } from '@core/packages/menu'
|
||||
import MenuItem from '@core/components/menu/MenuItem.vue'
|
||||
import { vTooltip } from '@core/directives/tooltip.directive'
|
||||
import { faTrashCan } from '@fortawesome/free-solid-svg-icons'
|
||||
import { computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const props = defineProps<{
|
||||
menu: MenuLike
|
||||
vmRefs: XenApiVm['$ref'][]
|
||||
}>()
|
||||
|
||||
const { t } = useI18n()
|
||||
const { getByOpaqueRef: getVm } = useVmStore().subscribe()
|
||||
|
||||
const { getByOpaqueRefs: getVms } = useVmStore().subscribe()
|
||||
const vms = computed<XenApiVm[]>(() => props.vmRefs.map(getVm).filter((vm): vm is XenApiVm => vm !== undefined))
|
||||
|
||||
const vms = computed(() => getVms(props.vmRefs))
|
||||
const areSomeVmsInExecution = computed(() => vms.value.some(vm => vm.power_state !== VM_POWER_STATE.HALTED))
|
||||
|
||||
const menuItem = useMenuAction({
|
||||
parent: props.menu,
|
||||
handler: () =>
|
||||
useModal(() => import('@/components/modals/VmDeleteModal.vue'), {
|
||||
vmRefs: props.vmRefs,
|
||||
}),
|
||||
disabled: computed(() => {
|
||||
if (vms.value.length === 0) {
|
||||
return true
|
||||
}
|
||||
const isDisabled = computed(() => vms.value.length === 0 || areSomeVmsInExecution.value)
|
||||
|
||||
if (vms.value.some(vm => vm.power_state !== VM_POWER_STATE.HALTED)) {
|
||||
return t('selected-vms-in-execution')
|
||||
}
|
||||
|
||||
return false
|
||||
}),
|
||||
})
|
||||
const openDeleteModal = () =>
|
||||
useModal(() => import('@/components/modals/VmDeleteModal.vue'), {
|
||||
vmRefs: props.vmRefs,
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
<template>
|
||||
<VtsMenuItem :icon="faDisplay" v-bind="menuItem">
|
||||
<MenuItem
|
||||
v-tooltip="
|
||||
vmRefs.length > 0 && !isSomeExportable && $t(isSingleAction ? 'vm-is-running' : 'no-selected-vm-can-be-exported')
|
||||
"
|
||||
:disabled="isDisabled"
|
||||
:icon="faDisplay"
|
||||
@click="openModal"
|
||||
>
|
||||
{{ $t(isSingleAction ? 'export-vm' : 'export-vms') }}
|
||||
</VtsMenuItem>
|
||||
</MenuItem>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
@@ -10,40 +17,28 @@ import { areSomeVmOperationAllowed } from '@/libs/vm'
|
||||
import { VM_OPERATION } from '@/libs/xen-api/xen-api.enums'
|
||||
import type { XenApiVm } from '@/libs/xen-api/xen-api.types'
|
||||
import { useVmStore } from '@/stores/xen-api/vm.store'
|
||||
import VtsMenuItem from '@core/components/menu/VtsMenuItem.vue'
|
||||
import { type MenuLike, useMenuAction } from '@core/packages/menu'
|
||||
import MenuItem from '@core/components/menu/MenuItem.vue'
|
||||
import { useDisabled } from '@core/composables/disabled.composable'
|
||||
import { vTooltip } from '@core/directives/tooltip.directive'
|
||||
import { faDisplay } from '@fortawesome/free-solid-svg-icons'
|
||||
import { computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const props = defineProps<{
|
||||
menu: MenuLike
|
||||
vmRefs: XenApiVm['$ref'][]
|
||||
isSingleAction?: boolean
|
||||
}>()
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const { getByOpaqueRefs } = useVmStore().subscribe()
|
||||
|
||||
const vms = computed(() => getByOpaqueRefs(props.vmRefs))
|
||||
const isSomeExportable = computed(() =>
|
||||
getByOpaqueRefs(props.vmRefs).some(vm => areSomeVmOperationAllowed(vm, VM_OPERATION.EXPORT))
|
||||
)
|
||||
|
||||
const menuItem = useMenuAction({
|
||||
parent: props.menu,
|
||||
handler: () =>
|
||||
useModal(() => import('@/components/modals/VmExportModal.vue'), {
|
||||
vmRefs: props.vmRefs,
|
||||
}),
|
||||
disabled: () => {
|
||||
if (props.vmRefs.length === 0) {
|
||||
return true
|
||||
}
|
||||
const isDisabled = useDisabled(() => !isSomeExportable.value)
|
||||
|
||||
if (!vms.value.some(vm => areSomeVmOperationAllowed(vm, VM_OPERATION.EXPORT))) {
|
||||
return props.isSingleAction ? t('vm-is-running') : t('no-selected-vm-can-be-exported')
|
||||
}
|
||||
|
||||
return false
|
||||
},
|
||||
})
|
||||
const openModal = () => {
|
||||
useModal(() => import('@/components/modals/VmExportModal.vue'), {
|
||||
vmRefs: props.vmRefs,
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
<template>
|
||||
<li>
|
||||
<VtsMenuTrigger :icon="faFileExport" v-bind="toggle.$trigger">
|
||||
{{ $t('export') }}
|
||||
</VtsMenuTrigger>
|
||||
|
||||
<VtsMenuList v-bind="toggle.$target">
|
||||
<VmActionExportItem :menu="toggle" :vm-refs="vmRefs" />
|
||||
<VtsMenuItem :icon="faCode" v-bind="toggle.exportAsJson">
|
||||
<MenuItem :icon="faFileExport">
|
||||
{{ $t('export') }}
|
||||
<template #submenu>
|
||||
<VmActionExportItem :vm-refs="vmRefs" />
|
||||
<MenuItem :icon="faCode" @click="exportVmsAsJsonFile(vms, `vms_${new Date().toISOString()}.json`)">
|
||||
{{ $t('export-table-to', { type: '.json' }) }}
|
||||
</VtsMenuItem>
|
||||
<VtsMenuItem :icon="faFileCsv" v-bind="toggle.exportAsCsv">
|
||||
</MenuItem>
|
||||
<MenuItem :icon="faFileCsv" @click="exportVmsAsCsvFile(vms, `vms_${new Date().toISOString()}.csv`)">
|
||||
{{ $t('export-table-to', { type: '.csv' }) }}
|
||||
</VtsMenuItem>
|
||||
</VtsMenuList>
|
||||
</li>
|
||||
</MenuItem>
|
||||
</template>
|
||||
</MenuItem>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
@@ -21,31 +18,14 @@ import VmActionExportItem from '@/components/vm/VmActionItems/VmActionExportItem
|
||||
import { exportVmsAsCsvFile, exportVmsAsJsonFile } from '@/libs/vm'
|
||||
import type { XenApiVm } from '@/libs/xen-api/xen-api.types'
|
||||
import { useVmStore } from '@/stores/xen-api/vm.store'
|
||||
import VtsMenuItem from '@core/components/menu/VtsMenuItem.vue'
|
||||
import VtsMenuList from '@core/components/menu/VtsMenuList.vue'
|
||||
import VtsMenuTrigger from '@core/components/menu/VtsMenuTrigger.vue'
|
||||
import { action, type MenuLike, useMenuToggle } from '@core/packages/menu'
|
||||
import MenuItem from '@core/components/menu/MenuItem.vue'
|
||||
import { faCode, faFileCsv, faFileExport } from '@fortawesome/free-solid-svg-icons'
|
||||
import { computed } from 'vue'
|
||||
|
||||
const props = defineProps<{
|
||||
menu: MenuLike
|
||||
vmRefs: XenApiVm['$ref'][]
|
||||
}>()
|
||||
|
||||
const { getByOpaqueRefs } = useVmStore().subscribe()
|
||||
|
||||
const vms = computed(() => getByOpaqueRefs(props.vmRefs))
|
||||
|
||||
const toggle = useMenuToggle({
|
||||
parent: props.menu,
|
||||
items: {
|
||||
exportAsJson: action(() => exportVmsAsJsonFile(vms.value, `vms_${new Date().toISOString()}.json`), {
|
||||
disabled: computed(() => vms.value.length === 0),
|
||||
}),
|
||||
exportAsCsv: action(() => exportVmsAsCsvFile(vms.value, `vms_${new Date().toISOString()}.csv`), {
|
||||
disabled: computed(() => vms.value.length === 0),
|
||||
}),
|
||||
},
|
||||
})
|
||||
const { getByOpaqueRef: getVm } = useVmStore().subscribe()
|
||||
const vms = computed(() => props.vmRefs.map(getVm).filter((vm): vm is XenApiVm => vm !== undefined))
|
||||
</script>
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
<template>
|
||||
<VtsMenuItem :icon="faRoute" v-bind="menuItem">
|
||||
<MenuItem
|
||||
v-tooltip="
|
||||
selectedRefs.length > 0 &&
|
||||
!isMigratable &&
|
||||
$t(isSingleAction ? 'this-vm-cant-be-migrated' : 'no-selected-vm-can-be-migrated')
|
||||
"
|
||||
:busy="isMigrating"
|
||||
:disabled="isDisabled"
|
||||
:icon="faRoute"
|
||||
@click="openModal()"
|
||||
>
|
||||
{{ $t('migrate') }}
|
||||
</VtsMenuItem>
|
||||
</MenuItem>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
@@ -10,41 +20,35 @@ import { areSomeVmOperationAllowed, isVmOperationPending } from '@/libs/vm'
|
||||
import { VM_OPERATION } from '@/libs/xen-api/xen-api.enums'
|
||||
import type { XenApiVm } from '@/libs/xen-api/xen-api.types'
|
||||
import { useVmStore } from '@/stores/xen-api/vm.store'
|
||||
import VtsMenuItem from '@core/components/menu/VtsMenuItem.vue'
|
||||
import { type MenuLike, useMenuAction } from '@core/packages/menu'
|
||||
import MenuItem from '@core/components/menu/MenuItem.vue'
|
||||
import { useDisabled } from '@core/composables/disabled.composable'
|
||||
import { vTooltip } from '@core/directives/tooltip.directive'
|
||||
import { faRoute } from '@fortawesome/free-solid-svg-icons'
|
||||
import { computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const props = defineProps<{
|
||||
menu: MenuLike
|
||||
selectedRefs: XenApiVm['$ref'][]
|
||||
isSingleAction?: boolean
|
||||
}>()
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const { getByOpaqueRefs } = useVmStore().subscribe()
|
||||
|
||||
const vms = computed(() => getByOpaqueRefs(props.selectedRefs))
|
||||
const isMigratable = computed(() =>
|
||||
getByOpaqueRefs(props.selectedRefs).some(vm =>
|
||||
areSomeVmOperationAllowed(vm, [VM_OPERATION.POOL_MIGRATE, VM_OPERATION.MIGRATE_SEND])
|
||||
)
|
||||
)
|
||||
|
||||
const menuItem = useMenuAction({
|
||||
parent: props.menu,
|
||||
handler: () =>
|
||||
useModal(() => import('@/components/modals/VmMigrateModal.vue'), {
|
||||
vmRefs: props.selectedRefs,
|
||||
}),
|
||||
disabled: () => {
|
||||
if (props.selectedRefs.length === 0) {
|
||||
return true
|
||||
}
|
||||
const isMigrating = computed(() =>
|
||||
getByOpaqueRefs(props.selectedRefs).some(vm =>
|
||||
isVmOperationPending(vm, [VM_OPERATION.POOL_MIGRATE, VM_OPERATION.MIGRATE_SEND])
|
||||
)
|
||||
)
|
||||
|
||||
if (!vms.value.some(vm => areSomeVmOperationAllowed(vm, [VM_OPERATION.POOL_MIGRATE, VM_OPERATION.MIGRATE_SEND]))) {
|
||||
return props.isSingleAction ? t('this-vm-cant-be-migrated') : t('no-selected-vm-can-be-migrated')
|
||||
}
|
||||
},
|
||||
busy: computed(() =>
|
||||
vms.value.some(vm => isVmOperationPending(vm, [VM_OPERATION.POOL_MIGRATE, VM_OPERATION.MIGRATE_SEND]))
|
||||
),
|
||||
})
|
||||
const isDisabled = useDisabled(() => !isMigratable.value)
|
||||
|
||||
const openModal = () =>
|
||||
useModal(() => import('@/components/modals/VmMigrateModal.vue'), {
|
||||
vmRefs: props.selectedRefs,
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
<template>
|
||||
<VtsMenuItem :icon="faPlay" v-bind="startItem">
|
||||
<MenuItem :busy="areVmsBusyToStart" :disabled="!areVmsHalted" :icon="faPlay" @click="xenApi.vm.start(vmRefs)">
|
||||
{{ $t('start') }}
|
||||
</VtsMenuItem>
|
||||
<li>
|
||||
<VtsMenuTrigger :icon="faServer" v-bind="startOnHostItem.$trigger">
|
||||
{{ $t('start-on-host') }}
|
||||
</VtsMenuTrigger>
|
||||
<VtsMenuList border v-bind="startOnHostItem.$target">
|
||||
<VtsMenuItem v-for="host in hosts" :key="host.$ref" :icon="faServer" v-bind="startOnHostItem[host.$ref]">
|
||||
</MenuItem>
|
||||
<MenuItem :busy="areVmsBusyToStartOnHost" :disabled="!areVmsHalted" :icon="faServer">
|
||||
{{ $t('start-on-host') }}
|
||||
<template #submenu>
|
||||
<MenuItem v-for="host in hosts" :key="host.$ref" :icon="faServer" @click="xenApi.vm.startOn(vmRefs, host.$ref)">
|
||||
<div class="wrapper">
|
||||
{{ host.name_label }}
|
||||
<div>
|
||||
@@ -15,30 +13,55 @@
|
||||
<PowerStateIcon :state="getHostState(host)" />
|
||||
</div>
|
||||
</div>
|
||||
</VtsMenuItem>
|
||||
</VtsMenuList>
|
||||
</li>
|
||||
<VtsMenuItem :icon="faPause" v-bind="pauseItem">
|
||||
</MenuItem>
|
||||
</template>
|
||||
</MenuItem>
|
||||
<MenuItem :busy="areVmsBusyToPause" :disabled="!areVmsRunning" :icon="faPause" @click="xenApi.vm.pause(vmRefs)">
|
||||
{{ $t('pause') }}
|
||||
</VtsMenuItem>
|
||||
<VtsMenuItem :icon="faMoon" v-bind="suspendItem">
|
||||
</MenuItem>
|
||||
<MenuItem :busy="areVmsBusyToSuspend" :disabled="!areVmsRunning" :icon="faMoon" @click="xenApi.vm.suspend(vmRefs)">
|
||||
{{ $t('suspend') }}
|
||||
</VtsMenuItem>
|
||||
<VtsMenuItem :icon="faCirclePlay" v-bind="resumeItem">
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
:busy="areVmsBusyToResume"
|
||||
:disabled="!areVmsSuspended && !areVmsPaused"
|
||||
:icon="faCirclePlay"
|
||||
@click="xenApi.vm.resume(vmRefsWithPowerState)"
|
||||
>
|
||||
{{ $t('resume') }}
|
||||
</VtsMenuItem>
|
||||
<VtsMenuItem :icon="faRotateLeft" v-bind="rebootItem">
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
:busy="areVmsBusyToReboot"
|
||||
:disabled="!areVmsRunning"
|
||||
:icon="faRotateLeft"
|
||||
@click="xenApi.vm.reboot(vmRefs)"
|
||||
>
|
||||
{{ $t('reboot') }}
|
||||
</VtsMenuItem>
|
||||
<VtsMenuItem :icon="faRepeat" v-bind="forceRebootItem">
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
:busy="areVmsBusyToForceReboot"
|
||||
:disabled="!areVmsRunning && !areVmsPaused"
|
||||
:icon="faRepeat"
|
||||
@click="xenApi.vm.reboot(vmRefs, true)"
|
||||
>
|
||||
{{ $t('force-reboot') }}
|
||||
</VtsMenuItem>
|
||||
<VtsMenuItem :icon="faPowerOff" v-bind="shutdownItem">
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
:busy="areVmsBusyToShutdown"
|
||||
:disabled="!areVmsRunning"
|
||||
:icon="faPowerOff"
|
||||
@click="xenApi.vm.shutdown(vmRefs)"
|
||||
>
|
||||
{{ $t('shutdown') }}
|
||||
</VtsMenuItem>
|
||||
<VtsMenuItem :icon="faPlug" v-bind="forceShutdownItem">
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
:busy="areVmsBusyToForceShutdown"
|
||||
:disabled="!areVmsRunning && !areVmsSuspended && !areVmsPaused"
|
||||
:icon="faPlug"
|
||||
@click="xenApi.vm.shutdown(vmRefs, true)"
|
||||
>
|
||||
{{ $t('force-shutdown') }}
|
||||
</VtsMenuItem>
|
||||
</MenuItem>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
@@ -52,10 +75,7 @@ import { useHostStore } from '@/stores/xen-api/host.store'
|
||||
import { usePoolStore } from '@/stores/xen-api/pool.store'
|
||||
import { useVmStore } from '@/stores/xen-api/vm.store'
|
||||
import { useXenApiStore } from '@/stores/xen-api.store'
|
||||
import VtsMenuItem from '@core/components/menu/VtsMenuItem.vue'
|
||||
import VtsMenuList from '@core/components/menu/VtsMenuList.vue'
|
||||
import VtsMenuTrigger from '@core/components/menu/VtsMenuTrigger.vue'
|
||||
import { action, type MenuLike, useMenuAction, useMenuToggle } from '@core/packages/menu'
|
||||
import MenuItem from '@core/components/menu/MenuItem.vue'
|
||||
import {
|
||||
faCirclePlay,
|
||||
faMoon,
|
||||
@@ -71,26 +91,17 @@ import {
|
||||
import { computed } from 'vue'
|
||||
|
||||
const props = defineProps<{
|
||||
menu: MenuLike
|
||||
vmRefs: XenApiVm['$ref'][]
|
||||
}>()
|
||||
|
||||
const { getByOpaqueRefs } = useVmStore().subscribe()
|
||||
const { getByOpaqueRef: getVm } = useVmStore().subscribe()
|
||||
const { records: hosts } = useHostStore().subscribe()
|
||||
const { pool } = usePoolStore().subscribe()
|
||||
const { isHostRunning } = useHostMetricsStore().subscribe()
|
||||
|
||||
const vms = computed(() => getByOpaqueRefs(props.vmRefs))
|
||||
const vms = computed(() => props.vmRefs.map(getVm).filter((vm): vm is XenApiVm => vm !== undefined))
|
||||
|
||||
const vmRefsWithPowerState = computed(() =>
|
||||
vms.value.reduce(
|
||||
(acc, vm) => ({
|
||||
...acc,
|
||||
[vm.$ref]: vm.power_state,
|
||||
}),
|
||||
{}
|
||||
)
|
||||
)
|
||||
const vmRefsWithPowerState = computed(() => vms.value.reduce((acc, vm) => ({ ...acc, [vm.$ref]: vm.power_state }), {}))
|
||||
|
||||
const xenApi = useXenApiStore().getXapi()
|
||||
|
||||
@@ -112,78 +123,6 @@ const areVmsBusyToForceReboot = computed(() => areOperationsPending(VM_OPERATION
|
||||
const areVmsBusyToShutdown = computed(() => areOperationsPending(VM_OPERATION.CLEAN_SHUTDOWN))
|
||||
const areVmsBusyToForceShutdown = computed(() => areOperationsPending(VM_OPERATION.HARD_SHUTDOWN))
|
||||
const getHostState = (host: XenApiHost) => (isHostRunning(host) ? VM_POWER_STATE.RUNNING : VM_POWER_STATE.HALTED)
|
||||
|
||||
const hasVm = computed(() => vms.value.length > 0)
|
||||
|
||||
const startItem = useMenuAction({
|
||||
parent: props.menu,
|
||||
busy: areVmsBusyToStart,
|
||||
disabled: computed(() => !hasVm.value || !areVmsHalted.value),
|
||||
handler: () => xenApi.vm.start(props.vmRefs),
|
||||
})
|
||||
|
||||
const startOnHostItem = useMenuToggle({
|
||||
parent: props.menu,
|
||||
placement: 'right-start',
|
||||
items: Object.fromEntries(
|
||||
hosts.value.map(host => [
|
||||
host.$ref,
|
||||
action(() => xenApi.vm.startOn(props.vmRefs, host.$ref), {
|
||||
busy: areVmsBusyToStartOnHost,
|
||||
disabled: computed(() => !hasVm.value || !areVmsHalted.value),
|
||||
}),
|
||||
])
|
||||
),
|
||||
})
|
||||
|
||||
const pauseItem = useMenuAction({
|
||||
parent: props.menu,
|
||||
busy: areVmsBusyToPause,
|
||||
disabled: computed(() => !hasVm.value || !areVmsRunning.value),
|
||||
handler: () => xenApi.vm.pause(props.vmRefs),
|
||||
})
|
||||
|
||||
const suspendItem = useMenuAction({
|
||||
parent: props.menu,
|
||||
busy: areVmsBusyToSuspend,
|
||||
disabled: computed(() => !hasVm.value || !areVmsRunning.value),
|
||||
handler: () => xenApi.vm.suspend(props.vmRefs),
|
||||
})
|
||||
|
||||
const resumeItem = useMenuAction({
|
||||
parent: props.menu,
|
||||
busy: areVmsBusyToResume,
|
||||
disabled: computed(() => !hasVm.value || (!areVmsSuspended.value && !areVmsPaused.value)),
|
||||
handler: () => xenApi.vm.resume(vmRefsWithPowerState.value),
|
||||
})
|
||||
|
||||
const rebootItem = useMenuAction({
|
||||
parent: props.menu,
|
||||
busy: areVmsBusyToReboot,
|
||||
disabled: computed(() => !hasVm.value || !areVmsRunning.value),
|
||||
handler: () => xenApi.vm.reboot(props.vmRefs),
|
||||
})
|
||||
|
||||
const forceRebootItem = useMenuAction({
|
||||
parent: props.menu,
|
||||
busy: areVmsBusyToForceReboot,
|
||||
disabled: computed(() => !hasVm.value || (!areVmsRunning.value && !areVmsPaused.value)),
|
||||
handler: () => xenApi.vm.reboot(props.vmRefs, true),
|
||||
})
|
||||
|
||||
const shutdownItem = useMenuAction({
|
||||
parent: props.menu,
|
||||
busy: areVmsBusyToShutdown,
|
||||
disabled: computed(() => !hasVm.value || !areVmsRunning.value),
|
||||
handler: () => xenApi.vm.shutdown(props.vmRefs),
|
||||
})
|
||||
|
||||
const forceShutdownItem = useMenuAction({
|
||||
parent: props.menu,
|
||||
busy: areVmsBusyToForceShutdown,
|
||||
disabled: computed(() => !hasVm.value || (!areVmsRunning.value && !areVmsSuspended.value && !areVmsPaused.value)),
|
||||
handler: () => xenApi.vm.shutdown(props.vmRefs, true),
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="postcss" scoped>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<VtsMenuItem :icon="faCamera" v-bind="menuItem">
|
||||
<MenuItem :busy="areSomeVmsSnapshoting" :disabled="isDisabled" :icon="faCamera" @click="handleSnapshot">
|
||||
{{ $t('snapshot') }}
|
||||
</VtsMenuItem>
|
||||
</MenuItem>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
@@ -10,28 +10,28 @@ import { VM_OPERATION } from '@/libs/xen-api/xen-api.enums'
|
||||
import type { XenApiVm } from '@/libs/xen-api/xen-api.types'
|
||||
import { useVmStore } from '@/stores/xen-api/vm.store'
|
||||
import { useXenApiStore } from '@/stores/xen-api.store'
|
||||
import VtsMenuItem from '@core/components/menu/VtsMenuItem.vue'
|
||||
import { type MenuLike, useMenuAction } from '@core/packages/menu'
|
||||
import MenuItem from '@core/components/menu/MenuItem.vue'
|
||||
import { faCamera } from '@fortawesome/free-solid-svg-icons'
|
||||
import { computed } from 'vue'
|
||||
|
||||
const props = defineProps<{
|
||||
menu: MenuLike
|
||||
vmRefs: XenApiVm['$ref'][]
|
||||
}>()
|
||||
|
||||
const { getByOpaqueRefs } = useVmStore().subscribe()
|
||||
const { getByOpaqueRef } = useVmStore().subscribe()
|
||||
|
||||
const vms = computed(() => getByOpaqueRefs(props.vmRefs))
|
||||
|
||||
const vmRefsToSnapshot = computed(() =>
|
||||
Object.fromEntries(vms.value.map(vm => [vm.$ref, `${vm.name_label}_${new Date().toISOString()}`]))
|
||||
const vms = computed(() =>
|
||||
props.vmRefs.map(vmRef => getByOpaqueRef(vmRef)).filter((vm): vm is XenApiVm => vm !== undefined)
|
||||
)
|
||||
|
||||
const menuItem = useMenuAction({
|
||||
parent: props.menu,
|
||||
handler: () => useXenApiStore().getXapi().vm.snapshot(vmRefsToSnapshot.value),
|
||||
busy: computed(() => vms.value.some(vm => isVmOperationPending(vm, VM_OPERATION.SNAPSHOT))),
|
||||
disabled: computed(() => vms.value.length === 0),
|
||||
})
|
||||
const areSomeVmsSnapshoting = computed(() => vms.value.some(vm => isVmOperationPending(vm, VM_OPERATION.SNAPSHOT)))
|
||||
|
||||
const isDisabled = computed(() => vms.value.length === 0 || areSomeVmsSnapshoting.value)
|
||||
|
||||
const handleSnapshot = () => {
|
||||
const vmRefsToSnapshot = Object.fromEntries(
|
||||
vms.value.map(vm => [vm.$ref, `${vm.name_label}_${new Date().toISOString()}`])
|
||||
)
|
||||
return useXenApiStore().getXapi().vm.snapshot(vmRefsToSnapshot)
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,39 +1,50 @@
|
||||
<template>
|
||||
<TitleBar :icon="faDisplay">
|
||||
{{ name }}
|
||||
<template v-if="vm !== undefined" #actions>
|
||||
<UiDropdownButton :icon="faPowerOff" v-bind="omit(powerMenu.$trigger, ['as', 'submenu'])">
|
||||
{{ $t('change-state') }}
|
||||
</UiDropdownButton>
|
||||
|
||||
<VtsMenuList border v-bind="powerMenu.$target">
|
||||
<VmActionPowerStateItems :menu="powerMenu" :vm-refs="[vm.$ref]" />
|
||||
</VtsMenuList>
|
||||
|
||||
<UiButtonIcon
|
||||
v-tooltip="{
|
||||
placement: 'left',
|
||||
content: $t('more-actions'),
|
||||
}"
|
||||
:icon="faEllipsisVertical"
|
||||
accent="info"
|
||||
class="more-actions-button"
|
||||
size="large"
|
||||
v-bind="omit(moreMenu.$trigger, ['as', 'submenu'])"
|
||||
/>
|
||||
|
||||
<VtsMenuList border v-bind="moreMenu.$target">
|
||||
<VmActionCopyItem :menu="moreMenu" :selected-refs="[vm.$ref]" is-single-action />
|
||||
<VmActionExportItem :menu="moreMenu" :vm-refs="[vm.$ref]" is-single-action />
|
||||
<VmActionSnapshotItem :menu="moreMenu" :vm-refs="[vm.$ref]" />
|
||||
<VmActionMigrateItem :menu="moreMenu" :selected-refs="[vm.$ref]" is-single-action />
|
||||
</VtsMenuList>
|
||||
<template #actions>
|
||||
<MenuList v-if="vm !== undefined" placement="bottom-end">
|
||||
<template #trigger="{ open, isOpen }">
|
||||
<UiButton
|
||||
size="medium"
|
||||
accent="brand"
|
||||
variant="primary"
|
||||
:class="{ pressed: isOpen }"
|
||||
:left-icon="faPowerOff"
|
||||
@click="open"
|
||||
>
|
||||
{{ $t('change-state') }}
|
||||
<UiIcon :icon="faAngleDown" />
|
||||
</UiButton>
|
||||
</template>
|
||||
<VmActionPowerStateItems :vm-refs="[vm.$ref]" />
|
||||
</MenuList>
|
||||
<MenuList v-if="vm !== undefined" placement="bottom-end">
|
||||
<template #trigger="{ open, isOpen }">
|
||||
<UiButtonIcon
|
||||
v-tooltip="{
|
||||
placement: 'left',
|
||||
content: $t('more-actions'),
|
||||
}"
|
||||
:selected="isOpen"
|
||||
:icon="faEllipsisVertical"
|
||||
accent="brand"
|
||||
class="more-actions-button"
|
||||
size="large"
|
||||
@click="open"
|
||||
/>
|
||||
</template>
|
||||
<VmActionCopyItem :selected-refs="[vm.$ref]" is-single-action />
|
||||
<VmActionExportItem :vm-refs="[vm.$ref]" is-single-action />
|
||||
<VmActionSnapshotItem :vm-refs="[vm.$ref]" />
|
||||
<VmActionMigrateItem :selected-refs="[vm.$ref]" is-single-action />
|
||||
</MenuList>
|
||||
</template>
|
||||
</TitleBar>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import TitleBar from '@/components/TitleBar.vue'
|
||||
import UiIcon from '@/components/ui/icon/UiIcon.vue'
|
||||
import VmActionCopyItem from '@/components/vm/VmActionItems/VmActionCopyItem.vue'
|
||||
import VmActionExportItem from '@/components/vm/VmActionItems/VmActionExportItem.vue'
|
||||
import VmActionMigrateItem from '@/components/vm/VmActionItems/VmActionMigrateItem.vue'
|
||||
@@ -41,13 +52,11 @@ import VmActionPowerStateItems from '@/components/vm/VmActionItems/VmActionPower
|
||||
import VmActionSnapshotItem from '@/components/vm/VmActionItems/VmActionSnapshotItem.vue'
|
||||
import type { XenApiVm } from '@/libs/xen-api/xen-api.types'
|
||||
import { useVmStore } from '@/stores/xen-api/vm.store'
|
||||
import VtsMenuList from '@core/components/menu/VtsMenuList.vue'
|
||||
import MenuList from '@core/components/menu/MenuList.vue'
|
||||
import UiButton from '@core/components/ui/button/UiButton.vue'
|
||||
import UiButtonIcon from '@core/components/ui/button-icon/UiButtonIcon.vue'
|
||||
import UiDropdownButton from '@core/components/ui/dropdown-button/UiDropdownButton.vue'
|
||||
import { vTooltip } from '@core/directives/tooltip.directive'
|
||||
import { useMenuToggle } from '@core/packages/menu'
|
||||
import { faDisplay, faEllipsisVertical, faPowerOff } from '@fortawesome/free-solid-svg-icons'
|
||||
import { objectOmit as omit } from '@vueuse/shared'
|
||||
import { faAngleDown, faDisplay, faEllipsisVertical, faPowerOff } from '@fortawesome/free-solid-svg-icons'
|
||||
import { computed } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
@@ -57,8 +66,4 @@ const { currentRoute } = useRouter()
|
||||
const vm = computed(() => getVmByUuid(currentRoute.value.params.uuid as XenApiVm['uuid']))
|
||||
|
||||
const name = computed(() => vm.value?.name_label)
|
||||
|
||||
const powerMenu = useMenuToggle({ placement: 'bottom-end' })
|
||||
|
||||
const moreMenu = useMenuToggle({ placement: 'bottom-end' })
|
||||
</script>
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
<template>
|
||||
<UiButtonIcon v-if="isMobile" :icon="faEllipsis" accent="info" size="medium" v-bind="menu.$trigger" />
|
||||
|
||||
<VtsMenuList
|
||||
:border="isMobile"
|
||||
<MenuList
|
||||
:disabled="selectedRefs.length === 0"
|
||||
:horizontal="!isMobile"
|
||||
:no-border="!isMobile"
|
||||
class="vms-actions-bar"
|
||||
v-bind="isMobile ? menu.$target : undefined"
|
||||
placement="bottom-end"
|
||||
>
|
||||
<VtsMenuItem :icon="faPowerOff" v-bind="menu.powerState.$trigger">
|
||||
<template v-if="isMobile" #trigger="{ isOpen, open }">
|
||||
<UiButtonIcon accent="brand" size="medium" :selected="isOpen" :icon="faEllipsis" @click="open" />
|
||||
</template>
|
||||
<MenuItem :icon="faPowerOff">
|
||||
{{ $t('change-state') }}
|
||||
</VtsMenuItem>
|
||||
<Teleport to="body">
|
||||
<VtsMenuList border v-bind="menu.powerState.$target">
|
||||
<VmActionPowerStateItems :menu="menu.powerState" :vm-refs="selectedRefs" />
|
||||
</VtsMenuList>
|
||||
</Teleport>
|
||||
<VmActionMigrateItem :menu :selected-refs="selectedRefs" />
|
||||
<VmActionCopyItem :menu :selected-refs="selectedRefs" />
|
||||
<VtsMenuItem :icon="faEdit" v-bind="menu.editConfig">
|
||||
<template #submenu>
|
||||
<VmActionPowerStateItems :vm-refs="selectedRefs" />
|
||||
</template>
|
||||
</MenuItem>
|
||||
<VmActionMigrateItem :selected-refs="selectedRefs" />
|
||||
<VmActionCopyItem :selected-refs="selectedRefs" />
|
||||
<MenuItem v-tooltip="$t('coming-soon')" :icon="faEdit">
|
||||
{{ $t('edit-config') }}
|
||||
</VtsMenuItem>
|
||||
<VmActionSnapshotItem :menu :vm-refs="selectedRefs" />
|
||||
<VmActionExportItems :menu :vm-refs="selectedRefs" />
|
||||
<VmActionDeleteItem :menu :vm-refs="selectedRefs" />
|
||||
</VtsMenuList>
|
||||
</MenuItem>
|
||||
<VmActionSnapshotItem :vm-refs="selectedRefs" />
|
||||
<VmActionExportItems :vm-refs="selectedRefs" />
|
||||
<VmActionDeleteItem :vm-refs="selectedRefs" />
|
||||
</MenuList>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
@@ -34,32 +34,20 @@ import VmActionMigrateItem from '@/components/vm/VmActionItems/VmActionMigrateIt
|
||||
import VmActionPowerStateItems from '@/components/vm/VmActionItems/VmActionPowerStateItems.vue'
|
||||
import VmActionSnapshotItem from '@/components/vm/VmActionItems/VmActionSnapshotItem.vue'
|
||||
import type { XenApiVm } from '@/libs/xen-api/xen-api.types'
|
||||
import VtsMenuItem from '@core/components/menu/VtsMenuItem.vue'
|
||||
import VtsMenuList from '@core/components/menu/VtsMenuList.vue'
|
||||
import MenuItem from '@core/components/menu/MenuItem.vue'
|
||||
import MenuList from '@core/components/menu/MenuList.vue'
|
||||
import UiButtonIcon from '@core/components/ui/button-icon/UiButtonIcon.vue'
|
||||
import { action, toggle, useMenuToggle } from '@core/packages/menu'
|
||||
import { vTooltip } from '@core/directives/tooltip.directive'
|
||||
import { useUiStore } from '@core/stores/ui.store'
|
||||
import { faEdit, faEllipsis, faPowerOff } from '@fortawesome/free-solid-svg-icons'
|
||||
import { noop } from '@vueuse/shared'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
defineProps<{
|
||||
disabled?: boolean
|
||||
selectedRefs: XenApiVm['$ref'][]
|
||||
}>()
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const { isMobile } = storeToRefs(useUiStore())
|
||||
|
||||
const menu = useMenuToggle({
|
||||
placement: 'bottom-end',
|
||||
items: {
|
||||
powerState: toggle({}),
|
||||
editConfig: action(noop, { disabled: t('coming-soon') }),
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="postcss" scoped>
|
||||
|
||||
@@ -2,8 +2,6 @@ import { createContext } from '@/composables/context.composable'
|
||||
import type { Color } from '@/types'
|
||||
import { computed } from 'vue'
|
||||
|
||||
export const DisabledContext = createContext(false)
|
||||
|
||||
export const ColorContext = createContext('info' as Color, color => ({
|
||||
name: color,
|
||||
textClass: computed(() => `context-color-${color.value}`),
|
||||
|
||||
@@ -58,6 +58,8 @@ type ObjectTypeToRecordMapping = {
|
||||
host_metrics: XenApiHostMetrics
|
||||
message: XenApiMessage<any>
|
||||
network: XenApiNetwork
|
||||
pif: XenApiPif
|
||||
pif_metrics: XenApiPifMetrics
|
||||
pool: XenApiPool
|
||||
sr: XenApiSr
|
||||
vm: XenApiVm
|
||||
|
||||
@@ -59,7 +59,6 @@
|
||||
|
||||
"descending": "sestupně",
|
||||
"description": "Popis",
|
||||
"dhcp": "DHCP",
|
||||
"disabled": "Zakázáno",
|
||||
"display": "Zobrazení",
|
||||
"dns": "DNS",
|
||||
|
||||
@@ -57,7 +57,6 @@
|
||||
|
||||
"descending": "absteigend",
|
||||
"description": "Beschreibung",
|
||||
"dhcp": "DHCP",
|
||||
"disabled": "deaktiviert",
|
||||
"display": "Display",
|
||||
"dns": "DNS",
|
||||
@@ -118,7 +117,6 @@
|
||||
"n-hosts-awaiting-patch": "Der Host {n} benötigt dieses Patch | Die Hosts {n} benötigen dieses Patch",
|
||||
"n-missing": "{n} verbleibend",
|
||||
"name": "Name",
|
||||
"netmask": "Netzmaske",
|
||||
"network-download": "Download",
|
||||
"network-throughput": "Netzwerkdurchsatz",
|
||||
"network-upload": "Upload",
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
"cpu-provisioning": "CPU provisioning",
|
||||
"cpu-provisioning-warning": "The number of vCPUs allocated exceeds the number of physical CPUs available. System performance could be affected",
|
||||
"cpu-usage": "CPU usage",
|
||||
"delete": "Delete",
|
||||
"delete-vms": "Delete 1 VM | Delete {n} VMs",
|
||||
"deploy": "Deploy",
|
||||
"deploy-xoa": "Deploy XOA",
|
||||
@@ -58,11 +57,8 @@
|
||||
"deploy-xoa-status.waiting": "Waiting for XOA to respond…",
|
||||
|
||||
"descending": "descending",
|
||||
"description": "Description",
|
||||
"dhcp": "DHCP",
|
||||
"disabled": "Disabled",
|
||||
"display": "Display",
|
||||
"dns": "DNS",
|
||||
"do-you-have-needs": "You have needs and/or expectations? Let us know",
|
||||
"documentation": "Documentation",
|
||||
"edit-config": "Edit config",
|
||||
@@ -96,8 +92,6 @@
|
||||
"force-reboot": "Force reboot",
|
||||
"force-shutdown": "Force shutdown",
|
||||
"fullscreen-leave": "Leave fullscreen",
|
||||
"n-gb-left": "{n} GB left",
|
||||
"n-gb-required": "{n} GB required",
|
||||
"go-back": "Go back",
|
||||
"gzip": "gzip",
|
||||
"here": "Here",
|
||||
@@ -115,6 +109,11 @@
|
||||
"job.vm-delete.in-progress": "Delete in progress…",
|
||||
"job.vm-delete.missing-vms": "No VM to delete",
|
||||
|
||||
"job.vm-export.in-progress": "Export in progress…",
|
||||
"job.vm-export.missing-compression": "Compression must be provided",
|
||||
"job.vm-export.missing-vms": "No VM to export",
|
||||
"job.vm-export.not-allowed": "A VM is not allowed to export",
|
||||
|
||||
"job.vm-force-reboot.bad-power-state": "VM must be running or paused",
|
||||
"job.vm-force-reboot.in-progress": "Force reboot in progress…",
|
||||
"job.vm-force-reboot.missing-vms": "No VM to force reboot",
|
||||
@@ -123,11 +122,6 @@
|
||||
"job.vm-force-shutdown.in-progress": "Force shutdown in progress…",
|
||||
"job.vm-force-shutdown.missing-vms": "No VM to force shutdown",
|
||||
|
||||
"job.vm-export.in-progress": "Export in progress…",
|
||||
"job.vm-export.missing-compression": "Compression must be provided",
|
||||
"job.vm-export.missing-vms": "No VM to export",
|
||||
"job.vm-export.not-allowed": "A VM is not allowed to export",
|
||||
|
||||
"job.vm-migrate.bad-power-state": "VM must be running",
|
||||
"job.vm-migrate.in-progress": "Migrate in progress…",
|
||||
"job.vm-migrate.missing-host": "Destination host must be provided",
|
||||
@@ -152,15 +146,15 @@
|
||||
"job.vm-snapshot.in-progress": "Snapshot in progress…",
|
||||
"job.vm-snapshot.missing-vms": "No VM to snapshot",
|
||||
|
||||
"job.vm-start.bad-power-state": "VM must be halted",
|
||||
"job.vm-start.in-progress": "Start in progress…",
|
||||
"job.vm-start.missing-vms": "No VM to start",
|
||||
|
||||
"job.vm-start-on.bad-power-state": "VM must be halted",
|
||||
"job.vm-start-on.in-progress": "Start in progress…",
|
||||
"job.vm-start-on.missing-host": "Destination host must be provided",
|
||||
"job.vm-start-on.missing-vms": "No VM to start",
|
||||
|
||||
"job.vm-start.bad-power-state": "VM must be halted",
|
||||
"job.vm-start.in-progress": "Start in progress…",
|
||||
"job.vm-start.missing-vms": "No VM to start",
|
||||
|
||||
"job.vm-suspend.bad-power-state": "VM must be running",
|
||||
"job.vm-suspend.in-progress": "Suspend in progress…",
|
||||
"job.vm-suspend.missing-vms": "No VM to suspend",
|
||||
@@ -173,12 +167,13 @@
|
||||
"loading-hosts": "Loading hosts…",
|
||||
"login": "Login",
|
||||
"login-only-on-master": "Login is only possible on the master host",
|
||||
"more-actions": "More actions",
|
||||
"migrate": "Migrate",
|
||||
"migrate-n-vms": "Migrate 1 VM | Migrate {n} VMs",
|
||||
"more-actions": "More actions",
|
||||
"n-gb-left": "{n} GB left",
|
||||
"n-gb-required": "{n} GB required",
|
||||
"n-hosts-awaiting-patch": "{n} host is awaiting this patch | {n} hosts are awaiting this patch",
|
||||
"n-missing": "{n} missing",
|
||||
"name": "Name",
|
||||
"netmask": "Netmask",
|
||||
"network-download": "Download",
|
||||
"network-throughput": "Network throughput",
|
||||
@@ -187,7 +182,6 @@
|
||||
"news": "News",
|
||||
"news-name": "{name} news",
|
||||
"no-alarm-triggered": "No alarm triggered",
|
||||
"no-result": "No result",
|
||||
"no-selected-vm-can-be-exported": "No selected VM can be exported",
|
||||
"no-selected-vm-can-be-migrated": "No selected VM can be migrated",
|
||||
"no-tasks": "No tasks",
|
||||
@@ -222,12 +216,12 @@
|
||||
"save": "Save",
|
||||
"select-compression": "Select a compression",
|
||||
"select-destination-host": "Select a destination host",
|
||||
"selected-vms-in-execution": "Some selected VMs are running",
|
||||
"send-us-feedback": "Send us feedback",
|
||||
|
||||
"select.network": "Select a network",
|
||||
"select.storage": "Select a storage",
|
||||
|
||||
"selected-vms-in-execution": "Some selected VMs are running",
|
||||
"send-us-feedback": "Send us feedback",
|
||||
"settings": "Settings",
|
||||
"shutdown": "Shutdown",
|
||||
"snapshot": "Snapshot",
|
||||
@@ -241,7 +235,6 @@
|
||||
"start": "Start",
|
||||
"start-on-host": "Start on specific host",
|
||||
"static-ip": "Static IP",
|
||||
"status": "Status",
|
||||
"storage-usage": "Storage usage",
|
||||
"support": "Support",
|
||||
"suspend": "Suspend",
|
||||
@@ -263,11 +256,11 @@
|
||||
"vcpus": "vCPUs",
|
||||
"vcpus-used": "vCPUs used",
|
||||
"version": "Version",
|
||||
"vm-is-running": "The VM is running",
|
||||
|
||||
"vm.active": "Active",
|
||||
"vm.inactive": "Inactive",
|
||||
|
||||
"vm-is-running": "The VM is running",
|
||||
"xo-lite-under-construction": "XOLite is under construction",
|
||||
"xoa-admin-account": "XOA admin account",
|
||||
"xoa-deploy": "XOA deployment",
|
||||
|
||||
283
@xen-orchestra/lite/src/locales/es.json
Normal file
283
@xen-orchestra/lite/src/locales/es.json
Normal file
@@ -0,0 +1,283 @@
|
||||
{
|
||||
"about": "A propósito",
|
||||
"access-xoa": "Acceder a la XOA",
|
||||
"add": "Añadir",
|
||||
"add-filter": "Añadir un filtro",
|
||||
"add-or": "+o",
|
||||
"add-sort": "Añadir un sorteo",
|
||||
"admin-login": "Nombre del usuario administrador",
|
||||
"admin-password": "Contraseña del administrador",
|
||||
"admin-password-confirm": "Confirmar la contraseña del administrador",
|
||||
|
||||
"alarm-type.cpu_usage": "El uso del CPU sobrepasa el {n}%",
|
||||
"alarm-type.disk_usage": "El uso del disco sobrepasa el {n}%",
|
||||
"alarm-type.fs_usage": "El uso del sistema de ficheros sobrepasa el {n}%",
|
||||
"alarm-type.log_fs_usage": "El uso de la bicácora del sistema de ficheros sobrepasa el {n}%",
|
||||
"alarm-type.mem_usage": "El uso de la memoria sobrepasa el {n}%",
|
||||
"alarm-type.memory_free_kib": "La memoria libre está debajo del {n}%",
|
||||
"alarm-type.network_usage": "El uso de la red sobrepasa el {n}%",
|
||||
"alarm-type.physical_utilisation": "El uso físico sobrepasa el {n}%",
|
||||
"alarm-type.sr_io_throughput_total_per_host": "El uso total de Entrada/Salida SR por servido físico sobrepasa el {n}%",
|
||||
"alarm-type.unknown": "Alarma desconocida",
|
||||
|
||||
"all-good": "Todo bien!",
|
||||
"allow-self-signed-ssl": "Es posible que tendrá que permitir certificados SSL autofirmados dentro de su navegador",
|
||||
"appearance": "Aparencia",
|
||||
"ascending": "ascendente",
|
||||
"available-properties-for-advanced-filter": "Propriedades disponibles para filtros avanzados",
|
||||
"back-pool-dashboard": "Regresa al panel de estado del conjunto de servidores",
|
||||
"backup": "Salvaguarda",
|
||||
"cancel": "Anular",
|
||||
"change-state": "Cambiar estado",
|
||||
"check-errors": "Revisar los errores :",
|
||||
"click-to-display-alarms": "Haga clic para mostra alarmas :",
|
||||
"click-to-return-default-pool": "Haga clic para regresar al conjunto de servidores predeterminado",
|
||||
"close": "Cerrar",
|
||||
"community": "Comunidad",
|
||||
"community-name": "Comunidad {name}",
|
||||
"configuration": "Configuración",
|
||||
"confirm-cancel": "¿Estás seguro que deseas cancelar?",
|
||||
"confirm-delete": "Estás a punto de eliminar {0}",
|
||||
"console-unavailable": "Cónsola no disponible",
|
||||
"copy": "Copiar",
|
||||
"cpu-provisioning": "Aprovisionamiento de CPU",
|
||||
"cpu-provisioning-warning": "La cantidad de vCPU asignadas excede la cantidad de CPU físicas disponibles. El rendimiento del sistema puede verse afectado.",
|
||||
"cpu-usage": "Uso del CPU",
|
||||
"delete": "Borrar",
|
||||
"delete-vms": "Borrar una máquina virtual | Borrar {n} máquinas virtuales",
|
||||
"deploy": "Desplegar",
|
||||
"deploy-xoa": "Desplegar XOA",
|
||||
"deploy-xoa-available-on-desktop": "El despliegue de XOA está disponible en la computadora",
|
||||
"deploy-xoa-custom-ntp-servers": "Servidores NTP para la XOA (seperados por espacios)",
|
||||
|
||||
"deploy-xoa-status.configuring": "Configurando la XOA…",
|
||||
"deploy-xoa-status.importing": "Importando la XOA…",
|
||||
"deploy-xoa-status.not-responding": "La XOA no responde",
|
||||
"deploy-xoa-status.ready": "La XOA está lista!",
|
||||
"deploy-xoa-status.starting": "Iniciando la XOA…",
|
||||
"deploy-xoa-status.waiting": "Esperando respuesta de la XOA…",
|
||||
|
||||
"descending": "descendente",
|
||||
"description": "Descripción",
|
||||
"dhcp": "DHCP",
|
||||
"dns": "DNS",
|
||||
"disabled": "Desactivado",
|
||||
"display": "Mostrar",
|
||||
"do-you-have-needs": "¿Falta algo? Háganos saber",
|
||||
"documentation": "Documentación",
|
||||
"edit-config": "Modificar configuración",
|
||||
"enabled": "Activado",
|
||||
"error-occurred": "Hubo un error",
|
||||
"export": "Exportar",
|
||||
"export-n-vms": "Exportar una máquina virtual | Exportar {n} máquinas virtuales",
|
||||
"export-n-vms-manually": "Exportar una máquina virtual a mano | Exportar {n} máquinas virtuales a mano",
|
||||
"export-table-to": "Exportar la tabla a {type}",
|
||||
"export-vm": "Exportar una máquina virtual",
|
||||
"export-vms": "Exportar unas máquinas virtuales",
|
||||
"export-vms-manually-information": "Algunas exportaciones de máquina virtual no pudieron iniciarse automáticamente, posiblemente debido a la configuración del navegador. Para exportarlos, tendrás que hacer clic en cada uno de ellos. (o copiar el enlace).",
|
||||
"fetching-fresh-data": "Refrescando datos",
|
||||
|
||||
"filter.comparison.contains": "Contiene",
|
||||
"filter.comparison.ends-with": "Termina con",
|
||||
"filter.comparison.equals": "Está egual a",
|
||||
"filter.comparison.is": "Es",
|
||||
"filter.comparison.is-false": "Es falso",
|
||||
"filter.comparison.is-not": "No es",
|
||||
"filter.comparison.is-true": "Es verdad",
|
||||
"filter.comparison.matches-regex": "Corresponde a la regex",
|
||||
"filter.comparison.not-contain": "No contiene",
|
||||
"filter.comparison.not-end-with": "No termina con",
|
||||
"filter.comparison.not-equal": "No es egual a",
|
||||
"filter.comparison.not-match-regex": "No corresponde a la regex",
|
||||
"filter.comparison.not-start-with": "No comienza con",
|
||||
"filter.comparison.starts-with": "Comienza con",
|
||||
|
||||
"following-hosts-unreachable": "Imposible comunicar con los servidores siguientes",
|
||||
"force-reboot": "Forzar un reinicio",
|
||||
"force-shutdown": "Forzar un apagado",
|
||||
"fullscreen-leave": "Salir de pantalla completa",
|
||||
"n-gb-left": "{n} Go libres",
|
||||
"n-gb-required": "{n} Go requeridos",
|
||||
"go-back": "Regresa",
|
||||
"gzip": "gzip",
|
||||
"here": "Aquí",
|
||||
|
||||
"host.active": "Activo | Activo | Activos",
|
||||
"host.inactive": "Inactivo | Inactivo | Inactivos",
|
||||
|
||||
"invalid-field": "Campo inválido",
|
||||
|
||||
"job.vm-copy.bad-power-state": "La máquina virtual debe estar apagada",
|
||||
"job.vm-copy.in-progress": "Copiando…",
|
||||
"job.vm-copy.missing-vms": "No hay máquinas virtuales para copiar",
|
||||
|
||||
"job.vm-delete.bad-power-state": "La máquina virtual debe estar apagada",
|
||||
"job.vm-delete.in-progress": "Borrándola…",
|
||||
"job.vm-delete.missing-vms": "No hay máquinas virtuales para borrar",
|
||||
|
||||
"job.vm-force-reboot.bad-power-state": "La máquina virtual debe estar en marcha o pausada",
|
||||
"job.vm-force-reboot.in-progress": "Reinicio forzado en curso…",
|
||||
"job.vm-force-reboot.missing-vms": "No hay máquinas virtuales para reiniciar por fuerza",
|
||||
|
||||
"job.vm-force-shutdown.bad-power-state": "La máquina virtual debe estar en marcha, suspendida o pausada",
|
||||
"job.vm-force-shutdown.in-progress": "Parada forzada en curso…",
|
||||
"job.vm-force-shutdown.missing-vms": "No hay máquinas virtuales para parar por fuerza",
|
||||
|
||||
"job.vm-export.in-progress": "Exportación en curso…",
|
||||
"job.vm-export.missing-compression": "Se requiere compresión",
|
||||
"job.vm-export.missing-vms": "No hay máquinas virtuales para exportar",
|
||||
"job.vm-export.not-allowed": "Prohibido exportar una máquina virtual",
|
||||
|
||||
"job.vm-migrate.bad-power-state": "La máquina virtual debe estar en marcha",
|
||||
"job.vm-migrate.in-progress": "Migrándola…",
|
||||
"job.vm-migrate.missing-host": "Se requiere servidor de destino",
|
||||
"job.vm-migrate.missing-vms": "No hay máquina virtual que migrar",
|
||||
|
||||
"job.vm-pause.bad-power-state": "La máquina virtual debe estar en marcha",
|
||||
"job.vm-pause.in-progress": "Pausándola…",
|
||||
"job.vm-pause.missing-vms": "No hay máquina virtual que pausar",
|
||||
|
||||
"job.vm-reboot.bad-power-state": "La máquina virtual debe estar en marcha",
|
||||
"job.vm-reboot.in-progress": "Reiniciándola…",
|
||||
"job.vm-reboot.missing-vms": "No hay máquina virtual que reiniciar",
|
||||
|
||||
"job.vm-resume.bad-power-state": "La máquina virtual debe estar pausada o suspendida",
|
||||
"job.vm-resume.in-progress": "Reanudándola…",
|
||||
"job.vm-resume.missing-vms": "No hay máquina virtual que reanudir",
|
||||
|
||||
"job.vm-shutdown.bad-power-state": "La máquina virtual debe estar en marcha",
|
||||
"job.vm-shutdown.in-progress": "Apagándola…",
|
||||
"job.vm-shutdown.missing-vms": "No hay máquina virtual que apagar",
|
||||
|
||||
"job.vm-snapshot.in-progress": "Creando instantánea…",
|
||||
"job.vm-snapshot.missing-vms": "No hay máquina virtual que instantanear",
|
||||
|
||||
"job.vm-start.bad-power-state": "La máquina virtual debe estar parada",
|
||||
"job.vm-start.in-progress": "Démarrage en curso…",
|
||||
"job.vm-start.missing-vms": "No hay máquina virtual que parar",
|
||||
|
||||
"job.vm-start-on.bad-power-state": "La máquina virtual debe estar parada",
|
||||
"job.vm-start-on.in-progress": "Iniciándola…",
|
||||
"job.vm-start-on.missing-host": "Se requiere servidor de destino",
|
||||
"job.vm-start-on.missing-vms": "No hay máquina virtual que iniciar",
|
||||
|
||||
"job.vm-suspend.bad-power-state": "La máquina virtual debe estar en marcha",
|
||||
"job.vm-suspend.in-progress": "Suspendiéndola…",
|
||||
"job.vm-suspend.missing-vms": "No hay máquina virtual que suspender",
|
||||
|
||||
"keep-me-logged": "Mantenerme conectado",
|
||||
"keep-page-open": "Hasta que termine el despliegue, no refresca ni cierra esta página",
|
||||
"language": "Idioma",
|
||||
"last-week": "Semana pasada",
|
||||
"load-now": "Cargar ahora",
|
||||
"loading-hosts": "Cargando servidores…",
|
||||
"login": "Conectarse",
|
||||
"login-only-on-master": "Sólo es posible conectarse al servidor principal",
|
||||
"more-actions": "Acciones adicionales",
|
||||
"migrate": "Migrar",
|
||||
"migrate-n-vms": "Migrar una máquina virtual | Migrar {n} máquinas virtuales",
|
||||
"n-hosts-awaiting-patch": "{n} servidor falta este parche | {n} servidores faltan este parche",
|
||||
"n-missing": "Falta {n} | Faltan {n}",
|
||||
"name": "Nombre",
|
||||
"netmask": "Máscara de red",
|
||||
"network-download": "Rendimiento de descarga de red",
|
||||
"network-throughput": "Rendimiento de red",
|
||||
"network-upload": "Rendimiento de carga de red",
|
||||
"new-features-are-coming": "Próximamente nuevas funciones!",
|
||||
"news": "Actualidades",
|
||||
"news-name": "Actualidades {name}",
|
||||
"no-alarm-triggered": "No hay alarma",
|
||||
"no-result": "No hay resultados",
|
||||
"no-selected-vm-can-be-exported": "Ninguna máquina virtual selectionada puede exportarse",
|
||||
"no-selected-vm-can-be-migrated": "Ninguna máquina virtual selectionada puede migrarse",
|
||||
"no-tasks": "No hay tareas",
|
||||
"not-found": "No encontrado",
|
||||
"object": "Objeto",
|
||||
"ok": "OK",
|
||||
"on-object": "sobre {object}",
|
||||
"or": "o/u",
|
||||
"password": "Contraseña",
|
||||
"password-invalid": "La contraseña no es válido",
|
||||
"pause": "Pausar",
|
||||
"please-confirm": "Confirme, por favor",
|
||||
"pool-cpu-usage": "Uso CPU del conjunto de servidores",
|
||||
"pool-ram-usage": "Uso RAM del conjunto de servidores",
|
||||
"power-state": "Estado alimentación electrica",
|
||||
"property": "Propriedad",
|
||||
"ram-usage": "Uso RAM",
|
||||
"reboot": "Reiniciar",
|
||||
"reformat": "Reformatear",
|
||||
|
||||
"relative-time.day": "1 día| {n} días",
|
||||
"relative-time.future": "Dentro de {str}",
|
||||
"relative-time.hour": "1 hora | {n} horas",
|
||||
"relative-time.minute": "Un minuto | {n} minutos",
|
||||
"relative-time.month": "Un mes | {n} meses",
|
||||
"relative-time.now": "Ahora mismo",
|
||||
"relative-time.past": "Hace {str}",
|
||||
"relative-time.second": "Un secundo | {n} secundos",
|
||||
"relative-time.year": "1 año | {n} años",
|
||||
|
||||
"resume": "Reanudar",
|
||||
"save": "Guardar",
|
||||
"select-compression": "Elige modo de compression",
|
||||
"select-destination-host": "Elige servidor destino",
|
||||
"selected-vms-in-execution": "Algunas de las máquinas virtuales selectionadas están en marcha",
|
||||
"send-us-feedback": "Envíenos sus comentarios",
|
||||
|
||||
"select.network": "Elige una red",
|
||||
"select.storage": "Elige un SR",
|
||||
|
||||
"settings": "Parámetros",
|
||||
"shutdown": "Apagar",
|
||||
"snapshot": "Instantanear",
|
||||
"sort-by": "Ordenar por",
|
||||
"ssh-account": "Cuenta SSH",
|
||||
"ssh-login": "Nombre de usuario SSH",
|
||||
"ssh-password": "Contraseña SSH",
|
||||
"ssh-password-confirm": "Confirmar la contraseña SSH",
|
||||
"stacked-cpu-usage": "Uso CPU apilado",
|
||||
"stacked-ram-usage": "Uso RAM apilado",
|
||||
"start": "Iniciar",
|
||||
"start-on-host": "Iniciar en un servidor específico",
|
||||
"static-ip": "IP estático",
|
||||
"status": "Estatus",
|
||||
"storage-usage": "Uso de almacenamiento",
|
||||
"support": "Apoyo",
|
||||
"suspend": "Suspender",
|
||||
"switch-theme": "Cambiar el tema",
|
||||
|
||||
"task.estimated-end": "Fin estimado",
|
||||
"task.progress": "Progreso",
|
||||
"task.started": "Iniciado",
|
||||
|
||||
"theme-auto": "Auto",
|
||||
"theme-dark": "Oscuro",
|
||||
"theme-light": "Claro",
|
||||
"this-vm-cant-be-migrated": "Esta máquina virtual no se puede migrar",
|
||||
"top-#": "{n} principales",
|
||||
"total-free:": "Total libre :",
|
||||
"total-used:": "Total usado :",
|
||||
"unreachable-hosts": "Servidores no accesibles",
|
||||
"unreachable-hosts-reload-page": "Acabado. Refresca la página",
|
||||
"vcpus": "vCPUs",
|
||||
"vcpus-used": "vCPUs usados",
|
||||
"version": "Versión",
|
||||
|
||||
"vm.active": "Activo | Activo | Activos",
|
||||
"vm.inactive": "No activo | No activo | No activos",
|
||||
|
||||
"vm-is-running": "La máquina virtual está en marcha",
|
||||
"xo-lite-under-construction": "XOLite está en desarroyo",
|
||||
"xoa-admin-account": "Cuanta administrador de la XOA",
|
||||
"xoa-deploy": "Despliegue de la XOA",
|
||||
"xoa-deploy-failed": "Error en el despliegue de la XOA !",
|
||||
"xoa-deploy-retry": "Vuelva a intentar el despliegue de la XOA",
|
||||
"xoa-deploy-successful": "Despliegue de la XOA succedió !",
|
||||
"xoa-ip": "Dirección IP de la XOA",
|
||||
"xoa-password-confirm-different": "No se confirmó la contraseña",
|
||||
"xoa-ssh-account": "Cuenta SSH de la XOA",
|
||||
"xoa-ssh-password-confirm-different": "No se confirmó la contraseña SSH",
|
||||
"you-are-currently-on": "Estás conectado al : {0}",
|
||||
"zstd": "zstd"
|
||||
}
|
||||
@@ -58,7 +58,6 @@
|
||||
|
||||
"descending": "نزولی",
|
||||
"description": "توصیف",
|
||||
"dhcp": "DHCP",
|
||||
"disabled": "غیر فعال",
|
||||
"display": "نمایش",
|
||||
"dns": "DNS",
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
"cpu-provisioning": "Provisionnement CPU",
|
||||
"cpu-provisioning-warning": "Le nombre de vCPU alloués dépasse le nombre de CPU physique disponible. Les performances du système pourraient être affectées",
|
||||
"cpu-usage": "Utilisation CPU",
|
||||
"delete": "Supprimer",
|
||||
"delete-vms": "Supprimer 1 VM | Supprimer {n} VMs",
|
||||
"deploy": "Déployer",
|
||||
"deploy-xoa": "Déployer XOA",
|
||||
@@ -58,10 +57,7 @@
|
||||
"deploy-xoa-status.waiting": "En attente de réponse de la XOA…",
|
||||
|
||||
"descending": "descendant",
|
||||
"description": "Description",
|
||||
"dhcp": "DHCP",
|
||||
"dns": "DNS",
|
||||
"disabled": "Désactivé",
|
||||
"display": "Affichage",
|
||||
"do-you-have-needs": "Vous avez des besoins et/ou des attentes ? Faites le nous savoir",
|
||||
"documentation": "Documentation",
|
||||
@@ -96,8 +92,6 @@
|
||||
"force-reboot": "Forcer le redémarrage",
|
||||
"force-shutdown": "Forcer l'arrêt",
|
||||
"fullscreen-leave": "Quitter plein écran",
|
||||
"n-gb-left": "{n} Go libres",
|
||||
"n-gb-required": "{n} Go requis",
|
||||
"go-back": "Revenir en arrière",
|
||||
"gzip": "gzip",
|
||||
"here": "Ici",
|
||||
@@ -115,6 +109,11 @@
|
||||
"job.vm-delete.in-progress": "Suppression en cours…",
|
||||
"job.vm-delete.missing-vms": "Aucune VM à supprimer",
|
||||
|
||||
"job.vm-export.in-progress": "Exportation en cours…",
|
||||
"job.vm-export.missing-compression": "La compression est requise",
|
||||
"job.vm-export.missing-vms": "Aucune VM à exporter",
|
||||
"job.vm-export.not-allowed": "VM non autorisée à être exportée",
|
||||
|
||||
"job.vm-force-reboot.bad-power-state": "La VM doit être allumée ou en pause",
|
||||
"job.vm-force-reboot.in-progress": "Redémarrage forcé en cours…",
|
||||
"job.vm-force-reboot.missing-vms": "Aucune VM à redémarrer de force",
|
||||
@@ -123,11 +122,6 @@
|
||||
"job.vm-force-shutdown.in-progress": "Arrêt forcé en cours…",
|
||||
"job.vm-force-shutdown.missing-vms": "Aucune VM à arrêter de force",
|
||||
|
||||
"job.vm-export.in-progress": "Exportation en cours…",
|
||||
"job.vm-export.missing-compression": "La compression est requise",
|
||||
"job.vm-export.missing-vms": "Aucune VM à exporter",
|
||||
"job.vm-export.not-allowed": "VM non autorisée à être exportée",
|
||||
|
||||
"job.vm-migrate.bad-power-state": "La VM doit être allumée",
|
||||
"job.vm-migrate.in-progress": "Migration en cours…",
|
||||
"job.vm-migrate.missing-host": "L'hôte de destination est requis",
|
||||
@@ -152,15 +146,15 @@
|
||||
"job.vm-snapshot.in-progress": "Instantané en cours…",
|
||||
"job.vm-snapshot.missing-vms": "Aucune VM pour l'instantané",
|
||||
|
||||
"job.vm-start.bad-power-state": "La VM doit être arrêtée",
|
||||
"job.vm-start.in-progress": "Démarrage en cours…",
|
||||
"job.vm-start.missing-vms": "Aucune VM à démarrer",
|
||||
|
||||
"job.vm-start-on.bad-power-state": "La VM doit être arrêtée",
|
||||
"job.vm-start-on.in-progress": "Démarrage en cours…",
|
||||
"job.vm-start-on.missing-host": "L'hôte de destination est requis",
|
||||
"job.vm-start-on.missing-vms": "Aucune VM à démarrer",
|
||||
|
||||
"job.vm-start.bad-power-state": "La VM doit être arrêtée",
|
||||
"job.vm-start.in-progress": "Démarrage en cours…",
|
||||
"job.vm-start.missing-vms": "Aucune VM à démarrer",
|
||||
|
||||
"job.vm-suspend.bad-power-state": "La VM doit être allumée",
|
||||
"job.vm-suspend.in-progress": "Suspension en cours…",
|
||||
"job.vm-suspend.missing-vms": "Aucune VM à suspendre",
|
||||
@@ -173,12 +167,13 @@
|
||||
"loading-hosts": "Chargement des hôtes…",
|
||||
"login": "Connexion",
|
||||
"login-only-on-master": "La connexion n'est possible que sur l'hôte primaire",
|
||||
"more-actions": "Plus d'actions",
|
||||
"migrate": "Migrer",
|
||||
"migrate-n-vms": "Migrer 1 VM | Migrer {n} VMs",
|
||||
"more-actions": "Plus d'actions",
|
||||
"n-gb-left": "{n} Go libres",
|
||||
"n-gb-required": "{n} Go requis",
|
||||
"n-hosts-awaiting-patch": "{n} hôte attend ce patch | {n} hôtes attendent ce patch",
|
||||
"n-missing": "{n} manquant | {n} manquants",
|
||||
"name": "Nom",
|
||||
"netmask": "Masque réseau",
|
||||
"network-download": "Descendant",
|
||||
"network-throughput": "Débit du réseau",
|
||||
@@ -187,7 +182,6 @@
|
||||
"news": "Actualités",
|
||||
"news-name": "Actualités {name}",
|
||||
"no-alarm-triggered": "Aucune alarme déclenchée",
|
||||
"no-result": "Aucun résultat",
|
||||
"no-selected-vm-can-be-exported": "Aucune VM sélectionnée ne peut être exportée",
|
||||
"no-selected-vm-can-be-migrated": "Aucune VM sélectionnée ne peut être migrée",
|
||||
"no-tasks": "Aucune tâche",
|
||||
@@ -222,12 +216,12 @@
|
||||
"save": "Enregistrer",
|
||||
"select-compression": "Sélectionnez une compression",
|
||||
"select-destination-host": "Sélectionnez un hôte de destination",
|
||||
"selected-vms-in-execution": "Certaines VMs sélectionnées sont en cours d'exécution",
|
||||
"send-us-feedback": "Envoyez-nous vos commentaires",
|
||||
|
||||
"select.network": "Sélectionner un réseau",
|
||||
"select.storage": "Sélectionner un SR",
|
||||
|
||||
"selected-vms-in-execution": "Certaines VMs sélectionnées sont en cours d'exécution",
|
||||
"send-us-feedback": "Envoyez-nous vos commentaires",
|
||||
"settings": "Paramètres",
|
||||
"shutdown": "Arrêter",
|
||||
"snapshot": "Instantané",
|
||||
@@ -241,7 +235,6 @@
|
||||
"start": "Démarrer",
|
||||
"start-on-host": "Démarrer sur un hôte spécifique",
|
||||
"static-ip": "IP statique",
|
||||
"status": "Statut",
|
||||
"storage-usage": "Utilisation du stockage",
|
||||
"support": "Support",
|
||||
"suspend": "Suspendre",
|
||||
@@ -263,11 +256,11 @@
|
||||
"vcpus": "vCPUs",
|
||||
"vcpus-used": "vCPUs utilisés",
|
||||
"version": "Version",
|
||||
"vm-is-running": "La VM est en cours d'exécution",
|
||||
|
||||
"vm.active": "Active | Active | Actives",
|
||||
"vm.inactive": "Inactive | Inactive | Inactives",
|
||||
|
||||
"vm-is-running": "La VM est en cours d'exécution",
|
||||
"xo-lite-under-construction": "XOLite est en construction",
|
||||
"xoa-admin-account": "Compte administrateur de la XOA",
|
||||
"xoa-deploy": "Déploiement de la XOA",
|
||||
|
||||
@@ -1,9 +1,38 @@
|
||||
import { createXapiStoreConfig } from '@/stores/xen-api/create-xapi-store-config'
|
||||
import { usePifStore } from '@/stores/xen-api/pif.store'
|
||||
import { createSubscribableStoreContext } from '@core/utils/create-subscribable-store-context.util'
|
||||
import { sortByNameLabel } from '@core/utils/sort-by-name-label.util'
|
||||
import { defineStore } from 'pinia'
|
||||
import { computed } from 'vue'
|
||||
|
||||
export const useNetworkStore = defineStore('xen-api-network', () => {
|
||||
const config = createXapiStoreConfig('network')
|
||||
const deps = {
|
||||
pifStore: usePifStore(),
|
||||
}
|
||||
|
||||
return createSubscribableStoreContext(config, {})
|
||||
const { context: baseContext, ...configRest } = createXapiStoreConfig('network', {
|
||||
sortBy: sortByNameLabel,
|
||||
})
|
||||
|
||||
const pifContext = deps.pifStore.getContext()
|
||||
|
||||
const networksWithPifs = computed(() => {
|
||||
const networkRefs = Array.from(pifContext.hostMasterPifsByNetwork.value.keys())
|
||||
|
||||
return baseContext.records.value.filter(network => {
|
||||
return networkRefs.includes(network.$ref) && network.PIFs.length > 0
|
||||
})
|
||||
})
|
||||
|
||||
const networksWithoutPifs = computed(() => {
|
||||
return baseContext.records.value.filter(network => network.PIFs.length === 0)
|
||||
})
|
||||
|
||||
const context = {
|
||||
...baseContext,
|
||||
networksWithPifs,
|
||||
networksWithoutPifs,
|
||||
}
|
||||
|
||||
return createSubscribableStoreContext({ context, ...configRest }, deps)
|
||||
})
|
||||
|
||||
17
@xen-orchestra/lite/src/stores/xen-api/pif-metrics.store.ts
Normal file
17
@xen-orchestra/lite/src/stores/xen-api/pif-metrics.store.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { XenApiPif } from '@/libs/xen-api/xen-api.types'
|
||||
import { createXapiStoreConfig } from '@/stores/xen-api/create-xapi-store-config'
|
||||
import { createSubscribableStoreContext } from '@core/utils/create-subscribable-store-context.util'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const usePifMetricsStore = defineStore('xen-api-pif-metrics', () => {
|
||||
const { context: baseContext, ...configRest } = createXapiStoreConfig('pif_metrics')
|
||||
|
||||
const getPifCarrier = (pif: XenApiPif) => baseContext.getByOpaqueRef(pif.metrics)?.carrier
|
||||
|
||||
const context = {
|
||||
...baseContext,
|
||||
getPifCarrier,
|
||||
}
|
||||
|
||||
return createSubscribableStoreContext({ context, ...configRest }, {})
|
||||
})
|
||||
53
@xen-orchestra/lite/src/stores/xen-api/pif.store.ts
Normal file
53
@xen-orchestra/lite/src/stores/xen-api/pif.store.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import type { XenApiNetwork, XenApiPif } from '@/libs/xen-api/xen-api.types'
|
||||
import { createXapiStoreConfig } from '@/stores/xen-api/create-xapi-store-config'
|
||||
import { usePoolStore } from '@/stores/xen-api/pool.store'
|
||||
import { createSubscribableStoreContext } from '@core/utils/create-subscribable-store-context.util'
|
||||
import { defineStore } from 'pinia'
|
||||
import { computed } from 'vue'
|
||||
|
||||
export const usePifStore = defineStore('xen-api-pif', () => {
|
||||
const deps = {
|
||||
poolStore: usePoolStore(),
|
||||
}
|
||||
const { context: baseContext, ...configRest } = createXapiStoreConfig('pif')
|
||||
|
||||
const poolContext = deps.poolStore.getContext()
|
||||
|
||||
const hostMasterPifsByNetwork = computed(() => {
|
||||
const hostMasterPifsByNetworkMap = new Map<XenApiNetwork['$ref'], XenApiPif[]>()
|
||||
|
||||
baseContext.records.value
|
||||
.filter(pif => poolContext.isMasterHost(pif.host))
|
||||
.forEach(pif => {
|
||||
const networkId = pif.network
|
||||
if (!hostMasterPifsByNetworkMap.has(networkId)) {
|
||||
hostMasterPifsByNetworkMap.set(networkId, [])
|
||||
}
|
||||
hostMasterPifsByNetworkMap.get(networkId)?.push(pif)
|
||||
})
|
||||
|
||||
return hostMasterPifsByNetworkMap
|
||||
})
|
||||
|
||||
const pifsByNetwork = computed(() => {
|
||||
const pifsByNetworkMap = new Map<XenApiNetwork['$ref'], XenApiPif[]>()
|
||||
|
||||
baseContext.records.value.forEach(pif => {
|
||||
const networkId = pif.network
|
||||
if (!pifsByNetworkMap.has(networkId)) {
|
||||
pifsByNetworkMap.set(networkId, [])
|
||||
}
|
||||
pifsByNetworkMap.get(networkId)?.push(pif)
|
||||
})
|
||||
|
||||
return pifsByNetworkMap
|
||||
})
|
||||
|
||||
const context = {
|
||||
...baseContext,
|
||||
pifsByNetwork,
|
||||
hostMasterPifsByNetwork,
|
||||
}
|
||||
|
||||
return createSubscribableStoreContext({ context, ...configRest }, deps)
|
||||
})
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { XenApiPool } from '@/libs/xen-api/xen-api.types'
|
||||
import type { XenApiHost, XenApiPool } from '@/libs/xen-api/xen-api.types'
|
||||
import { createXapiStoreConfig } from '@/stores/xen-api/create-xapi-store-config'
|
||||
import { createSubscribableStoreContext } from '@core/utils/create-subscribable-store-context.util'
|
||||
import { defineStore } from 'pinia'
|
||||
@@ -9,9 +9,12 @@ export const usePoolStore = defineStore('xen-api-pool', () => {
|
||||
|
||||
const pool = computed<XenApiPool | undefined>(() => baseContext.records.value[0])
|
||||
|
||||
const isMasterHost = (hostRef: XenApiHost['$ref']) => pool.value?.master === hostRef
|
||||
|
||||
const context = {
|
||||
...baseContext,
|
||||
pool,
|
||||
isMasterHost,
|
||||
}
|
||||
|
||||
return createSubscribableStoreContext({ context, ...configRest }, {})
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import LinearChart from '@/components/charts/LinearChart.vue'
|
||||
import ComponentStory from '@/components/component-story/ComponentStory.vue'
|
||||
import { prop } from '@/libs/story/story-param'
|
||||
import type { LinearChartData } from '@/types/chart'
|
||||
import type { LinearChartData } from '@core/types/chart'
|
||||
import LinearChart from '@core/components/charts/LinearChart.vue'
|
||||
// eslint-disable-next-line import/no-named-as-default
|
||||
import humanFormat from 'human-format'
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
<template #title>Do you confirm?</template>
|
||||
<template #subtitle>You should be sure about this</template>
|
||||
<template #buttons>
|
||||
<ModalDeclineButton>I prefer not</UiButton>
|
||||
<ModalApproveButton>Yes, I'm sure!</UiButton>
|
||||
<ModalDeclineButton>I prefer not</ModalDeclineButton>
|
||||
<ModalApproveButton>Yes, I'm sure!</ModalApproveButton>
|
||||
</template>
|
||||
</ConfirmModalLayout>
|
||||
</UiModal>
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
<template #title>{{ settings.title }}</template>
|
||||
<template #subtitle>{{ settings.subtitle }}</template>
|
||||
<template #buttons>
|
||||
<UiButton variant="secondary" accent="info" size="medium">I prefer not</UiButton>
|
||||
<UiButton variant="primary" accent="info" size="medium">Yes, I'm sure!</UiButton>
|
||||
<UiButton variant="secondary" accent="brand" size="medium">I prefer not</UiButton>
|
||||
<UiButton variant="primary" accent="brand" size="medium">Yes, I'm sure!</UiButton>
|
||||
</template>
|
||||
</ConfirmModalLayout>
|
||||
</ComponentStory>
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
|
||||
<template #buttons>
|
||||
<ModalDeclineButton />
|
||||
<ModalApproveButton>Migrate 3 VMs</UiButton>
|
||||
<ModalApproveButton>Migrate 3 VMs</ModalApproveButton>
|
||||
</template>
|
||||
</ConfirmModalLayout>
|
||||
</FormModalLayout>
|
||||
</UiModal>
|
||||
```
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
</div>
|
||||
|
||||
<template #buttons>
|
||||
<UiButton variant="secondary" accent="info" size="medium">Cancel</UiButton>
|
||||
<UiButton variant="primary" accent="info" size="medium">Migrate 3 VMs</UiButton>
|
||||
<UiButton variant="secondary" accent="brand" size="medium">Cancel</UiButton>
|
||||
<UiButton variant="primary" accent="brand" size="medium">Migrate 3 VMs</UiButton>
|
||||
</template>
|
||||
</FormModalLayout>
|
||||
</ComponentStory>
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
# Example
|
||||
|
||||
```vue-template
|
||||
<UiResources>
|
||||
<UiResource :icon="faDisplay" count="1" label="VMs" />
|
||||
<UiResource :icon="faMicrochip" count="4" label="vCPUs" />
|
||||
<UiResource :icon="faMemory" count="2" label="RAM" />
|
||||
<UiResource :icon="faDatabase" count="1" label="SR" />
|
||||
<UiResource :icon="faNetworkWired" count="2" label="Interfaces" />
|
||||
</UiResources>
|
||||
```
|
||||
@@ -1,19 +0,0 @@
|
||||
<template>
|
||||
<ComponentStory :params="[slot().help('One or multiple `UiResource`')]" full-width-component>
|
||||
<UiResources>
|
||||
<UiResource :icon="faDisplay" count="1" label="VMs" />
|
||||
<UiResource :icon="faMicrochip" count="4" label="vCPUs" />
|
||||
<UiResource :icon="faMemory" count="2" label="RAM" />
|
||||
<UiResource :icon="faDatabase" count="1" label="SR" />
|
||||
<UiResource :icon="faNetworkWired" count="2" label="Interfaces" />
|
||||
</UiResources>
|
||||
</ComponentStory>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import ComponentStory from '@/components/component-story/ComponentStory.vue'
|
||||
import UiResource from '@/components/ui/resources/UiResource.vue'
|
||||
import UiResources from '@/components/ui/resources/UiResources.vue'
|
||||
import { slot } from '@/libs/story/story-param'
|
||||
import { faDatabase, faDisplay, faMemory, faMicrochip, faNetworkWired } from '@fortawesome/free-solid-svg-icons'
|
||||
</script>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user