Compare commits

..

127 Commits

Author SHA1 Message Date
Thierry
aba06d56f6 feat(web-core): introducing useFormSelect composable 2025-02-21 18:00:12 +01:00
OlivierFL
4eed730a09 feat: technical release (#8370) 2025-02-21 15:29:00 +01:00
Stephane
42ca53f80c feat(@xen-orchestra/xapi): smart reboot improvements (#8333)
feat(xapi): smart reboot improvements
2025-02-21 11:21:41 +01:00
Julien Fontanet
6b8167a2fc docs(installation): add missing openssl dependency 2025-02-21 10:50:08 +01:00
Mathieu
780e0bbefa feat(@xen-orchestra/rest-api): expose get vms and get vm (#8356)
@vates/types Added an export to the root of the lib because TSOA requires importing the type from the root library to generate the OpenAPI specification
    @vates/types Tuples ([number, number]) throw errors when generating the OpenAPI specification. They have been updated to number[]
    @vates/types Created a XapiXoRecord to be able to differentiate between XO types that come from xapi-object-to-xo and XO types that come from XO collections
    xo-server Added getObjectsByType to avoid iterating over all XAPI objects when we know what type of object we want
    Branded is not a valid type for the OpenAPI spec. I created a Unbrand type, that convert all Branded to string . (Use Unbrand only for OpenAPI specification definition to maintain Branded type safety)
    Added another error middleware to catch TSOA errors and throw XO errors
    Added a README.md to have consistency of order in the use of decorators
2025-02-21 10:31:57 +01:00
Bastien Nollet
b2ba5abacf docs(fuse-vhd): document cli file restoration (#8355)
Document how to restore a file from a VHD with fuse-vhd CLI.
This will allow users to restore by themselves large files that make the restore fail when done from the UI.
2025-02-21 10:26:12 +01:00
Pierre Donias
695b3d76e8 fix(xo-web): empty list of options in selects (#8363)
Introduced by a386680d90
Fixes #8361
See https://github.com/bvaughn/react-virtualized/issues/1871

react-virtualized@9.22.6 seems to be breaking old versions of React
Error in browser console: `TypeError: p.createRef is not a function`
2025-02-20 17:08:52 +01:00
Mathieu
6f5b97f7f3 feat(@xen-orchestra/rest-api): setup simple auth middleware (#8327)
Configure dependency injection + configure authentication middleware for openapi (copy of what actually exists in the current REST API. Will be improved later when implementing ACL/resource set)
2025-02-20 16:07:09 +01:00
OlivierFL
db3f702235 fix(web-stack): rollback vue-tsc version (#8362)
Rollback `vue-tsc` version to `2.1.10`, to fix broken `yarn type-check` and CI.
2025-02-20 13:04:43 +01:00
Bastien Nollet
fb02bf07f6 fix(@vates/task): ensure compatibility between library versions (#8347) 2025-02-19 17:44:34 +01:00
Florent BEAUCHAMP
9723075253 feat(generator): create a toolbox (#8295) 2025-02-18 17:23:51 +01:00
MlssFrncJrg
4b8cdf8043 feat(xo-server/rest-api): ability to create user (#8282) 2025-02-18 16:54:02 +01:00
Florent BEAUCHAMP
397e8b6ed7 fix(xo-server-test): normalize package 2025-02-18 16:45:23 +01:00
Florent BEAUCHAMP
da332715f6 doc(sdn-controller): update readme 2025-02-18 16:45:23 +01:00
Florent BEAUCHAMP
08c47da2b6 fix(rest-api): normalize package 2025-02-18 16:45:23 +01:00
Florent BEAUCHAMP
aa27e3ba46 fix(fatfs): normalize package 2025-02-18 16:45:23 +01:00
Julien Fontanet
a386680d90 chore: update dev deps 2025-02-18 11:05:22 +01:00
Julien Fontanet
6e508b03d8 fix(xo-server-audit): ignore host.getBiosInfo
Introduced by d5217f92f

Related to zammad#34890
2025-02-18 09:19:32 +01:00
Julien Fontanet
2aa7c012f1 fix(xo-server-audit): ignore host.getMdadmHealth
Introduced by c41ae0527

Related to zammad#34890
2025-02-18 09:13:47 +01:00
Julien Fontanet
18fec2a0af fix(CHANGELOG.unreleased): fix Markdown
Introduced by 137837cda
2025-02-18 09:10:56 +01:00
David Johnston
be6b73dcb5 docs: fix links to cloud-init (#8354)
Introduced by a89c31c75

Co-authored-by: David Johnston <david@johnstons.net>
2025-02-18 08:58:37 +01:00
Thomas Moraine
a89c31c75b docs: add page to explain VM templates (#8340)
A forum user suggested changes for better understanding of VM templates.
A new page has been created just for templates,
with Create, Read, Update, Delete (CRUD) sections.

Also, the Cloud-init/Cloudbase-init section of the Advanced page has been moved
to this new page.

This should make it easier for users to get all useful information on templates
in a single document.

Signed-off-by: Thomas Moraine <thomas.moraine@vates.tech>
2025-02-17 10:06:30 +01:00
Julien Fontanet
51b06b1177 docs(xoa): always use HTTPS and wget --no-verbose
`--no-verbose-` is better than `--quite` because it does not hide errors.
2025-02-17 09:36:04 +01:00
Florent BEAUCHAMP
c0d434b612 fix(v2v): Cannot read properties of undefined (reading 'map') with empty datastore (#8311) 2025-02-17 09:35:42 +01:00
Thomas Moraine
b390f36deb doc(XO): Update encryption algorithm transition guidance (#8350)
Update the Xen Orchestra documentation to guide users
on transitioning from AES-256-GCM to ChaCha20-Poly1305 encryption,
solving an issue where users could encounter warnings due to mixed
encryption algorithms in remote storage.
Fix [this]((https://xcp-ng.org/forum/topic/10453/remote-encryption-algorithm)
2025-02-17 09:32:10 +01:00
Mathieu
1983025403 fix(@vates/types): normalize package (#8332) 2025-02-17 09:22:07 +01:00
OlivierFL
9e29c98735 feat(xo-core): update treeview components colors (#8326) 2025-02-17 09:18:00 +01:00
Florent BEAUCHAMP
66e677d7cb feat(V2V/powerOff): handle queued state when stopping the VM (#8328)
zammad#34451
2025-02-14 17:16:50 +01:00
OlivierFL
ecd7d624a0 feat(xo-core): update UiTablePagination component (#8344) 2025-02-14 16:20:24 +01:00
Florent BEAUCHAMP
5219d47fd0 test(vhd-lib): improve ci (#8335) 2025-02-14 15:05:34 +01:00
Mathieu
b7a056dfaf feat(@xen-orchestra/rest-api): add error middlware (#8323) 2025-02-14 14:54:44 +01:00
Mathieu
a5831f8a58 fix(xo-server/rest-api): restore legacy rest-api doc (#8346) 2025-02-14 11:43:41 +01:00
Thomas Moraine
ef636a9821 docs(users): add troubleshooting steps for LDAP group sync issues (#8312)
Some users weren't able to sync all LDAP groups with XO.
Adding what to check to troubleshoot the issue.
Also, refreshing the style and presentation of the LDAP section in the Users page
2025-02-14 09:20:35 +01:00
Nathanaël
987e969103 docs(airgap): replace curl by wget to avoid download errors (#8227)
cURL configuration in old XCP-ng/XenServer hosts is not compatible with https://xoa.io, use wget instead.
2025-02-13 14:40:39 +01:00
MlssFrncJrg
7615a6c5f8 feat(xo-server/rest-api): ability to remove user from a group (#8336) 2025-02-13 12:51:29 +01:00
MlssFrncJrg
a0b1ac9388 feat(xo-server/rest-api): ability to add user in a group (#8334) 2025-02-13 12:36:46 +01:00
MlssFrncJrg
4c6797d278 feat(xo-server/rest-api): ability to update group's name (#8278) 2025-02-13 12:25:02 +01:00
MlssFrncJrg
4b244daebd feat(xo-server/rest-api): ability to delete group (#8277) 2025-02-13 11:45:21 +01:00
MlssFrncJrg
2994b9a327 feat(xo-server/rest-api): ability to create group (#8276) 2025-02-13 11:08:10 +01:00
Mathieu
137837cdab fix(sdn-controller): fix no PIF found when creating private network (#8319)
Fix #8027 zammad#34140
2025-02-12 17:07:40 +01:00
OlivierFL
1fd74a29b9 feat(xo-core): update UiCheckbox and UiRadioButton components (#8342) 2025-02-12 15:26:51 +01:00
Mathieu
877ca82600 feat(@xen-orchestra/rest-api): initial setup for swagger (#8316) 2025-02-12 14:09:22 +01:00
OlivierFL
5dbb529126 feat(xo-core): update UiCounter component (#8337) 2025-02-12 11:55:18 +01:00
OlivierFL
78c3b40762 feat(xo-core): update Button components (#8329) 2025-02-12 11:25:07 +01:00
OlivierFL
47ee8799f3 feat(xo-core): update UiCardTitle and UiCardSubtitle components (#8338) 2025-02-12 11:07:00 +01:00
OlivierFL
8f877962f3 feat(xo-core): update VtsIcon component brand color (#8325) 2025-02-11 17:06:55 +01:00
b-Nollet
832634f284 chore(xo-server): upgrade hashy version (#8304) 2025-02-11 15:50:07 +01:00
Sebastian CZECH
6b6a9a4942 feat(xo-6): dashboard mobile layout (#8268) 2025-02-11 15:11:58 +01:00
OlivierFL
87551ca7b8 feat(xo-core): update UiLink component (#8331) 2025-02-11 13:57:10 +01:00
Julien Fontanet
decf1ebf3e feat(normalize-packages): Node defaults to >=18
See https://github.com/vatesfr/xen-orchestra/pull/8332/files#r1950603611
2025-02-11 11:37:27 +01:00
OlivierFL
aeb22636c7 feat(xo-core): update scrollbars color (#8330) 2025-02-11 09:39:31 +01:00
Thomas Moraine
82473fdf37 docs(sdn_controller): remove XCP-ng 8.0 and prior (obsolete) (#8322)
XCP-ng 8.0 and 7.6 are references in multiple sections.

These versions are obsolete, nobody should be using SDN Controller on anything older than XCP-ng 8.2.

As a result, references to XCP-ng 8.0 and older can be removed safely.

Signed-off-by: Thomas Moraine <thomas.moraine@vates.tech>
2025-02-10 17:19:25 +01:00
Truong
f692c25638 VM Description in backup report (#8253)
Sometime, the name does not provide enough information about the VM, adding more with Description, we will know more which VM has issue with backup.

Co-authored-by: b-Nollet <150058367+b-Nollet@users.noreply.github.com>
2025-02-10 17:05:06 +01:00
OlivierFL
6b30fb50c4 feat(xo-core): update color "info" values (#8314) 2025-02-10 15:10:38 +01:00
Mathieu
0ef95d9911 feat(@vates/types): create @vates/types lib (#8308) 2025-02-10 10:16:39 +01:00
Thomas Moraine
37aa941796 docs(sdn-controller): various improvements (#8318) 2025-02-09 00:33:40 +01:00
Jonas
d907129e82 docs(users): using Google for SAML auth (#8296) 2025-02-07 12:46:57 +01:00
Thomas Moraine
57fe8aec51 docs(users): authentication with auth-oidc plugin (#8230)
Signed-off-by: Thomas Moraine <thomas.moraine@vates.tech>
2025-02-07 12:44:24 +01:00
Sebastian CZECH
90188726e3 feat(lite/release): add changelog to GitHub release description (#8265) 2025-02-07 11:18:09 +01:00
Sebastian CZECH
564a2af879 feat(web-core): migrate UiResource(s) to VtsResource(s) (#8315) 2025-02-06 11:08:37 +01:00
b-Nollet
13488b41b1 feat(lite): 0.7.1 (#8310) 2025-02-04 16:37:53 +01:00
b-Nollet
3e335a3741 feat: release 5.103.1 (#8309) 2025-02-04 16:09:19 +01:00
b-Nollet
ac015305d7 feat: technical release (#8307)
* feat(@xen-orchestra/web-core): 0.13.0

* feat(@xen-orchestra/web): 0.9.0

* feat(xo-server): 5.170.0

* chore(CHANGELOG): update next
2025-02-04 14:48:46 +01:00
Mathieu
936bdaac45 fix(web-core): fix UiStackedBar percent calculation (#8306)
Introduced by 14da422
2025-02-04 13:30:46 +01:00
OlivierFL
0960f8d8d3 fix(lite/host): improve console retrieval (#8305) 2025-02-04 10:17:18 +01:00
Mathieu
6ae05398d7 feat(XO6/dashboard): display size used by replications (#8300) 2025-02-04 10:15:11 +01:00
Stephane
e1b1fcd948 fix(xo-server): fix calculate size replication in sr (#8302)
Introduced by 90a33ea
2025-02-03 17:35:57 +01:00
Florent BEAUCHAMP
7579b3359c docs(async-each): improve the js doc (#8293) 2025-02-03 13:00:25 +01:00
Thomas Moraine
dfbdcd23f2 docs: update XO logo & require Debian 12 (#8263)
Signed-off-by: Thomas Moraine <thomas.moraine@vates.tech>
2025-02-03 12:48:49 +01:00
Thomas Moraine
683f5f61d3 docs: remove references to XOSAN (legacy) (#8299)
Since XOSAN is now legacy and XOSTOR has taken its place, we are removing XOSAN from the Xen Orchestra doc.

Links to XOSAN docs are replaced with links to XOSTOR (from the XCP-ng doc).

Signed-off-by: Thomas Moraine <thomas.moraine@vates.tech>
2025-02-03 09:28:53 +01:00
b-Nollet
c8c9f77d45 feat(xo-server): remember server's pool name and description (#8206)
Remember server's pool name and description, and display the pool name as server default label. The server label can be deleted (since 81e7e07) to get back to the default pool name value.

We did multiple commits to keep the original changes around, but I would advise not to review by commit.

XO-437
2025-02-03 08:41:38 +01:00
Mathieu
7aa51f20c9 fix(xo-server/VM): do not try to resize vdi if vdi.size is undefined (#8291) 2025-02-03 08:35:13 +01:00
b-Nollet
494ea4509f feat(lite): 0.7.0 (#8290) 2025-01-30 16:39:46 +01:00
b-Nollet
4296ca7e9b feat: release 5.103.0 (#8289) 2025-01-30 13:58:52 +01:00
b-Nollet
437e438672 feat: technical release (#8288) 2025-01-30 11:54:42 +01:00
Julien Fontanet
81e7e07312 fix(xo-server,xo-web): allow deleting server's label 2025-01-30 10:27:37 +01:00
Mathieu
05dd9238b8 fix(xo-server/test): use mock.timers for getFromAsyncCache test (#8279)
introduced by 1eeff13

use mock.timers to avoid false negative.
https://nodejs.org/dist/v23.6.1/docs/api/test.html#timers
2025-01-30 08:21:56 +01:00
b-Nollet
aae8b6b1d8 fix(@xen-orchestra/backups): avoid undefined target (#8275) 2025-01-29 17:43:26 +01:00
Sebastian CZECH
097aa5a584 feat(xo-6): add host network view (#8198) 2025-01-29 16:29:41 +01:00
Nathanaël
062dd7561f feat(web-stack/i18n): translations update from Weblate (#8178) 2025-01-29 14:41:03 +01:00
Joris K
2fe2ef49db fix(xo-lite,xo-6): issue with status in pool network table (#8284)
Fix issue with how status is calculated in pool table
2025-01-29 12:23:35 +01:00
Joris K
7862952cf6 fix(xo-lite): issue with wording in host pif table (#8285) 2025-01-29 12:18:02 +01:00
Sebastian CZECH
76c3f7472f feat(xo-6): add pool network view (#8182) 2025-01-29 09:54:06 +01:00
Thomas Moraine
35e8af6313 docs(advanced): disk health monitoring (#8264)
Disk health monitoring from XO was available since XO v5.87.
It's now documented as part of the Management -> Advanced features section.
2025-01-29 09:53:01 +01:00
Joris K
3e69d4c84b feat(xo-lite/host): add host network tab and pif table / status component … (#8180) 2025-01-28 16:22:58 +01:00
Stephane
7e3b7367f1 fix(backups): backup worker inspect failed: address already in use (#8197) 2025-01-28 15:50:45 +01:00
Pierre Donias
42b32eb079 feat: technical release (#8274) 2025-01-28 11:43:52 +01:00
Florent BEAUCHAMP
bf874bce7c fix(xo-server/getAllUnhealthyVdiChainsLength): better handling of vdi not in cache (#8273) 2025-01-28 10:32:22 +01:00
Florent BEAUCHAMP
989b3888ee feat(backups): don't use checksum if not needed (#8270)
* feat(backups): don't use checksum if not needed

encrypted backups are already authenticated, this guarantee that
a readble file has not been modified
thus, no need to compute a relatively slow hash is encryption is already done
2025-01-28 10:30:15 +01:00
MlssFrncJrg
b519e25601 fix(xo-web): in storage creation, display error when selecting SR type (#8250) 2025-01-28 10:02:03 +01:00
Florent BEAUCHAMP
2677b8ca38 fix(backups): weekly ltr retention last week of year (#8269)
the year computation use the locale year computation, whereas the week 
was using the iso week computation
2025-01-28 08:19:16 +01:00
Florent BEAUCHAMP
5024bd765b test: fix ci (#8271)
* test(xo-server/asynccache): more time to let the test run
* test(vhd-lib/openvhd): concurrency on openvhd tests
2025-01-27 16:27:52 +01:00
Joris K
6761274a16 feat(xo-lite/network): implementation of network tab and add network/pif store (#8147) 2025-01-27 16:21:46 +01:00
Thomas Moraine
512af62f7f docs(backups): long term retention (GFS) (#8223) 2025-01-27 15:38:05 +01:00
Thomas Moraine
4123ae731f docs(backups): encryption algorithms (#8266)
Explain how backups are encrypted by Xen Orchestra,
what each encryption algorithm does,
and how it works with Amazon S3
2025-01-27 11:52:39 +01:00
Stephane
90a33ead6d feat(xo-server): calculate size replication in sr (#8262) 2025-01-27 11:49:37 +01:00
Florent BEAUCHAMP
a49864abfb fix(V2V/Vsan): better handling of multiple VSAN (#8243) 2025-01-24 11:34:50 +01:00
Sebastian CZECH
1f4ec8d0e1 feat(xo-6): add console fullscreen action (#8238) 2025-01-23 15:00:22 +01:00
Mathieu
3e615f725b fix(xapi): VDI_destroyCloudInitConfig wait 5 minutes before removing the VDI (#8247) 2025-01-23 13:09:43 +01:00
Mathieu
9af58185cf fix(xo-server, xo-web): fix install patches and RPU on XS8 (#8241) 2025-01-22 15:58:18 +01:00
Sebastian CZECH
2b63829e91 feat(web-core): inverse the logic of border props in MenuList.vue (#8246) 2025-01-22 15:34:56 +01:00
Sebastian CZECH
300bb18a64 feat(web-core): focus on console (#8235) 2025-01-22 15:14:09 +01:00
Sebastian CZECH
42f205e473 feat(xo-6): switch to language based on xo5 cookie (#8242) 2025-01-22 14:55:01 +01:00
Thierry Goettelmann
fe5276217f fix(web-core): useRouteQuery composable type issue (#8261) 2025-01-22 09:04:59 +01:00
Julien Fontanet
1765600437 fix(xo-server-audit): ignore host.getIpmiSensors
Introduced by e30f28907
2025-01-21 09:07:09 +01:00
Stephane
f0680df1e1 feat(backups): add encryption chacha20-poly1305, allow file larger than 64GB on encrypted remote (#8237)
This will also incite users to create new remote with the chacha20-poly1305 instead of aes-256-gcm that will continue to work on exusting remote
2025-01-20 20:10:34 +01:00
Sebastian CZECH
6d34cf67fb feat(web-core): move chart lib from xo-lite to web-core (#8248) 2025-01-20 15:15:46 +01:00
Sebastian CZECH
9c97ac903f feat(xo-6): add Ctrl+Alt+Del (#8239)
functionality to console
2025-01-20 14:56:46 +01:00
OlivierFL
a96d5e64de docs(xo-core): update guidelines (#8194) 2025-01-20 11:44:49 +01:00
b-Nollet
4744071098 fix(usage-report): avoid report failure when previous stats are invalid (#8240) 2025-01-20 11:43:02 +01:00
b-Nollet
dc9dbd9018 fix(xo-web): display mirror backup transfer size (#8224) 2025-01-20 11:40:31 +01:00
b-Nollet
6405eeb1b5 fix(xo-server): throw when remote uses encryption without data blocks (#8244) 2025-01-20 11:38:42 +01:00
Stephane
7c666d1156 fix(backups): fix metadata.isVhdDifferencing key computation (#8216)
This PR fix metadata.isVhdDifferencing where an object was used instead of a string to set the filename.
2025-01-20 10:55:56 +01:00
Sebastian CZECH
7ca6829c27 feat(web-core): standardize console component between xo-lite and xo-6 (#8245) 2025-01-20 10:25:30 +01:00
Florent BEAUCHAMP
97cd50af44 test(backups): fix parallel test (#8257) 2025-01-20 10:16:43 +01:00
David Johnston
5bfd462616 feat(web-stack): add Spanish translation (#8220) 2025-01-20 09:03:41 +01:00
Florent BEAUCHAMP
2b964576f2 test(vhd-lib): fix ci (#8255)
Assertion messages can now contain extra info since Node 20.18.1
2025-01-17 11:50:59 +01:00
MlssFrncJrg
d044dda59a fix(xo-web/SelectTag): list SR tags (#8251)
See https://xcp-ng.org/forum/topic/9953
2025-01-16 15:22:42 +01:00
Julien Fontanet
11a4ceddce chore: update dev deps 2025-01-15 14:46:20 +01:00
Thierry Goettelmann
b97268727c feat(web-core,lite,xo6): add useDisabled composable and replace DisabledContext usage (#8133) 2025-01-13 16:30:24 +01:00
Sebastian CZECH
3a21290fde feat(web-core): add loading state on console (#8226) 2025-01-09 14:43:09 +01:00
Julien Fontanet
299a109eb6 fix(CHANGELOG): fix date
Introduced by 4235e9816
2025-01-09 14:28:28 +01:00
Julien Fontanet
4235e98166 fix(CHANGELOG): add missing date
Introduced by 281ccbb8b
2025-01-09 12:03:04 +01:00
Julien Fontanet
281ccbb8ba feat: release 5.102.1 2025-01-09 11:42:32 +01:00
Julien Fontanet
7053fc4a08 feat(xo-server-backup-reports): 1.4.4 2025-01-09 10:31:12 +01:00
b-Nollet
cd2f74cd63 fix(xo-server-backup-reports): fix undefined function in partial (#8229)
In some failure cases, backup reports were not sent because of an error during handlebars compilation.
The `formatDate` function was incorrectly passed from partial to partial causing the `executeFunction` helper to execute `undefined` as a function (the `vmFailure` helper used default `formatDate=./formatDate` instead of `formatDate=../formatDate`, the `..` being necessary because of the `#each` loop)


Introduced by aa9c49ce6a
2025-01-08 17:25:01 +01:00
Thomas Moraine
6d836df6bf docs(xoa): NTP synchronization with systemd-timesyncd (#8217)
On recent versions of Xen Orchestra, we switched to systemd-timesyncd for NTP management.
XOA documentation is updated to reflect this change.
2025-01-08 09:07:50 +01:00
361 changed files with 12640 additions and 5042 deletions

View File

@@ -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
View File

@@ -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/

View File

@@ -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 } = {}) {

View File

@@ -1,3 +0,0 @@
.DS_Store
.vscode/
node_modules/

1
@vates/fatfs/.npmignore Symbolic link
View File

@@ -0,0 +1 @@
../../scripts/npmignore

View File

@@ -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"
}
}

View File

@@ -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.

View File

@@ -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

View File

@@ -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",

View 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)`

View File

@@ -0,0 +1 @@
../../scripts/npmignore

View File

@@ -0,0 +1,89 @@
<!-- DO NOT EDIT MANUALLY, THIS FILE HAS BEEN GENERATED -->
# @vates/generator-toolbox
[![Package Version](https://badgen.net/npm/v/@vates/generator-toolbox)](https://npmjs.org/package/@vates/generator-toolbox) ![License](https://badgen.net/npm/license/@vates/generator-toolbox) [![PackagePhobia](https://badgen.net/bundlephobia/minzip/@vates/generator-toolbox)](https://bundlephobia.com/result?p=@vates/generator-toolbox) [![Node compatibility](https://badgen.net/npm/node/@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)

View 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)

View 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"
}
}

View File

@@ -0,0 +1,3 @@
export { Synchronized } from './synchronized.mjs'
export { Throttle } from './throttle.mjs'
export { Timeout } from './timeout.mjs'

View 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
}
}

View 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'))
})
})

View 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)
}
}
}

View 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))
})
})

View 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
}
}

View 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')
})
})

View 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"]
}

View File

@@ -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
}

View File

@@ -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
View File

@@ -0,0 +1 @@
../../scripts/npmignore

View 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
View 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
View 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]

View 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

File diff suppressed because it is too large Load Diff

202
@vates/types/src/xo.mts Normal file
View 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

View File

@@ -0,0 +1,12 @@
{
"compilerOptions": {
"outDir": "./dist",
"declaration": true,
"strict": true,
"module": "ESNext",
"target": "ES2022",
"skipLibCheck": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}

View File

@@ -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",

View File

@@ -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,

View File

@@ -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`, '')

View File

@@ -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
}
}

View File

@@ -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',

View File

@@ -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

View File

@@ -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": {

View File

@@ -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)

View File

@@ -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",

View File

@@ -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(

View File

@@ -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",

View File

@@ -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)

View File

@@ -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,

View File

@@ -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)}`)

View File

@@ -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'

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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"

View File

@@ -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>

View File

@@ -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>

View File

@@ -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

View File

@@ -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}`,

View File

@@ -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>

View File

@@ -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>

View 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>

View File

@@ -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'

View File

@@ -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 />

View File

@@ -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 />

View File

@@ -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>

View File

@@ -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" />

View File

@@ -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()

View File

@@ -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()

View File

@@ -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()

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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()

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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}`),

View File

@@ -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

View File

@@ -59,7 +59,6 @@
"descending": "sestupně",
"description": "Popis",
"dhcp": "DHCP",
"disabled": "Zakázáno",
"display": "Zobrazení",
"dns": "DNS",

View File

@@ -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",

View File

@@ -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",

View 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"
}

View File

@@ -58,7 +58,6 @@
"descending": "نزولی",
"description": "توصیف",
"dhcp": "DHCP",
"disabled": "غیر فعال",
"display": "نمایش",
"dns": "DNS",

View File

@@ -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",

View File

@@ -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)
})

View 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 }, {})
})

View 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)
})

View File

@@ -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 }, {})

View File

@@ -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'

View File

@@ -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>

View File

@@ -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>

View File

@@ -9,9 +9,9 @@
<template #buttons>
<ModalDeclineButton />
<ModalApproveButton>Migrate 3 VMs</UiButton>
<ModalApproveButton>Migrate 3 VMs</ModalApproveButton>
</template>
</ConfirmModalLayout>
</FormModalLayout>
</UiModal>
```

View File

@@ -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>

View File

@@ -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>
```

View File

@@ -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