Compare commits

..

193 Commits

Author SHA1 Message Date
Florent BEAUCHAMP
6700ce0365 feat(xen-api): transfer the trace context to json rpc calls 2025-03-14 07:40:16 +00:00
Florent BEAUCHAMP
7645b365e9 try to configure jeager 2025-03-13 16:39:14 +00:00
Florent BEAUCHAMP
76d5c10753 fix:use the right tracer in json rpc 2025-03-13 15:47:13 +00:00
Florent BEAUCHAMP
57c1673f98 feat(xo-server): enable opentelemetry 2025-03-13 15:42:56 +00:00
Thierry Goettelmann
7fd4528eae feat(web-core): recreate UiDropdown component from DS (#8418) 2025-03-13 12:09:39 +01:00
Thierry Goettelmann
ac2f4e9f32 chore(web-stack): update deps (#8428) 2025-03-13 11:54:36 +01:00
Mathieu
1d4b04c777 feat(@xen-orchestra/rest-api): expose get vbd and get vbds (#8404) 2025-03-13 09:41:52 +01:00
Florent BEAUCHAMP
e16f9bfa91 fix(v2v): assert error on import delta from esxi < 7.5 (#8422)
it happens when the source disk is not aligned with the vhd block size ( 2MB)
this PR will read more data into the grain directory / grain tables, but
this data won't be used since we use the virtual size to compute which
grain to read

from ticket 33018
2025-03-12 17:47:11 +01:00
Pierre Donias
9c27b53dfd fix(netbox/name-dedup): perform a case-insensitive name comparison (#8413)
Netbox doesn't allow 2 VM names to be equal within the same cluster even if they
don't have the same case.
2025-03-11 17:03:20 +01:00
Thomas Moraine
763e5f082d docs(backups): Microsoft ReFS is unsupported (#8423)
Signed-off-by: Thomas Moraine <thomas.moraine@vates.tech>
2025-03-11 16:16:09 +01:00
Pierre Donias
8a0604c274 feat(netbox): support Netbox v4.2 (#8417)
Fixes #8280
Fixes #7645
See Zammad#34699
See https://xcp-ng.org/forum/topic/10236/netbox-version-4-2-1-not-supported
See https://github.com/netbox-community/netbox/releases/tag/v4.2.0
2025-03-11 15:35:53 +01:00
Mathieu
ca84af4eda feat(@xen-orchestra/rest-api): migrate vms/:id/actions/start (#8379) 2025-03-11 12:50:42 +01:00
Mathieu
57056b2298 Add XoSr type + expose /rest/v0/srs and /rest/v0/srs/:id (#8419)
* feat(@vates/types): add XoSr type

* feat(@xen-orchestra/rest-api): expose get srs and get sr
2025-03-11 11:18:38 +01:00
Florent BEAUCHAMP
517a0c7b6b fix(backups): handle case when a new disk is added to a replicated VM (#8400)
* fix(backups): handle case when a new disk is added to a replicated VM

* changelog

* changelog
2025-03-11 10:31:56 +01:00
Mathieu
0951d5606d feat(@xen-orchestra/rest-api): mutualize code for better qol (#8401)
* feat(@xen-orchestra/rest-api): mutualize code for better qol

* fix after rebase

* use queries instead of query(s)
2025-03-11 09:16:37 +01:00
Thomas Moraine
d74828017a doc(XO): Add Amazon S3 to the list of supported remotes (#8407)
doc(XO): Add Amazon S3 to list of supported remotes

Amazon S3 remotes have been supported for a while,
but there was no section mentioning it in the Backups → Remotes doc.
This is now fixed

Signed-off-by: Thomas Moraine <thomas.moraine@vates.tech>
2025-03-11 09:00:31 +01:00
Pierre Donias
1bd7bd6661 feat(xo-web,xo-server/createVm): ability to assign ACLs to VM during creation (#8412)
Fixes #6996
2025-03-10 17:10:46 +01:00
Mathieu
6816d6e759 fix(CHANGELOG.unreleased.md): fix extra space (#8420) 2025-03-10 11:29:34 +01:00
Pierre Donias
8fd8e3dff5 fix(netbox): fetch Netbox version even if version check is disabled (#8416)
See Zammad#34699
2025-03-10 09:52:59 +01:00
Bastien Nollet
37fbb7edb8 docs(perf-alert): functional description (#8414) 2025-03-07 16:04:53 +01:00
Bastien Nollet
9e7e4298ab fix(perf-alert): preventing alerts sent endlessly every minute (#8408)
Introduced by b1ce62f
2025-03-07 15:38:58 +01:00
Mathieu
f310575d0c fix(xo-server/createVm): fix OTHER_OPERATION_IN_PROGRESS (#8399)
Introduced by 04dd9e9
2025-03-07 15:27:57 +01:00
Julien Fontanet
5a501d9ee2 fix(xo-server): clarify session duration validity (#8411)
Related to zammad#35588
2025-03-07 14:04:15 +01:00
mathieuRA
37444afa12 fix(xo-server/rest-api): on VM import SR ID is no longer ignored 2025-03-07 12:10:30 +01:00
mathieuRA
31b049963f fix(@xen-orchestra/xapi/VM): throws a nice error when migrating VM without SR or default SR 2025-03-07 12:10:30 +01:00
mathieuRA
76e23ecdcc feat(@xen-orchestra/rest-api): expose hosts/:id/stats 2025-03-06 16:56:38 +01:00
mathieuRA
93706d70c9 feat(@xen-orchestra/rest-api): expose get hosts and get host 2025-03-06 16:56:38 +01:00
mathieuRA
a5866bbb6a feat(@vates/types): add XoHost type 2025-03-06 16:56:38 +01:00
Mathieu
034d9b5eca feat(@xen-orchestra/rest-api): expose VM stats (#8359) 2025-03-06 15:06:28 +01:00
Mathieu
a415c452ef fix(@xen-orchestra/rest-api): fix null values not displayed as nullable (#8406) 2025-03-06 09:23:51 +01:00
OlivierFL
adc5bea153 feat: release 5.104.1 (#8405) 2025-03-04 16:49:47 +01:00
OlivierFL
600d8d9e85 feat: technical release (#8403) 2025-03-04 15:37:15 +01:00
Florent BEAUCHAMP
82f0894fec fix(xapi): add missing changelog entry (#8397) 2025-03-04 13:19:52 +01:00
Florent BEAUCHAMP
90f8f9cff4 feat(vhd-lib): handle broken vhd directory named as aliases (#8292) 2025-03-04 09:55:04 +01:00
Florent BEAUCHAMP
cf0331391b fix(backups): handle undefined remote name in restore description (#8367) 2025-03-04 08:39:11 +01:00
Florent BEAUCHAMP
2a2c966126 fix(backups): disable CBT when CBT is unusable (#8313) 2025-03-03 11:41:39 +01:00
Julien Fontanet
39613ff2fa feat(xo-server/vdi.migrate): returns the new UUID
See https://team.vates.fr/vates/pl/169jwdqkeiys8boftay745iony
2025-02-28 11:18:39 +01:00
Sebastian CZECH
9033577406 feat(xo-6): add sidebar to pool networks view (#8286) 2025-02-28 10:18:46 +01:00
OlivierFL
6125348529 feat(lite): 0.8.0 (#8392) 2025-02-27 14:51:44 +01:00
OlivierFL
b59125cf5a feat: release 5.104.0 (#8391) 2025-02-27 14:26:02 +01:00
OlivierFL
73c9f74a45 feat: technical release (#8389) 2025-02-27 11:48:59 +01:00
OlivierFL
6a21e5525a feat(xo-core): update UiInput and UiTextArea components (#8349) 2025-02-27 11:03:55 +01:00
Sebastian CZECH
e0338c33d7 fix(xo-server): add pifs bond master of (#8368) 2025-02-27 10:49:59 +01:00
Joris K
e905817ea5 fix(xo-lite): add changelog (#8386) 2025-02-27 10:49:13 +01:00
Thomas Moraine
b0ab26b77e docs(backups): Microsoft Data Deduplication and Logical Disk Manager are unsupported (#8382)
Also, replace the screenshot of the file restore feature with an example that uses Linux instead of a Microsoft/NTFS resource

Signed-off-by: Thomas Moraine <thomas.moraine@vates.tech>
2025-02-27 10:32:38 +01:00
Pierre Donias
82daa3550f fix(xo-web/tab-disks): wrong PropTypes on AttachDisk's vbds (#8387) 2025-02-27 10:27:18 +01:00
Pierre Donias
db4d394449 feat(xo-web/vm/disks): allow Self Service users to attach disks to their VMs (#8384)
See Zammad#30630
2025-02-27 10:19:51 +01:00
Joris K
8063f438d9 feat(xo-lite/host): display pif information in side panel / add pif metrics store (#8186) 2025-02-27 09:33:05 +01:00
OlivierFL
b3d66497b9 feat: technical release (#8383) 2025-02-26 16:34:07 +01:00
Mathieu
e567a3b358 feat(xo-server/rest-api): expose vms/hosts stats (#8378)
`GET /rest/v0/vms/f26eb0a5-1d91-4682-ae58-96df405a3af6/stats`
`GET /rest/v0/hosts/f26eb0a5-1d91-4682-ae58-96df405a3af6/stats`
2025-02-26 12:01:03 +01:00
Mathieu
468732cdba fix(xo-server/rest-api): do not show route twice (#8377) 2025-02-26 11:55:55 +01:00
MlssFrncJrg
13bda9812e feat(xo-server/rest-api): ability to update a user (#8343) 2025-02-26 10:03:29 +01:00
OlivierFL
ff8a020fa2 feat(web-stack): update typography (#8320) 2025-02-26 09:30:44 +01:00
OlivierFL
d1c65756be feat(web-stack/i18n): merge translation files into single file (#8380) 2025-02-26 09:00:18 +01:00
Nathanaël
905e3cc943 feat(web-stack/i18n): update translations (#8294) 2025-02-25 17:57:35 +01:00
Joris K
5a21bdfe10 feat(xo-lite/network): add side panel informations and some trad (#8150) 2025-02-25 16:16:30 +01:00
Dan Pollak
a7446ae4af fix(xo-server-audit): ignore additional API calls (#8353) 2025-02-25 15:58:46 +01:00
Julien Fontanet
d46c871b06 fix(xo-server/joinPool): remove useless and bogus obfuscation
Username was obfuscated instead of password.

Obfuscation is now properly done in `xen-api`.
2025-02-25 13:44:14 +01:00
Julien Fontanet
7cc89012d7 fix(xen-api): obfuscate password for pool.join{,_force}
Fixes zammad#35148
2025-02-25 13:44:14 +01:00
Julien Fontanet
bd8a1b25ed fix(xo-cli): timeouts with legacy JSON-RPC API
Fixes zammad#34473
2025-02-25 10:30:01 +01:00
OlivierFL
f18b010588 feat(web-stack): update "info" and "brand" colors usages (#8345) 2025-02-24 16:30:18 +01:00
Mathieu
ac2ff9b38d fix(@vates/types): add missing VM-template in XapiXoRecord (#8376)
Introduced by 0ef95d9
2025-02-24 15:54:19 +01:00
MlssFrncJrg
1a3cd3e2b9 feat(xo-server/rest-api): ability to delete user by its ID (#8283) 2025-02-24 14:46:26 +01:00
OlivierFL
f25c67d5a8 feat: technical release (#8375) 2025-02-24 10:48:54 +01:00
Pierre Donias
821c25f864 fix(generator-toolbox): normalize (#8374) 2025-02-24 10:12:19 +01:00
Mathieu
5910a47780 fix(@xen-orchestra/rest-api): rename example files to not be ignored by npm (#8373)
Introduced by 780e0bb

`.npmignore` ignores all `examples/` folders and all `*.example.*` files
Rename Open API examples as `*.oa-example.mts`
2025-02-24 09:51:05 +01:00
OlivierFL
749f063dc6 fix: bump versions of packages with wrong dependencies (#8371)
Introduced by 4eed730a09

Due to an issue with bump-pkg script, some packages were previously published on
NPM before their dependencies' versions were updated. This commit simply bumps
the versions of those packages to publish the correct list of dependencies.
2025-02-21 17:04:25 +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
500 changed files with 19180 additions and 7852 deletions

View File

@@ -192,18 +192,14 @@ module.exports = {
// Specific rules for XO i18n-related files
{
files: [
'@xen-orchestra/lite/**/*.{vue,ts,json}',
'@xen-orchestra/web/**/*.{vue,ts,json}',
'@xen-orchestra/lite/**/*.{vue,ts}',
'@xen-orchestra/web/**/*.{vue,ts}',
'@xen-orchestra/web-core/**/*.{vue,ts,json}',
],
extends: ['plugin:@intlify/vue-i18n/base'],
settings: {
'vue-i18n': {
localeDir: [
'@xen-orchestra/lite/src/locales/*.json',
'@xen-orchestra/web/src/locales/*.json',
'@xen-orchestra/web-core/lib/locales/*.json',
],
localeDir: ['@xen-orchestra/web-core/lib/locales/*.json'],
messageSyntaxVersion: '^9.9.0',
},
},
@@ -227,7 +223,10 @@ 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', 'sv'] },
],
},
},
// 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,12 +19,12 @@
},
"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",
"promise-toolbox": "^0.21.0",
"vhd-lib": "^4.11.2"
"vhd-lib": "^4.11.3"
},
"bin": {
"xo-fuse-vhd": "./cli.mjs"

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,34 @@
{
"name": "@vates/generator-toolbox",
"version": "1.0.1",
"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",
"postversion": "npm publish --access public",
"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

@@ -24,7 +24,7 @@
"@xen-orchestra/async-map": "^0.1.2",
"@xen-orchestra/log": "^0.7.1",
"promise-toolbox": "^0.21.0",
"xen-api": "^4.7.0"
"xen-api": "^4.7.1"
},
"devDependencies": {
"tap": "^18.7.0",

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'],
})

48
@vates/types/package.json Normal file
View File

@@ -0,0 +1,48 @@
{
"name": "@vates/types",
"private": false,
"version": "1.0.1",
"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"
},
"./lib/vates/*": {
"default": "./dist/lib/vates-*.mjs",
"type": "./dist/lib/vates-*.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"
}
}

698
@vates/types/src/common.mts Normal file
View File

@@ -0,0 +1,698 @@
declare const __brand: unique symbol
export type Branded<TBrand extends string, TType = string> = TType & { [__brand]: TBrand }
export const HOST_POWER_STATE = {
RUNNING: 'Running',
HALTED: 'Halted',
UNKNOWN: 'Unknown',
} as const
export type HOST_POWER_STATE = (typeof HOST_POWER_STATE)[keyof typeof HOST_POWER_STATE]
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]
// ----- XAPI Stats
type XapiStatsResponse<T> = {
endTimestamp: number
interval: number
stats: T
}
export type XapiStatsGranularity = 'seconds' | 'minutes' | 'hours' | 'days'
export type XapiHostStats = XapiStatsResponse<{
cpus: Record<string, number[]>
ioThroughput: {
r: Record<string, number[]>
w: Record<string, number[]>
}
iops: {
r: Record<string, number[]>
w: Record<string, number[]>
}
iowait: Record<string, number[]>
latency: {
r: Record<string, number[]>
w: Record<string, number[]>
}
load: number[]
memory: number[]
memoryFree: number[]
pifs: {
rx: Record<string, number[]>
tx: Record<string, number[]>
}
}>
export type XapiVmStats = XapiStatsResponse<{
cpus: Record<string, number[]>
iops: {
r: Record<string, number[]>
w: Record<string, number[]>
}
memory: number[]
memoryFree?: number[]
vifs: {
rx: Record<string, number[]>
tx: Record<string, number[]>
}
xvds: {
w: Record<string, number[]>
r: Record<string, number[]>
}
}>

View File

@@ -0,0 +1,3 @@
export * from './common.mjs'
export * from './xen-api.mjs'
export * from './xo.mjs'

View File

@@ -0,0 +1,7 @@
import { Branded } from '../common.mjs'
export type Task = {
id: Branded<'task'>
run: <T>(fn: () => T) => Promise<T>
}

1337
@vates/types/src/xen-api.mts Normal file

File diff suppressed because it is too large Load Diff

349
@vates/types/src/xo.mts Normal file
View File

@@ -0,0 +1,349 @@
// Types based on xapi-object-to-xo
import type {
Branded,
DOMAIN_TYPE,
HOST_ALLOWED_OPERATIONS,
HOST_POWER_STATE,
STORAGE_OPERATIONS,
VM_OPERATIONS,
VM_POWER_STATE,
} from './common.mjs'
type BaseXapiXo = {
$pool: XoPool['id']
/**
* @deprecated use $pool instead
*/
$poolId: XoPool['id']
_xapiRef: string
uuid: string
}
type BaseXoVm = BaseXapiXo & {
$VBDs: XoVbd['id'][]
$VGPUs: XoVgpu['id'][]
$container: XoPool['id'] | XoHost['id']
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 = BaseXapiXo & {
$PBDs: XoPbd['id'][]
$PCIs: XoPci['id'][]
$PGPUs: XoPgpu['id'][]
$PIFs: XoPif['id'][]
PCIs: XoPci['id'][]
PGPUs: XoPgpu['id'][]
PIFs: XoPif['id'][]
/**
* @deprecated use cpus instead
*/
CPUs: Record<string, string>
address?: string
agentStartTime: null | number
bios_string: Record<string, string>
build: string
certificates?: {
fingerprint: string
notAfter: number
}
chipset_info: {
iommu?: boolean
}
controlDomain?: XoVm['id']
cpus: {
cores?: null | number
sockets?: null | number
}
current_operations: Record<string, HOST_ALLOWED_OPERATIONS>
enabled: boolean
hostname?: string
hvmCapable: boolean
id: Branded<'host'>
iscsiIqn: string
license_expiry: null | number
license_params: Record<string, string>
license_server: Record<string, string>
logging?: Record<string, string>
memory: {
size: number
/**
* @deprecated
*/
total?: number
usage: number
}
multipathing: boolean
name_description: string
name_label: string
otherConfig: Record<string, string>
/**
* @deprecated
*/
patches: XoHostPatch['id'][]
power_state: HOST_POWER_STATE
powerOnMode: string
productBrand: string
rebootRequired: boolean
residentVms: XoVm['id'][]
startTime: null | number
supplementalPacks:
| {
author: string
description: string
guidance: string
hosts: XoHost['id'][]
name: string
size: number
version: string
vdi: XoVdi['id']
}[]
| {
author: string
description: string
name: string
version: string
}[]
tags: string[]
type: 'host'
version: string
zstdSupported: boolean
}
export type XoHostPatch = BaseXapiXo & {
id: Branded<'host_patch'>
type: 'host_patch'
}
export type XoPbd = BaseXapiXo & {
id: Branded<'PBD'>
type: 'PBD'
}
export type XoPci = BaseXapiXo & {
id: Branded<'PCI'>
type: 'PCI'
}
export type XoPgpu = BaseXapiXo & {
id: Branded<'PGPU'>
type: 'PGPU'
}
export type XoPif = BaseXapiXo & {
id: Branded<'PIF'>
type: 'PIF'
}
export type XoPool = BaseXapiXo & {
id: Branded<'pool'>
type: 'pool'
}
export type XoSr = BaseXapiXo & {
$PBDs: XoPbd['id'][]
$container: XoPool['id'] | XoHost['id']
VDIs: XoVdi['id'][]
allocationStrategy: 'thin' | 'thick' | 'unknown'
content_type?: string
current_operations: Record<string, STORAGE_OPERATIONS>
id: Branded<'SR'>
inMaintenanceMode: boolean
name_description: string
name_label: string
other_config: Record<string, string>
physical_usage: number | null
shared: boolean
size: number | null
sm_config: Record<string, string>
SR_type?: string
tags: string[]
type: 'SR'
usage: number | null
}
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 = BaseXapiXo & {
attached: boolean
bootable: boolean
device: string | null
id: Branded<'VBD'>
is_cd_drive: boolean
position?: string
read_only: boolean
type: 'VBD'
VDI: XoVdi['id']
VM: XoVm['id']
}
export type XoVdi = BaseXapiXo & {
id: Branded<'VDI'>
type: 'VDI'
}
export type XoVgpu = BaseXapiXo & {
id: Branded<'VGPU'>
type: 'VGPU'
}
export type XoVif = BaseXapiXo & {
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 = BaseXapiXo & {
id: Branded<'VTPM'>
type: 'VTPM'
}
export type XapiXoRecord =
| XoHost
| XoPool
| XoSr
| XoVbd
| XoVdi
| XoVgpu
| XoVif
| XoVm
| XoVmController
| XoVmSnapshot
| XoVmTemplate
| 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.3",
"@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

@@ -257,7 +257,14 @@ export class ImportVmBackup {
: await importIncrementalVm(backup, await xapi.getRecord('SR', srRef), {
newMacAddresses,
})
const remoteName = adapter._handler._remote.name
let desc = `Restored on ${formatFilenameDate(+new Date())}`
if (remoteName !== undefined) {
desc += ` from ${remoteName}`
}
if (metadata.vm.name_description) {
desc += ` - ${metadata.vm.name_description}`
}
await Promise.all([
xapi.call('VM.add_tags', vmRef, 'restored from backup'),
xapi.call(
@@ -265,13 +272,7 @@ export class ImportVmBackup {
vmRef,
`${metadata.vm.name_label} (${formatFilenameDate(metadata.timestamp)})`
),
xapi.call(
'VM.set_name_description',
vmRef,
`Restored on ${formatFilenameDate(+new Date())} from ${adapter._handler._remote.name} -
${metadata.vm.name_description}
`
),
xapi.call('VM.set_name_description', vmRef, desc),
])
return {

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

@@ -129,10 +129,29 @@ export async function checkAliases(
logWarn('missing target of alias', { alias })
if (remove) {
logInfo('removing alias and non VHD target', { alias, target })
await handler.unlink(target)
await handler.unlink(alias)
}
continue
}
if (err.code === 'EISDIR') {
logWarn('alias is a vhd directory', { alias })
if (remove) {
logInfo('removing vhd directory named as alias', { alias, target })
await VhdAbstract.unlink(handler, alias)
}
continue
}
logWarn('unhandled error while checking alias', { alias, err })
continue
}
if (target === '') {
logWarn('empty target for alias ', { alias })
if (remove) {
logInfo('removing alias and non VHD target', { alias, target })
await handler.unlink(alias)
}
continue
}
if (!isVhdFile(target)) {
@@ -575,7 +594,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

@@ -11,7 +11,6 @@ import { MixinXapiWriter } from './_MixinXapiWriter.mjs'
import { listReplicatedVms } from './_listReplicatedVms.mjs'
import { COPY_OF, setVmOtherConfig, BASE_DELTA_VDI } from '../../_otherConfig.mjs'
import assert from 'node:assert'
export class IncrementalXapiWriter extends MixinXapiWriter(AbstractIncrementalWriter) {
async checkBaseVdis(baseUuidToSrcVdi) {
const sr = this._sr
@@ -118,9 +117,10 @@ export class IncrementalXapiWriter extends MixinXapiWriter(AbstractIncrementalWr
const baseReplicatedTo = replicatedVdis.find(
replicatedVdi => replicatedVdi.other_config[COPY_OF] === vdi.other_config[BASE_DELTA_VDI]
)
assert.notStrictEqual(baseReplicatedTo, undefined)
// baseReplicatedTo can be undefined if a new disk is added and other are already replicated
vdi.baseVdi = baseReplicatedTo
} else {
// first replication of this disk
vdi.baseVdi = undefined
}
// ensure the VDI are created on the target SR

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.3",
"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",
@@ -48,8 +48,8 @@
"tar": "^6.1.15",
"uuid": "^9.0.0",
"value-matcher": "^0.2.0",
"vhd-lib": "^4.11.2",
"xen-api": "^4.7.0",
"vhd-lib": "^4.11.3",
"xen-api": "^4.7.1",
"yazl": "^2.5.1"
},
"devDependencies": {
@@ -59,7 +59,7 @@
"tmp": "^0.2.1"
},
"peerDependencies": {
"@xen-orchestra/xapi": "^7.10.0"
"@xen-orchestra/xapi": "^8.1.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

@@ -18,7 +18,7 @@
"preferGlobal": true,
"dependencies": {
"golike-defer": "^0.5.1",
"xen-api": "^4.7.0"
"xen-api": "^4.7.1"
},
"scripts": {
"postversion": "npm publish"

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,19 +17,19 @@
"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.3",
"@xen-orchestra/log": "^0.7.1",
"app-conf": "^3.0.0",
"chokidar": "^3.5.3",
"execa": "^5.0.0",
"ms": "^2.1.3",
"vhd-lib": "^4.11.2"
"vhd-lib": "^4.11.3"
},
"devDependencies": {
"rimraf": "^5.0.5",

View File

@@ -1,8 +1,26 @@
# ChangeLog
## **next**
## **0.8.0** (2025-02-27)
- [i18n] Add Swedish, update Czech and Spanish translations (contributions made by [@xiscoj](https://github.com/xiscoj), [@p-bo](https://github.com/p-bo) and [Jonas](https://translate.vates.tech/user/Jonas/)) (PR [#8294](https://github.com/vatesfr/xen-orchestra/pull/8294))
- [i18n] Merge XO Lite translations files into one file in web-core ([PR #8380](https://github.com/vatesfr/xen-orchestra/pull/8380))
- [Pool/Network]: Display networks and host internal networks information in side panel (PR [#8150](https://github.com/vatesfr/xen-orchestra/pull/8150))
- [Host/Network]: Display pifs information in side panel (PR [#8186](https://github.com/vatesfr/xen-orchestra/pull/8186))
## **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.8.0",
"type": "module",
"scripts": {
"dev": "GIT_HEAD=$(git rev-parse HEAD) vite",
@@ -14,31 +14,31 @@
"type-check": "vue-tsc --build --force tsconfig.type-check.json"
},
"devDependencies": {
"@csstools/postcss-global-data": "^2.1.1",
"@floating-ui/vue": "^1.1.5",
"@fortawesome/fontawesome-svg-core": "^6.5.1",
"@fortawesome/free-regular-svg-icons": "^6.5.1",
"@fortawesome/free-solid-svg-icons": "^6.5.1",
"@fortawesome/vue-fontawesome": "^3.0.5",
"@intlify/unplugin-vue-i18n": "^2.0.0",
"@novnc/novnc": "^1.4.0",
"@tsconfig/node18": "^18.2.2",
"@csstools/postcss-global-data": "^3.0.0",
"@floating-ui/vue": "^1.1.6",
"@fontsource/poppins": "^5.2.5",
"@fortawesome/fontawesome-svg-core": "^6.7.2",
"@fortawesome/free-regular-svg-icons": "^6.7.2",
"@fortawesome/free-solid-svg-icons": "^6.7.2",
"@fortawesome/vue-fontawesome": "^3.0.8",
"@intlify/unplugin-vue-i18n": "^6.0.3",
"@novnc/novnc": "~1.5.0",
"@tsconfig/node18": "^18.2.4",
"@types/d3-time-format": "^4.0.3",
"@types/file-saver": "^2.0.7",
"@types/lodash-es": "^4.17.12",
"@types/node": "^18.19.7",
"@vitejs/plugin-vue": "^5.1.4",
"@vue/tsconfig": "^0.5.1",
"@vueuse/core": "^10.7.1",
"@vueuse/math": "^10.7.1",
"@vueuse/shared": "^10.7.1",
"@xen-orchestra/web-core": "^0.10.0",
"@types/node": "^18.19.80",
"@vitejs/plugin-vue": "^5.2.1",
"@vue/tsconfig": "^0.7.0",
"@vueuse/core": "^13.0.0",
"@vueuse/math": "^13.0.0",
"@vueuse/shared": "^13.0.0",
"@xen-orchestra/web-core": "^0.16.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",
"highlight.js": "^11.11.1",
"human-format": "^1.2.1",
"iterable-backoff": "^0.1.0",
"json-rpc-2.0": "^1.7.0",
@@ -46,22 +46,21 @@
"limit-concurrency-decorator": "^0.6.0",
"lodash-es": "^4.17.21",
"make-error": "^1.3.6",
"marked": "^9.1.5",
"marked": "^15.0.7",
"minimist": "^1.2.8",
"npm-run-all": "^4.1.5",
"pinia": "^2.2.6",
"pinia": "^3.0.1",
"placement.js": "^1.0.0-beta.5",
"postcss": "^8.4.33",
"postcss": "^8.5.3",
"postcss-color-function": "^4.1.0",
"postcss-custom-media": "^10.0.2",
"postcss-nested": "^6.0.1",
"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",
"postcss-custom-media": "^11.0.5",
"postcss-nested": "^7.0.2",
"typescript": "~5.8.2",
"vite": "^6.2.1",
"vue": "~3.5.13",
"vue-i18n": "^11.1.2",
"vue-router": "^4.5.0",
"vue-tsc": "~2.2.8",
"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

@@ -1,14 +1,14 @@
<template>
<header class="app-header">
<UiIcon v-if="isMobile" ref="navigationTrigger" :icon="faBars" class="toggle-navigation" />
<UiIcon v-if="uiStore.isMobile" ref="navigationTrigger" :icon="faBars" class="toggle-navigation" />
<RouterLink :to="{ name: 'home' }">
<img v-if="isMobile" alt="XO Lite" src="../assets/logo.svg" />
<img v-if="uiStore.isMobile" alt="XO Lite" src="../assets/logo.svg" />
<TextLogo v-else />
</RouterLink>
<slot />
<div class="right">
<PoolOverrideWarning as-tooltip />
<XoaButton v-if="isDesktop" />
<XoaButton v-if="uiStore.isDesktop" />
<AccountMenu />
</div>
</header>
@@ -26,7 +26,6 @@ import { faBars } from '@fortawesome/free-solid-svg-icons'
import { storeToRefs } from 'pinia'
const uiStore = useUiStore()
const { isMobile, isDesktop } = storeToRefs(uiStore)
const navigationStore = useNavigationStore()
const { trigger: navigationTrigger } = storeToRefs(navigationStore)

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,6 +1,11 @@
<template>
<Transition name="slide">
<nav v-if="isDesktop || isOpen" ref="navElement" :class="{ collapsible: isMobile }" class="app-navigation">
<nav
v-if="uiStore.isDesktop || isOpen"
ref="navElement"
:class="{ collapsible: uiStore.isMobile }"
class="app-navigation"
>
<StoryMenu v-if="route.meta.hasStoryNav" />
<InfraPoolList v-else />
</nav>
@@ -20,7 +25,6 @@ import { useRoute } from 'vue-router'
const route = useRoute()
const uiStore = useUiStore()
const { isMobile, isDesktop } = storeToRefs(uiStore)
const navigationStore = useNavigationStore()
const { isOpen, trigger } = storeToRefs(navigationStore)
@@ -36,6 +40,7 @@ whenever(isOpen, () => {
},
{
ignore: [trigger],
controls: false,
}
)
})

View File

@@ -68,7 +68,7 @@ const isIcon = (maybeIcon: any): maybeIcon is IconDefinition => typeof maybeIcon
gap: 0.1rem;
&:focus-within {
outline: 1px solid var(--color-info-item-active);
outline: 1px solid var(--color-brand-item-active);
}
}
@@ -78,7 +78,7 @@ const isIcon = (maybeIcon: any): maybeIcon is IconDefinition => typeof maybeIcon
}
.form-widget:hover .widget {
border-color: var(--color-info-item-hover);
border-color: var(--color-brand-item-hover);
}
.element {

View File

@@ -1,5 +1,5 @@
<template>
<div v-if="error !== undefined" class="error typo p2-regular">
<div v-if="error !== undefined" class="error typo-body-regular-small">
<UiIcon :icon="faExclamationCircle" />
<span v-if="error.message === 'SESSION_AUTHENTICATION_FAILED'">
{{ $t('password-invalid') }}

View File

@@ -1,7 +1,7 @@
<template>
<div class="no-data">
<img alt="" class="img" src="@/assets/undraw-bug-fixing.svg" />
<p class="text-error typo h4-medium">{{ $t('error-no-data') }}</p>
<p class="text-error typo-h4">{{ $t('error-no-data') }}</p>
</div>
</template>
@@ -18,6 +18,7 @@
width: 17em;
height: 13em;
}
.text-error {
margin: auto;
width: 8em;

View File

@@ -27,6 +27,6 @@
font-weight: 500;
font-size: 2rem;
line-height: 150%;
color: var(--color-info-txt-base);
color: var(--color-brand-txt-base);
}
</style>

View File

@@ -33,7 +33,7 @@ const isRecordNotFound = computed(() => props.isReady && !props.uuidChecker(id.v
}
.spinner {
color: var(--color-info-txt-base);
color: var(--color-brand-txt-base);
display: flex;
margin: auto;
width: 10rem;

View File

@@ -4,7 +4,7 @@
:subtitle="$t('new-features-are-coming')"
:title="$t('xo-lite-under-construction')"
>
<p class="contact typo p1-regular">
<p class="contact typo-body-regular">
{{ $t('do-you-have-needs') }}
<a
href="https://xcp-ng.org/forum/topic/5018/xo-lite-building-an-embedded-ui-in-xcp-ng"

View File

@@ -26,7 +26,7 @@ const className = computed(() => `state-${props.state.toLocaleLowerCase()}`)
<style lang="postcss" scoped>
.power-state-icon {
color: var(--color-info-txt-item);
color: var(--color-brand-txt-item);
&.state-running {
color: var(--color-success-item-base);
@@ -37,7 +37,7 @@ const className = computed(() => `state-${props.state.toLocaleLowerCase()}`)
}
&.state-suspended {
color: var(--color-info-txt-hover);
color: var(--color-brand-txt-hover);
}
&.state-halted {

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

@@ -1,7 +1,7 @@
<template>
<div class="title-bar">
<UiIcon :icon class="icon" />
<div class="title typo h4-medium">
<div class="title typo-h4">
<slot />
</div>
<div class="actions">
@@ -36,7 +36,7 @@ defineProps<{
.icon {
font-size: 2.5rem;
color: var(--color-info-txt-base);
color: var(--color-brand-txt-base);
}
.title {

View File

@@ -60,20 +60,20 @@ const computedData = computed(() => {
}
.progress-item:nth-child(1) {
--progress-bar-color: var(--color-info-txt-item);
--progress-bar-color: var(--color-brand-txt-item);
}
.progress-item:nth-child(2) {
--progress-bar-color: var(--color-info-txt-active);
--progress-bar-color: var(--color-brand-txt-active);
}
.progress-item:nth-child(3) {
--progress-bar-color: var(--color-info-txt-hover);
--progress-bar-color: var(--color-brand-txt-hover);
}
.progress-item {
--progress-bar-height: 1.2rem;
--progress-bar-color: var(--color-info-item-hover);
--progress-bar-color: var(--color-brand-item-hover);
--progress-bar-background-color: var(--color-neutral-background-disabled);
&.warning {

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

@@ -3,13 +3,13 @@
<li v-for="[key, node] in tree" :key="key">
<span
v-if="node.children.size > 0"
class="directory typo p1-medium"
class="directory typo-body-bold"
@click="emit('toggleDirectory', node.directory)"
>
<UiIcon :icon="isOpen(node.directory) ? faFolderOpen : faFolderClosed" />
{{ formatName(key) }}
</span>
<RouterLink v-else :to="node.path" class="link typo p1-regular">
<RouterLink v-else :to="node.path" class="link typo-body-regular">
<UiIcon :icon="faFile" />
{{ formatName(key) }}
</RouterLink>

View File

@@ -1,5 +1,5 @@
<template>
<table class="story-params-table typo p2-regular">
<table class="story-params-table typo-body-regular-small">
<slot />
</table>
</template>
@@ -27,7 +27,7 @@
}
&:nth-child(odd) {
background-color: var(--color-info-background-selected);
background-color: var(--color-brand-background-selected);
}
}

View File

@@ -3,7 +3,7 @@
v-if="isSelectWidget(widget)"
v-model="model"
:wrapper-attrs="{ class: 'full-width' }"
class="typo p2-regular"
class="typo-body-regular-small"
>
<option v-if="!required && model === undefined" :value="undefined" />
<option v-for="choice in widget.choices" :key="choice.label" :value="choice.value">
@@ -19,9 +19,9 @@
<div v-else-if="isBooleanWidget(widget)">
<FormCheckbox v-model="model" />
</div>
<FormInput v-else-if="isNumberWidget(widget)" v-model.number="model" type="number" class="typo p2-regular" />
<FormInput v-else-if="isTextWidget(widget)" v-model="model" class="typo p2-regular" />
<FormJson v-else-if="isObjectWidget(widget)" v-model="model" class="typo p2-regular" />
<FormInput v-else-if="isNumberWidget(widget)" v-model.number="model" type="number" class="typo-body-regular-small" />
<FormInput v-else-if="isTextWidget(widget)" v-model="model" class="typo-body-regular-small" />
<FormJson v-else-if="isObjectWidget(widget)" v-model="model" class="typo-body-regular-small" />
</template>
<script lang="ts" setup>

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
@@ -83,7 +79,7 @@ const isIndeterminate = computed(() => (type === 'checkbox' || type === 'toggle'
.input.indeterminate + .fake-checkbox > .icon {
opacity: 1;
color: var(--color-info-txt-item);
color: var(--color-brand-txt-item);
}
}
@@ -145,7 +141,7 @@ const isIndeterminate = computed(() => (type === 'checkbox' || type === 'toggle'
.icon {
font-size: var(--checkbox-icon-size);
position: absolute;
color: var(--color-info-txt-item);
color: var(--color-brand-txt-item);
filter: drop-shadow(0 0.0625em 0.5em rgba(0, 0, 0, 0.1)) drop-shadow(0 0.1875em 0.1875em rgba(0, 0, 0, 0.06))
drop-shadow(0 0.1875em 0.25em rgba(0, 0, 0, 0.08));
@@ -164,7 +160,7 @@ const isIndeterminate = computed(() => (type === 'checkbox' || type === 'toggle'
background-color: var(--background-color);
box-shadow: var(--shadow-100);
--border-color: var(--color-info-item-base);
--border-color: var(--color-brand-item-base);
}
.input:disabled {
@@ -175,32 +171,32 @@ const isIndeterminate = computed(() => (type === 'checkbox' || type === 'toggle'
&:checked + .fake-checkbox {
--border-color: transparent;
--background-color: var(--color-info-item-disabled);
--background-color: var(--color-brand-item-disabled);
}
}
.input:not(:disabled) {
&:hover + .fake-checkbox,
&:focus + .fake-checkbox {
--border-color: var(--color-info-item-hover);
--border-color: var(--color-brand-item-hover);
}
&:active + .fake-checkbox {
--border-color: var(--color-info-item-active);
--border-color: var(--color-brand-item-active);
}
&:checked + .fake-checkbox {
--border-color: transparent;
--background-color: var(--color-info-item-base);
--background-color: var(--color-brand-item-base);
}
&:checked:hover + .fake-checkbox,
&:checked:focus + .fake-checkbox {
--background-color: var(--color-info-item-hover);
--background-color: var(--color-brand-item-hover);
}
&:checked:active + .fake-checkbox {
--background-color: var(--color-info-item-active);
--background-color: var(--color-brand-item-active);
}
}
</style>

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

@@ -1,7 +1,7 @@
<template>
<div class="form-input-wrapper">
<div v-if="label !== undefined || learnMoreUrl !== undefined" class="label-container">
<label :class="[light ? 'p1-regular light' : 'h7-semi-bold']" :for="id" class="label typo">
<label :class="[light ? 'typo-body-regular light' : 'typo-body-bold-small']" :for="id" class="label">
<UiIcon :icon />
{{ label }}
</label>
@@ -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>
@@ -126,7 +124,7 @@ useContext(DisabledContext, () => props.disabled)
align-items: center;
gap: 0.5rem;
text-decoration: none;
color: var(--color-info-txt-base);
color: var(--color-brand-txt-base);
& > span {
text-decoration: underline;

View File

@@ -1,7 +1,7 @@
<template>
<div :class="{ collapsible }" class="form-section">
<fieldset class="fieldset">
<legend class="legend typo h4-medium" @click="toggleCollapse">
<legend class="legend typo-h4" @click="toggleCollapse">
{{ label }}
<UiIcon :icon class="collapse-icon" />
</legend>
@@ -53,7 +53,7 @@ whenever(
<style lang="postcss" scoped>
.collapsible {
padding: 1rem 1.5rem;
background-color: var(--color-info-background-selected);
background-color: var(--color-brand-background-selected);
border-radius: 0.8rem;
}
@@ -67,9 +67,9 @@ whenever(
display: flex;
align-items: center;
justify-content: space-between;
color: var(--color-info-txt-base);
color: var(--color-brand-txt-base);
border: none;
border-bottom: 1px solid var(--color-info-txt-base);
border-bottom: 1px solid var(--color-brand-txt-base);
width: 100%;
padding-bottom: 1rem;
@@ -85,6 +85,6 @@ whenever(
}
.collapse-icon {
color: var(--color-info-txt-base);
color: var(--color-brand-txt-base);
}
</style>

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,460 @@
<template>
<UiPanel>
<template #header>
<UiButton
v-tooltip="$t('coming-soon')"
disabled
size="medium"
variant="tertiary"
accent="brand"
:left-icon="faEdit"
>
{{ $t('edit') }}
</UiButton>
<UiButton
v-tooltip="$t('coming-soon')"
disabled
size="medium"
variant="tertiary"
accent="danger"
:left-icon="faTrash"
>
{{ $t('delete') }}
</UiButton>
</template>
<template #default>
<!-- PIF -->
<UiCard class="card">
<UiCardTitle>{{ isBond ? $t('bond') : $t('pif') }}</UiCardTitle>
<div class="content">
<!-- UUID -->
<VtsCardRowKeyValue>
<template #key>
{{ $t('uuid') }}
</template>
<template #value>
{{ pif.uuid }}
</template>
<template #addons>
<VtsIcon
v-if="pif.management"
v-tooltip="$t('management')"
accent="info"
:icon="faCircle"
:overlay-icon="faStar"
/>
<UiButtonIcon
v-tooltip="copied && $t('core.copied')"
:icon="faCopy"
size="medium"
accent="brand"
@click="copy(pif.uuid)"
/>
</template>
</VtsCardRowKeyValue>
<!-- NETWORK -->
<VtsCardRowKeyValue>
<template #key>
{{ $t('network') }}
</template>
<template #value>
<div class="network">
<!-- TODO Remove the span when the link works and the icon is fixed -->
<!--
<UiComplexIcon size="medium">
<VtsIcon :icon="faNetworkWired" accent="current" />
<VtsIcon accent="success" :icon="faCircle" :overlay-icon="faCheck" />
</UiComplexIcon>
<a href="">{{ networkNameLabel }}</a>
-->
<span v-tooltip class="text-ellipsis">{{ network?.name_label }}</span>
</div>
</template>
<template v-if="network?.name_label" #addons>
<UiButtonIcon
v-tooltip="copied && $t('core.copied')"
:icon="faCopy"
size="medium"
accent="brand"
@click="copy(network?.name_label)"
/>
</template>
</VtsCardRowKeyValue>
<!-- DEVICE -->
<VtsCardRowKeyValue>
<template #key>
{{ $t('device') }}
</template>
<template #value>
{{ pif.device }}
</template>
<template v-if="pif.device" #addons>
<UiButtonIcon
v-tooltip="copied && $t('core.copied')"
:icon="faCopy"
size="medium"
accent="brand"
@click="copy(pif.device)"
/>
</template>
</VtsCardRowKeyValue>
<!-- PIF STATUS -->
<VtsCardRowKeyValue>
<template #key>
{{ isBond ? $t('bond-status') : $t('pif-status') }}
</template>
<template #value>
<VtsConnectionStatus :status />
</template>
</VtsCardRowKeyValue>
<!-- PHYSICAL INTERFACE STATUS -->
<VtsCardRowKeyValue>
<template #key>
{{ $t('physical-interface-status') }}
</template>
<template #value>
<VtsConnectionStatus :status="physicalInterfaceStatus" />
</template>
</VtsCardRowKeyValue>
<!-- VLAN -->
<VtsCardRowKeyValue>
<template #key>
{{ $t('vlan') }}
</template>
<template #value>
{{ pif.VLAN === -1 ? $t('none') : pif.VLAN }}
</template>
<template v-if="pif.VLAN !== -1" #addons>
<UiButtonIcon
v-tooltip="copied && $t('core.copied')"
:icon="faCopy"
size="medium"
accent="brand"
@click="copy(String(pif.VLAN))"
/>
</template>
</VtsCardRowKeyValue>
<!-- TAGS -->
<VtsCardRowKeyValue>
<template #key>
{{ $t('tags') }}
</template>
<template #value>
<UiTagsList class="tags value">
<UiTag v-for="tag in network?.tags" :key="tag" accent="info" variant="secondary">
{{ tag }}
</UiTag>
</UiTagsList>
</template>
</VtsCardRowKeyValue>
</div>
</UiCard>
<!-- NETWORK INFORMATION -->
<UiCard class="card">
<UiCardTitle>{{ $t('network-information') }}</UiCardTitle>
<div class="content">
<!-- IP ADDRESSES -->
<div v-if="ipAddresses.length">
<VtsCardRowKeyValue v-for="(ip, index) in ipAddresses" :key="ip">
<template #key>
<div v-if="index === 0">{{ $t('ip-addresses') }}</div>
</template>
<template #value>
<span class="text-ellipsis">{{ ip }}</span>
</template>
<template #addons>
<UiButtonIcon
v-if="ipAddresses.length"
v-tooltip="copied && $t('core.copied')"
:icon="faCopy"
size="medium"
accent="brand"
@click="copy(ip)"
/>
<UiButtonIcon
v-if="index === 0 && ipAddresses.length > 1"
v-tooltip="$t('coming-soon')"
disabled
:icon="faEllipsis"
size="medium"
accent="brand"
/>
</template>
</VtsCardRowKeyValue>
</div>
<VtsCardRowKeyValue v-else>
<template #key>
{{ $t('ip-addresses') }}
</template>
<template #value>
<span class="value" />
</template>
</VtsCardRowKeyValue>
<!-- MAC ADDRESSES -->
<VtsCardRowKeyValue>
<template #key>
{{ $t('mac-address') }}
</template>
<template #value>
{{ pif.MAC }}
</template>
<template v-if="pif.MAC" #addons>
<UiButtonIcon
v-tooltip="copied && $t('core.copied')"
:icon="faCopy"
size="medium"
accent="brand"
@click="copy(pif.MAC)"
/>
</template>
</VtsCardRowKeyValue>
<!-- NETMASK -->
<VtsCardRowKeyValue>
<template #key>
{{ $t('netmask') }}
</template>
<template #value>
<span class="value">{{ pif.netmask }}</span>
</template>
<template v-if="pif.netmask" #addons>
<UiButtonIcon
v-tooltip="copied && $t('core.copied')"
:icon="faCopy"
size="medium"
accent="brand"
@click="copy(String(pif.netmask))"
/>
</template>
</VtsCardRowKeyValue>
<!-- DNS -->
<VtsCardRowKeyValue>
<template #key>
{{ $t('dns') }}
</template>
<template #value>
<span class="value">
{{ pif.DNS }}
</span>
</template>
<template v-if="pif.DNS" #addons>
<UiButtonIcon
v-tooltip="copied && $t('core.copied')"
:icon="faCopy"
size="medium"
accent="brand"
@click="copy(String(pif.DNS))"
/>
</template>
</VtsCardRowKeyValue>
<!-- GATEWAY -->
<VtsCardRowKeyValue>
<template #key>
{{ $t('gateway') }}
</template>
<template #value>
<span class="value">
{{ pif.gateway }}
</span>
</template>
<template v-if="pif.gateway" #addons>
<UiButtonIcon
v-tooltip="copied && $t('core.copied')"
:icon="faCopy"
size="medium"
accent="brand"
@click="copy(String(pif.gateway))"
/>
</template>
</VtsCardRowKeyValue>
<!-- IP CONFIGURATION MODE -->
<VtsCardRowKeyValue>
<template #key>
{{ $t('ip-mode') }}
</template>
<template #value>
{{ ipConfigurationMode }}
</template>
</VtsCardRowKeyValue>
<!-- BOND DEVICES -->
<div>
<VtsCardRowKeyValue v-for="(device, index) in bondDevices" :key="device">
<template #key>
<div v-if="index === 0">{{ $t('bond-devices') }}</div>
</template>
<template #value>
<span class="text-ellipsis">{{ device }}</span>
</template>
<template #addons>
<UiButtonIcon
v-if="device"
v-tooltip="copied && $t('core.copied')"
:icon="faCopy"
size="medium"
accent="brand"
@click="copy(device)"
/>
<UiButtonIcon
v-if="index === 0 && bondDevices.length > 1"
v-tooltip="$t('coming-soon')"
disabled
:icon="faEllipsis"
size="medium"
accent="brand"
/>
</template>
</VtsCardRowKeyValue>
</div>
</div>
</UiCard>
<!-- PROPERTIES -->
<UiCard class="card">
<UiCardTitle>{{ $t('properties') }}</UiCardTitle>
<div class="content">
<!-- MTU -->
<VtsCardRowKeyValue>
<template #key>
{{ $t('mtu') }}
</template>
<template #value>
{{ pif.MTU === -1 ? $t('none') : pif.MTU }}
</template>
<template v-if="pif.MTU !== -1" #addons>
<UiButtonIcon
v-tooltip="copied && $t('core.copied')"
:icon="faCopy"
size="medium"
accent="brand"
@click="copy(String(pif.MTU))"
/>
</template>
</VtsCardRowKeyValue>
<!-- SPEED -->
<VtsCardRowKeyValue>
<template #key>
{{ $t('speed') }}
</template>
<template #value>
{{ speed }}
</template>
</VtsCardRowKeyValue>
<!-- NETWORK BLOCK DEVICE -->
<VtsCardRowKeyValue>
<template #key>
{{ $t('network-block-device') }}
</template>
<template #value>
{{ networkPurpose }}
</template>
<template v-if="networkPurpose" #addons>
<UiButtonIcon
v-tooltip="copied && $t('core.copied')"
:icon="faCopy"
size="medium"
accent="brand"
@click="copy(networkPurpose)"
/>
</template>
</VtsCardRowKeyValue>
</div>
</UiCard>
</template>
</UiPanel>
</template>
<script setup lang="ts">
import type { XenApiPif } 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 VtsCardRowKeyValue from '@core/components/card/VtsCardRowKeyValue.vue'
import VtsConnectionStatus from '@core/components/connection-status/VtsConnectionStatus.vue'
import VtsIcon from '@core/components/icon/VtsIcon.vue'
import UiButton from '@core/components/ui/button/UiButton.vue'
import UiButtonIcon from '@core/components/ui/button-icon/UiButtonIcon.vue'
import UiCard from '@core/components/ui/card/UiCard.vue'
import UiCardTitle from '@core/components/ui/card-title/UiCardTitle.vue'
import UiPanel from '@core/components/ui/panel/UiPanel.vue'
import UiTag from '@core/components/ui/tag/UiTag.vue'
import UiTagsList from '@core/components/ui/tag/UiTagsList.vue'
import { vTooltip } from '@core/directives/tooltip.directive'
import { faCircle, faCopy, faEdit, faEllipsis, faStar, faTrash } from '@fortawesome/free-solid-svg-icons'
import { useClipboard } from '@vueuse/core'
import humanFormat from 'human-format'
import { computed } from 'vue'
import { useI18n } from 'vue-i18n'
const { pif } = defineProps<{
pif: XenApiPif
}>()
const { getByOpaqueRef: getPifMetricsByOpaqueRef, getPifCarrier } = usePifMetricsStore().subscribe()
const { getByOpaqueRef: getNetworkByOpaqueRef } = useNetworkStore().subscribe()
const { getBondsDevices, isBondMaster } = usePifStore().subscribe()
const { t } = useI18n()
const ipAddresses = computed(() => [pif.IP, ...pif.IPv6].filter(ip => ip))
const network = computed(() => getNetworkByOpaqueRef(pif.network))
const networkPurpose = computed(() => (network.value?.purpose?.[0] ? t('on') : t('off')))
const status = computed(() => (pif.currently_attached ? 'connected' : 'disconnected'))
const physicalInterfaceStatus = computed(() => (getPifCarrier(pif) ? 'connected' : 'physically-disconnected'))
const ipConfigurationMode = computed(() => {
switch (pif.ip_configuration_mode) {
case 'Static':
return t('static')
case 'DHCP':
return t('dhcp')
default:
return t('none')
}
})
const bondDevices = computed(() => getBondsDevices(pif))
const isBond = computed(() => isBondMaster(pif))
const speed = computed(() => {
const speed = getPifMetricsByOpaqueRef(pif.metrics)?.speed || 0
const speedInBytes = speed * 1000000
return humanFormat(speedInBytes, {
scale: 'SI',
unit: 'b/s',
maxDecimals: 2,
})
})
const { copy, copied } = useClipboard()
</script>
<style scoped lang="postcss">
.card {
gap: 1.6rem;
.content {
display: flex;
flex-direction: column;
gap: 0.8rem;
}
.network {
display: flex;
gap: 0.8rem;
}
.tags {
width: 100%;
display: flex;
gap: 0.8rem;
}
.value:empty::before {
content: '-';
}
}
</style>

View File

@@ -0,0 +1,304 @@
<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-body-regular-small"
: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="info"
:icon="faCircle"
:overlay-icon="faStar"
/>
</div>
<div v-else-if="column.id === 'IP'" class="ip-addresses">
<span v-tooltip class="value text-ellipsis">{{ column.value[0] }}</span>
<span v-if="column.value.length > 1" class="typo-body-regular-small more-ips">
{{ `+${column.value.length - 1}` }}
</span>
</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 { XenApiNetwork, XenApiPif } from '@/libs/xen-api/xen-api.types'
import { useNetworkStore } from '@/stores/xen-api/network.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'
const { pifs } = defineProps<{
pifs: XenApiPif[]
}>()
const { isReady, hasError } = usePifStore().subscribe()
const { getByOpaqueRef } = useNetworkStore().subscribe()
const { getPifStatus } = usePifStore().subscribe()
const { t } = useI18n()
const selectedPifId = useRouteQuery('id')
const pifsUuids = computed(() => pifs.map(pif => pif.uuid))
const { selected, areAllSelected } = useMultiSelect(pifsUuids)
const getNetworkName = (networkRef: XenApiNetwork['$ref']) => getByOpaqueRef(networkRef)?.name_label
const getVlanData = (vlan: number) => (vlan !== -1 ? vlan : t('none'))
const getIpAddresses = (pif: XenApiPif) => [pif.IP, ...pif.IPv6].filter(ip => ip)
const getIpConfigurationMode = (ipMode: string) => {
switch (ipMode) {
case 'Static':
return t('static')
case 'DHCP':
return t('dhcp')
default:
return t('none')
}
}
const searchQuery = ref('')
const filteredPifs = computed(() => {
const searchTerm = searchQuery.value.trim().toLocaleLowerCase()
if (!searchTerm) {
return pifs
}
return pifs.filter(pif =>
[...Object.values(pif), getNetworkName(pif.network)].some(value =>
String(value).toLocaleLowerCase().includes(searchTerm)
)
)
})
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', record => getIpAddresses(record), { label: t('ip-addresses') }),
define('MAC', { label: t('mac-addresses') }),
define('ip_configuration_mode', record => getIpConfigurationMode(record.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;
}
.ip-addresses {
display: flex;
justify-content: space-between;
align-items: center;
.more-ips {
color: var(--color-neutral-txt-secondary);
}
&:has(.value:empty) {
justify-content: center;
}
}
.checkbox,
.more {
width: 4.8rem;
}
.checkbox {
text-align: center;
line-height: 1;
}
.value:empty::before {
content: '-';
}
}
</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

@@ -14,7 +14,7 @@
<div v-if="newFilters.some(filter => filter.isAdvanced)" class="available-properties">
{{ $t('available-properties-for-advanced-filter') }}
<div class="properties typo p1-regular">
<div class="properties typo-body-regular">
<UiBadge v-for="(filter, property) in availableFilters" :key="property" :icon="getFilterIcon(filter)">
{{ property }}
</UiBadge>
@@ -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

@@ -0,0 +1,109 @@
<template>
<tr class="pif-row" :class="{ clickable: pifHost }" @click="pifHost?.redirect()">
<td v-tooltip class="typo-body-regular-small text-ellipsis host-container">
<div v-if="pifHost" class="host">
<UiObjectIcon :state="pifHost.powerState" type="host" size="small" />
<span v-tooltip class="typo-body-regular-small text-ellipsis host-name">
{{ pifHost.label }}
</span>
</div>
<div v-else>
<span>{{ $t('host-unknown') }}</span>
</div>
</td>
<td v-tooltip class="typo-body-regular-small text-ellipsis device">{{ pif.device }}</td>
<td v-tooltip class="typo-body-regular-small status">
<VtsConnectionStatus :status />
</td>
<td>
<UiButtonIcon size="small" accent="brand" :icon="faAngleRight" :disabled="!pifHost" />
</td>
</tr>
</template>
<script setup lang="ts">
import type { XenApiPif } from '@/libs/xen-api/xen-api.types'
import { useHostMetricsStore } from '@/stores/xen-api/host-metrics.store'
import { useHostStore } from '@/stores/xen-api/host.store'
import { usePifStore } from '@/stores/xen-api/pif.store'
import VtsConnectionStatus from '@core/components/connection-status/VtsConnectionStatus.vue'
import UiButtonIcon from '@core/components/ui/button-icon/UiButtonIcon.vue'
import UiObjectIcon from '@core/components/ui/object-icon/UiObjectIcon.vue'
import { vTooltip } from '@core/directives/tooltip.directive'
import { faAngleRight } from '@fortawesome/free-solid-svg-icons'
import { computed } from 'vue'
import { useRouter } from 'vue-router'
const { pif } = defineProps<{
pif: XenApiPif
}>()
const { getByOpaqueRef } = useHostStore().subscribe()
const { isHostRunning } = useHostMetricsStore().subscribe()
const { getPifStatus } = usePifStore().subscribe()
const router = useRouter()
const status = computed(() => getPifStatus(pif))
const pifHost = computed(() => {
const host = getByOpaqueRef(pif.host)
if (!host) {
return
}
return {
label: host.name_label,
powerState: isHostRunning(host) ? 'running' : 'halted',
redirect() {
router.push({
name: 'host.network',
params: { uuid: host.uuid },
query: { id: pif.uuid },
})
},
} as const
})
</script>
<style lang="postcss" scoped>
.pif-row {
&.clickable {
cursor: pointer;
&:hover {
background-color: var(--color-brand-background-hover);
}
}
td {
color: var(--color-neutral-txt-primary);
}
.host-container {
width: 14rem;
max-width: 14rem;
.host {
display: flex;
align-items: center;
gap: 0.8rem;
}
.host-name {
color: var(--color-brand-txt-base);
}
}
.device {
width: 8rem;
max-width: 8rem;
}
.status {
width: 11.5rem;
max-width: 11.5rem;
}
}
</style>

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

@@ -8,10 +8,10 @@
</UiCardTitle>
<div v-if="!isStarted" class="pre-start">
<div>
<p class="text typo h4-medium">
<p class="text typo-h4">
{{ $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" />
@@ -25,7 +25,7 @@
<div>
<img alt="" src="@/assets/server-status.svg" />
</div>
<p class="text typo h4-medium">{{ $t('all-good') }}<br />{{ $t('no-alarm-triggered') }}</p>
<p class="text typo-h4">{{ $t('all-good') }}<br />{{ $t('no-alarm-triggered') }}</p>
</div>
<div v-else class="table-container">
<UiTable>

View File

@@ -85,7 +85,7 @@ const hasError = computed(() => hostStoreHasError.value || vmStoreHasError.value
.progress-item {
margin-top: 2.6rem;
--progress-bar-height: 1.2rem;
--progress-bar-color: var(--color-info-item-base);
--progress-bar-color: var(--color-brand-item-base);
--progress-bar-background-color: var(--color-neutral-background-disabled);
&.warning {

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

@@ -2,18 +2,18 @@
<div class="pool-dashboard-status-item">
<ProgressCircle :max-value="total" :value="active" />
<div class="content">
<h6 class="typo h6-semi-bold">{{ label }}</h6>
<div class="status-line typo p1-regular">
<h6 class="typo-h6">{{ label }}</h6>
<div class="status-line typo-body-regular">
<div class="bullet" />
<div class="label">{{ activeLabel }}</div>
<div class="count">{{ active }}</div>
</div>
<div class="status-line typo p1-regular">
<div class="status-line typo-body-regular">
<div class="bullet inactive" />
<div class="label">{{ inactiveLabel }}</div>
<div class="count">{{ inactive }}</div>
</div>
<div class="total typo c2-semi-bold">
<div class="total typo-caption-small">
{{ $t('total') }} <span>{{ total }}</span>
</div>
</div>

View File

@@ -10,7 +10,7 @@
{{ $t(`alarm-type.${alarm.type}`, { n: alarm.triggerLevel * 100 }) }}
</div>
</td>
<td class="level typo h7-semi-bold">
<td class="level typo-body-bold-small">
<!-- Using `Math.min` because `alarm.level` can be `Infinity` -->
{{ $n(Math.min(alarm.level, 1), 'percent') }}
</td>

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,230 @@
<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-body-regular-small"
: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="value 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 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 { networks } = defineProps<{
networks: XenApiNetwork[]
}>()
const { isReady, hasError } = useNetworkStore().subscribe()
const { t } = useI18n()
const selectedNetworkId = useRouteQuery('id')
const networkUuids = computed(() => networks.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 searchQuery = ref('')
const filteredNetworks = computed(() => {
const searchTerm = searchQuery.value.trim().toLocaleLowerCase()
if (!searchTerm) {
return networks
}
return networks.filter(network =>
Object.values(network).some(value => String(value).toLocaleLowerCase().includes(searchTerm))
)
})
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;
}
.value:empty::before {
content: '-';
display: flex;
justify-content: center;
}
}
</style>

View File

@@ -0,0 +1,218 @@
<template>
<UiPanel>
<template #header>
<UiButton
v-tooltip="$t('coming-soon')"
disabled
variant="tertiary"
size="medium"
accent="brand"
:left-icon="faEdit"
>
{{ $t('edit') }}
</UiButton>
<UiButton
v-tooltip="$t('coming-soon')"
disabled
variant="tertiary"
size="medium"
accent="danger"
:left-icon="faTrash"
>
{{ $t('delete') }}
</UiButton>
<UiButtonIcon v-tooltip="$t('coming-soon')" disabled accent="brand" size="medium" :icon="faEllipsis" />
</template>
<template #default>
<UiCard class="card-container">
<UiCardTitle v-tooltip="{ placement: 'bottom-end' }" class="typo-body-bold text-ellipsis">
{{ network.name_label }}
</UiCardTitle>
<div class="content">
<!-- UUID -->
<VtsCardRowKeyValue>
<template #key>
{{ $t('uuid') }}
</template>
<template #value>{{ network.uuid }}</template>
<template v-if="network.uuid" #addons>
<UiButtonIcon
v-tooltip="copied && $t('core.copied')"
accent="brand"
size="medium"
:icon="faCopy"
@click="copy(network.uuid)"
/>
</template>
</VtsCardRowKeyValue>
<!-- DESCRIPTION -->
<VtsCardRowKeyValue>
<template #key>{{ $t('description') }}</template>
<template #value>
<span class="value">{{ network.name_description }}</span>
</template>
<template v-if="network.name_description" #addons>
<UiButtonIcon
v-tooltip="copied && $t('core.copied')"
accent="brand"
size="medium"
:icon="faCopy"
@click="copy(network.name_description)"
/>
</template>
</VtsCardRowKeyValue>
<!-- VLAN -->
<VtsCardRowKeyValue v-if="networkVlan">
<template #key>{{ $t('vlan') }}</template>
<template #value>{{ networkVlan }}</template>
<template #addons>
<UiButtonIcon
v-tooltip="copied && $t('core.copied')"
accent="brand"
size="medium"
:icon="faCopy"
@click="copy(String(networkVlan))"
/>
</template>
</VtsCardRowKeyValue>
<!-- MTU -->
<VtsCardRowKeyValue>
<template #key>{{ $t('mtu') }}</template>
<template #value>
<span class="value">{{ network.MTU }}</span>
</template>
<template v-if="network.MTU" #addons>
<UiButtonIcon
v-tooltip="copied && $t('core.copied')"
accent="brand"
size="medium"
:icon="faCopy"
@click="copy(String(network.MTU))"
/>
</template>
</VtsCardRowKeyValue>
<!-- NBD -->
<VtsCardRowKeyValue>
<template #key>{{ $t('network-block-device') }}</template>
<template #value>{{ networkNbd }}</template>
<template #addons>
<UiButtonIcon
v-tooltip="copied && $t('core.copied')"
accent="brand"
size="medium"
:icon="faCopy"
@click="copy(networkNbd)"
/>
</template>
</VtsCardRowKeyValue>
<!-- DEFAULT LOCKING MODE -->
<VtsCardRowKeyValue>
<template #key>{{ $t('locking-mode-default') }}</template>
<template #value>{{ networkDefaultLockingMode }}</template>
</VtsCardRowKeyValue>
</div>
</UiCard>
<UiCard v-if="pifsCount && pifsCount > 0" class="card-container">
<div class="typo-body-bold">
{{ $t('pifs') }}
<UiCounter :value="pifsCount" variant="primary" size="small" accent="neutral" />
</div>
<table class="simple-table">
<thead>
<tr>
<th class="text-left typo-body-regular-small">
{{ $t('host') }}
</th>
<th class="text-left typo-body-regular-small">
{{ $t('device') }}
</th>
<th class="text-left typo-body-regular-small">
{{ $t('pifs-status') }}
</th>
<th />
</tr>
</thead>
<tbody>
<PifRow v-for="pif in pifs" :key="pif.uuid" :pif />
</tbody>
</table>
</UiCard>
</template>
</UiPanel>
</template>
<script setup lang="ts">
import PifRow from '@/components/pif/PifRow.vue'
import type { XenApiNetwork } from '@/libs/xen-api/xen-api.types'
import { usePifStore } from '@/stores/xen-api/pif.store'
import VtsCardRowKeyValue from '@core/components/card/VtsCardRowKeyValue.vue'
import UiButton from '@core/components/ui/button/UiButton.vue'
import UiButtonIcon from '@core/components/ui/button-icon/UiButtonIcon.vue'
import UiCard from '@core/components/ui/card/UiCard.vue'
import UiCardTitle from '@core/components/ui/card-title/UiCardTitle.vue'
import UiCounter from '@core/components/ui/counter/UiCounter.vue'
import UiPanel from '@core/components/ui/panel/UiPanel.vue'
import { vTooltip } from '@core/directives/tooltip.directive'
import { faCopy, faEdit, faEllipsis, faTrash } from '@fortawesome/free-solid-svg-icons'
import { useClipboard } from '@vueuse/core'
import { computed } from 'vue'
import { useI18n } from 'vue-i18n'
const { network } = defineProps<{
network: XenApiNetwork
}>()
const { getPifsByNetworkRef } = usePifStore().subscribe()
const { t } = useI18n()
const pifs = computed(() => getPifsByNetworkRef(network.$ref))
const networkVlan = computed(() => {
if (pifs.value.length === 0) {
return ''
}
return pifs.value[0].VLAN !== -1 ? pifs.value[0].VLAN.toString() : t('none')
})
const networkNbd = computed(() => (network.purpose[0] ? t('on') : t('off')))
const networkDefaultLockingMode = computed(() =>
network.default_locking_mode === 'disabled' ? t('disabled') : t('unlocked')
)
const pifsCount = computed(() => pifs.value.length)
const { copy, copied } = useClipboard()
</script>
<style scoped lang="postcss">
.card-container {
display: flex;
flex-direction: column;
gap: 1.6rem;
.content {
display: flex;
flex-direction: column;
gap: 0.4rem;
}
.text-left {
text-align: left;
}
.simple-table {
border-spacing: 0;
padding: 0.4rem;
thead tr th {
color: var(--color-neutral-txt-secondary);
}
}
.value:empty::before {
content: '-';
}
}
</style>

View File

@@ -0,0 +1,272 @@
<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-body-regular-small"
: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="value 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 { networks } = defineProps<{
networks: XenApiNetwork[]
}>()
const { isReady, hasError } = useNetworkStore().subscribe()
const { records: pifs } = usePifStore().subscribe()
const { getPifCarrier } = usePifMetricsStore().subscribe()
const { t } = useI18n()
const selectedNetworkId = useRouteQuery('id')
const networkUuids = computed(() => networks.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 searchQuery = ref('')
const filteredNetworks = computed(() => {
const searchTerm = searchQuery.value.trim().toLocaleLowerCase()
if (!searchTerm) {
return networks
}
return networks.filter(network =>
Object.values(network).some(value => String(value).toLocaleLowerCase().includes(searchTerm))
)
})
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;
}
.value:empty::before {
content: '-';
display: flex;
justify-content: center;
}
}
</style>

View File

@@ -12,7 +12,7 @@
<tbody>
<tr v-if="hasError">
<td colspan="5">
<span class="text-error typo h6-semi-bold">{{ $t('error-no-data') }}</span>
<span class="text-error typo-h6">{{ $t('error-no-data') }}</span>
</td>
</tr>
<tr v-else-if="isFetching">
@@ -69,7 +69,7 @@ td[colspan='5'] {
}
.loader {
color: var(--color-info-txt-base);
color: var(--color-brand-txt-base);
display: block;
font-size: 4rem;
margin: 2rem auto 0;

View File

@@ -1,5 +1,5 @@
<template>
<div v-if="isDisplayed" class="summary typo c2-semi-bold">
<div v-if="isDisplayed" class="summary typo-caption-small">
<div class="summary-card">
<p>{{ $t('total-used:') }}</p>
<div class="summary-value">
@@ -24,6 +24,7 @@
<script lang="ts" setup>
import { formatSize, percent } from '@/libs/utils'
import { computed } from 'vue'
const props = defineProps<{
size: number
usage: number

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>
@@ -62,8 +58,8 @@ const isDisabled = useContext(DisabledContext, () => props.disabled)
&:active,
&.active,
&.busy {
color: var(--color-info-txt-base);
background-color: var(--color-info-background-selected);
color: var(--color-brand-txt-base);
background-color: var(--color-brand-background-selected);
}
}
}

View File

@@ -1,5 +1,5 @@
<template>
<span class="ui-badge typo p2-medium">
<span class="ui-badge typo-body-bold-small">
<UiIcon :icon />
<slot />
</span>

View File

@@ -1,5 +1,5 @@
<template>
<div class="footer typo c2-semi-bold">
<div class="footer typo-caption-small">
<div class="footer-card">
<slot name="left" />
</div>

View File

@@ -17,7 +17,7 @@ import UiSpinner from '@/components/ui/UiSpinner.vue'
}
.spinner {
color: var(--color-info-txt-base);
color: var(--color-brand-txt-base);
font-size: 4rem;
}
</style>

Some files were not shown because too many files have changed in this diff Show More