Skip to content

Commit 62013d4

Browse files
authored
feat(xo6): add detach host button (#10179)
* feat(xo6): rebase detach * add redirect when detach ok * fix post rebase * remove dev route * returns from MR * add check master host * use linked translation * rebase ok
1 parent 6a4415e commit 62013d4

14 files changed

Lines changed: 179 additions & 21 deletions

File tree

‎@xen-orchestra/web-core/lib/components/modal/VtsActionModal.vue‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ const textMappingsByObject: TextMappingByObject = {
139139
message: t('modal:host-restart-toolstack-message'),
140140
action: t('action:restart-toolstack'),
141141
},
142+
detach: {
143+
title: t('modal:confirm-host-detach?', { host: hostName }),
144+
message: t('modal:host-detach-message'),
145+
action: t('action:detach'),
146+
},
142147
},
143148
}
144149

‎@xen-orchestra/web-core/lib/locales/en.json‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"action:delete-n-vms": "Delete 1 VM | Delete {n} VMs",
5353
"action:deploy": "Deploy",
5454
"action:deploy-xoa": "Deploy XOA",
55+
"action:detach": "Detach",
5556
"action:detach-n-vdis": "Detach 1 VDI | Detach {n} VDIs",
5657
"action:detach-vdi": "Detach VDI",
5758
"action:disable": "Disable",
@@ -430,6 +431,7 @@
430431
"host-disable-title": "Are you sure you want to disable {host}?",
431432
"host-enable-title": "Are you sure you want to enable {host}?",
432433
"host-internal-networks": "Host internal networks",
434+
"host-missing": "Host is missing",
433435
"host-not-running": "Host not running",
434436
"host-off": "Host is powered off",
435437
"host:status:active": "@:status:active",
@@ -505,9 +507,12 @@
505507
"job:disconnect:in-progress": "Disconnect in progress…",
506508
"job:enable:in-progress": "Enable in progress…",
507509
"job:export:in-progress": "Export in progress…",
510+
"job:host-detach:in-progress": "Host detach in progress…",
511+
"job:host-detach:master-host": "Master host cannot be detached",
512+
"job:host-detach:missing-host": "No host to detach",
508513
"job:host-disable:bad-power-state": "Host is not running",
509-
"job:host-disable:missing-host": "Host is missing",
510-
"job:host-enable:missing-host": "Host is missing",
514+
"job:host-disable:missing-host": "@:host-missing",
515+
"job:host-enable:missing-host": "@:host-missing",
511516
"job:host-evacuate:in-progress": "Host evacuation in progress…",
512517
"job:host-forget:bad-power-state": "Host is running",
513518
"job:host-forget:in-progress": "Host forgetting in progress…",
@@ -521,7 +526,7 @@
521526
"job:host-restart-toolstack:missing-host": "No host to restart toolstack on",
522527
"job:host-scan-pifs:bad-power-state": "Host is not running",
523528
"job:host-scan-pifs:in-progress": "@:scan-pifs in progress…",
524-
"job:host-scan-pifs:missing-host": "Host is missing",
529+
"job:host-scan-pifs:missing-host": "@:host-missing",
525530
"job:host-shutdown:bad-power-state": "Host already halted",
526531
"job:host-shutdown:in-progress": "Host shut down in progress…",
527532
"job:host-shutdown:missing-host": "No host to shut down",
@@ -683,6 +688,7 @@
683688
"modal:action:vm-force-shutdown": "@:action:force-shutdown VM",
684689
"modal:action:vm-reboot": "@:action:reboot VM",
685690
"modal:action:vm-shutdown": "@:action:shutdown VM",
691+
"modal:confirm-host-detach?": "Are you sure you want to detach {host}?",
686692
"modal:confirm-host-disable-and-evacuate-vms?": "Are you sure you want to disable {host} and evacuate its VMs?",
687693
"modal:confirm-host-disable?": "Are you sure you want to disable {host}?",
688694
"modal:confirm-host-enable?": "Are you sure you want to enable {host}?",
@@ -697,14 +703,15 @@
697703
"modal:confirm-vm-force-shutdown": "Confirm VM force shutdown",
698704
"modal:confirm-vm-reboot": "Confirm VM reboot",
699705
"modal:confirm-vm-shutdown": "Confirm VM shutdown",
706+
"modal:host-detach-message": "This host will be detached from the pool and its local storage reset. Make sure no VMs are still running on it and that anything you need from its local storage has been backed up.",
700707
"modal:host-disable-and-evacuate-vms-message": "The host will be disabled and its running VMs will be automatically migrated to other hosts in the pool, with no interruption as long as resources allow.",
701708
"modal:host-disable-message": "The host will be marked unavailable for starting or receiving new VMs. Already-running VMs are not affected.",
702709
"modal:host-enable-message": "The host becomes available again for starting or receiving VMs.",
703710
"modal:host-force-reboot-message": "The host is about to reboot. Its running VMs will be migrated to other hosts when possible, but those that can't be will be forcibly shut down. Data loss may occur.",
704711
"modal:host-forget-message": "This will permanently remove the host from the pool database. Only do this if the host is physically gone or unrecoverable - if it can come back online, use Detach instead. This action cannot be undone.",
705712
"modal:host-reboot-message": "The host is about to reboot. Its running VMs will be migrated to other hosts and won't be moved back to it automatically afterwards.",
706713
"modal:host-restart-toolstack-message": "The host's management service (toolstack) is about to restart. Running VMs won't be interrupted, but they'll be temporarily unmanageable (a few minutes).",
707-
"modal:host-shutdown-message": "This will power off the host. Any VMs still running on it will be shut down immediately unless you've migrated them first.",
714+
"modal:host-shutdown-message": "This will power off the host. Any VMs still running on it will be migrated to another running host.",
708715
"modal:host-smart-reboot-message": "All running VMs on this host will be suspended, the host will reboot, then the VMs will automatically resume. This causes temporary downtime. If Xen Orchestra itself runs on this host, VMs may not resume automatically.",
709716
"modal:pool-disconnect-message": "The pool will no longer be manageable from XO. You can reconnect it later.",
710717
"modal:vm-force-reboot-message": "This will immediately reboot the virtual machine without a clean shutdown. Data loss may occur and ongoing processes will be interrupted.",

‎@xen-orchestra/web-core/lib/locales/fr.json‎

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"action:delete-n-vms": "Supprimer 1 VM | Supprimer {n} VMs",
5353
"action:deploy": "Déployer",
5454
"action:deploy-xoa": "Déployer XOA",
55+
"action:detach": "Détacher",
5556
"action:detach-n-vdis": "Détacher 1 VDI | Détacher {n} VDIs",
5657
"action:detach-vdi": "Détacher le VDI",
5758
"action:disable": "Désactiver",
@@ -505,27 +506,30 @@
505506
"job:disconnect:in-progress": "Déconnexion en cours…",
506507
"job:enable:in-progress": "Activation en cours…",
507508
"job:export:in-progress": "Export en cours…",
508-
"job:host-disable:bad-power-state": "L'hôte n'est pas démarré",
509-
"job:host-disable:missing-host": "L'hôte est manquant",
510-
"job:host-enable:missing-host": "L'hôte est manquant",
509+
"job:host-detach:in-progress": "Détachement de l'hôte en cours…",
510+
"job:host-detach:master-host": "L'hôte primaire ne peut pas être détaché",
511+
"job:host-detach:missing-host": "Aucun hôte à détacher",
512+
"job:host-disable:bad-power-state": "@:host-not-running",
513+
"job:host-disable:missing-host": "@:host-missing",
514+
"job:host-enable:missing-host": "@:host-missing",
511515
"job:host-evacuate:in-progress": "Évacuation de l'hôte en cours…",
512516
"job:host-forget:bad-power-state": "L'hôte est en cours d'exécution",
513517
"job:host-forget:in-progress": "Oubli de l'hôte en cours…",
514518
"job:host-forget:missing-host": "Aucun hôte à oublier",
515-
"job:host-reboot:bad-power-state": "L'hôte n'est pas démarré",
519+
"job:host-reboot:bad-power-state": "@:host-not-running",
516520
"job:host-reboot:evacuate-in-progress": "Évacuation des VMs en cours…",
517521
"job:host-reboot:in-progress": "Redémarrage de l'hôte en cours…",
518522
"job:host-reboot:missing-host": "Aucun hôte à redémarrer",
519-
"job:host-restart-toolstack:bad-power-state": "L'hôte n'est pas démarré",
523+
"job:host-restart-toolstack:bad-power-state": "@:host-not-running",
520524
"job:host-restart-toolstack:in-progress": "Redémarrage du toolstack de l'hôte en cours…",
521525
"job:host-restart-toolstack:missing-host": "Aucun hôte sur lequel redémarrer le toolstack",
522-
"job:host-scan-pifs:bad-power-state": "L'hôte n'est pas lancé",
526+
"job:host-scan-pifs:bad-power-state": "@:host-not-running",
523527
"job:host-scan-pifs:in-progress": "@:scan-pifs en cours…",
524-
"job:host-scan-pifs:missing-host": "L'hôte est manquant",
528+
"job:host-scan-pifs:missing-host": "@:host-missing",
525529
"job:host-shutdown:bad-power-state": "Hôte déjà arrêté",
526530
"job:host-shutdown:in-progress": "Arrêt de l'hôte en cours…",
527531
"job:host-shutdown:missing-host": "Aucun hôte à arrêter",
528-
"job:host-smart-reboot:bad-power-state": "L'hôte n'est pas démarré",
532+
"job:host-smart-reboot:bad-power-state": "@:host-not-running",
529533
"job:host-smart-reboot:in-progress": "Redémarrage optimisé de l'hôte en cours…",
530534
"job:host-smart-reboot:missing-host": "Aucun hôte pour le redémarrage optimisé",
531535
"job:host-smart-reboot:vm-clean-shutdown-in-progress": "Arrêt des VMs en cours…",
@@ -683,6 +687,7 @@
683687
"modal:action:vm-force-shutdown": "@:action:force-shutdown la VM",
684688
"modal:action:vm-reboot": "@:action:reboot la VM",
685689
"modal:action:vm-shutdown": "@:action:shutdown la VM",
690+
"modal:confirm-host-detach?": "Êtes-vous sûr de vouloir détacher {host} ?",
686691
"modal:confirm-host-disable-and-evacuate-vms?": "Êtes-vous sûr de vouloir désactiver {host} et évacuer ses VMs ?",
687692
"modal:confirm-host-disable?": "Êtes-vous sûr de vouloir désactiver {host} ?",
688693
"modal:confirm-host-enable?": "Êtes-vous sûr de vouloir activer {host} ?",
@@ -696,15 +701,17 @@
696701
"modal:confirm-vm-force-reboot": "Confirmer le redémarrage forcé de la VM",
697702
"modal:confirm-vm-force-shutdown": "Confirmer l'arrêt forcé de la VM",
698703
"modal:confirm-vm-reboot": "Confirmer le redémarrage de la VM",
704+
"host-missing": "L'hôte est manquant",
699705
"modal:confirm-vm-shutdown": "Confirmer l'arrêt de la VM",
706+
"modal:host-detach-message": "Cet hôte sera détaché du pool et son stockage local réinitialisé. Assurez-vous qu'aucune VM n'est encore en cours d'exécution et que tout ce dont vous avez besoin sur son stockage local a été sauvegardé.",
700707
"modal:host-disable-and-evacuate-vms-message": "L'hôte sera désactivé et ses VMs en cours d'exécution seront automatiquement migrées vers d'autres hôtes du pool, sans interruption si les ressources le permettent.",
701708
"modal:host-disable-message": "L'hôte sera marqué comme indisponible pour le démarrage ou la réception de nouvelles VMs. Les VMs déjà en cours d’exécution ne sont pas affectées.",
702709
"modal:host-enable-message": "L'hôte redevient disponible pour démarrer ou recevoir des VMs.",
703710
"modal:host-force-reboot-message": "L'hôte est sur le point de redémarrer. Ses VMs en cours d'exécution seront migrées vers d'autres hôtes lorsque cela sera possible, mais celles qui ne peuvent pas l'être seront arrêtées de force. Une perte de données peut survenir.",
704711
"modal:host-forget-message": "Cela supprimera définitivement l'hôte de la base de données du pool. Ne faites cela que si l'hôte est physiquement absent ou irrécupérable - s'il peut revenir en ligne, utilisez à la place Détacher. Cette action ne peut pas être annulée.",
705712
"modal:host-reboot-message": "L'hôte va redémarrer. Ses VMs en cours d'exécution seront migrées vers d'autres hôtes et ne reviendront pas automatiquement dessus après l'opération.",
706713
"modal:host-restart-toolstack-message": "Le service de gestion de l'hôte (toolstack) est sur le point de redémarrer. Les VMs en cours d'exécution ne seront pas interrompues, mais elles seront temporairement ingérables (quelques minutes).",
707-
"modal:host-shutdown-message": "Cela éteindra l'hôte. Toute VM encore en cours d’exécution sera immédiatement arrêtée, à moins que vous ne l'ayez migrée au préalable.",
714+
"modal:host-shutdown-message": "Cela va éteindre l'hôte. Les VMs encore en cours d'exécution seront migrées vers un autre hôte actif.",
708715
"modal:host-smart-reboot-message": "Toutes les VMs en cours d'exécution sur cet hôte seront suspendues, l'hôte redémarrera, puis les VMs reprendront automatiquement. Cela entraîne une interruption temporaire. Si Xen Orchestra lui-même s'exécute sur cet hôte, les VMs pourraient ne pas reprendre automatiquement.",
709716
"modal:pool-disconnect-message": "Le pool ne pourra plus être géré depuis XO. Vous pourrez le reconnecter ultérieurement.",
710717
"modal:vm-force-reboot-message": "Cela redémarrera immédiatement la VM sans arrêt propre. Des pertes de données peuvent survenir et les processus en cours seront interrompus.",

‎@xen-orchestra/web-core/lib/types/object.type.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export type HostActions =
1212
| 'force-reboot'
1313
| 'smart-reboot'
1414
| 'restart-toolstack'
15+
| 'detach'
1516

1617
export type VmBlockedOperations =
1718
| 'clean_shutdown'

‎@xen-orchestra/web/src/modules/host/components/HostMoreActions.vue‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
<HostDisableAndEvacuateVmsButton :host />
1616
</template>
1717
<HostEnableButton v-else :host />
18+
<HostDetachButton :host />
1819
<HostForgetButton :host />
1920
<VtsDivider type="stretch" />
2021
<HostDownloadButton :host-id="host.id" />
2122
</template>
2223

2324
<script lang="ts" setup>
25+
import HostDetachButton from '@/modules/host/components/actions/detach/HostDetachButton.vue'
2426
import HostDisableButton from '@/modules/host/components/actions/disable/HostDisableButton.vue'
2527
import HostDisableAndEvacuateVmsButton from '@/modules/host/components/actions/disable-and-evacuate-vms/HostDisableAndEvacuateVmsButton.vue'
2628
import HostDownloadButton from '@/modules/host/components/actions/download/HostDownloadButton.vue'
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<template>
2+
<MenuItem
3+
v-tooltip="!canDetachHost && detachHostErrorMessage"
4+
class="detach"
5+
:disabled="!canDetachHost"
6+
icon="action:detach"
7+
:busy="isDetachingHost"
8+
@click="detachHost()"
9+
>
10+
{{ t('action:detach') }}
11+
</MenuItem>
12+
</template>
13+
14+
<script lang="ts" setup>
15+
import { useXoHostDetachJob } from '@/modules/host/jobs/xo-host-detach.job.ts'
16+
import type { FrontXoHost } from '@/modules/host/remote-resources/use-xo-host-collection.ts'
17+
import { useXoPoolCollection } from '@/modules/pool/remote-resources/use-xo-pool-collection.ts'
18+
import { useRedirectAfterDelete } from '@/shared/composables/redirect-after-delete.composable.ts'
19+
import MenuItem from '@core/components/menu/MenuItem.vue'
20+
import { useActionModal } from '@core/composables/modals/use-action-modal.ts'
21+
import { vTooltip } from '@core/directives/tooltip.directive.ts'
22+
import { useI18n } from 'vue-i18n'
23+
import { useRoute } from 'vue-router'
24+
25+
const { host } = defineProps<{
26+
host: FrontXoHost
27+
}>()
28+
29+
const { t } = useI18n()
30+
31+
const { hasPoolById } = useXoPoolCollection()
32+
33+
const route = useRoute<'/host/[id]'>()
34+
35+
const {
36+
run,
37+
canRun: canDetachHost,
38+
isRunning: isDetachingHost,
39+
errorMessage: detachHostErrorMessage,
40+
} = useXoHostDetachJob(() => host)
41+
42+
const { open: openActionModal } = useActionModal()
43+
44+
const { redirect: redirectAfterDetachHost } = useRedirectAfterDelete({
45+
isOnObjectPage: () => route.params.id === host.id,
46+
redirectTo: () => {
47+
if (hasPoolById(host.$pool)) {
48+
return { name: '/pool/[id]/hosts', params: { id: host.$pool } }
49+
}
50+
51+
return { name: '/(site)/dashboard' }
52+
},
53+
})
54+
55+
async function detachHost() {
56+
const { event } = await openActionModal({
57+
props: {
58+
accent: 'warning',
59+
action: 'detach',
60+
object: 'host',
61+
hostName: host.name_label,
62+
icon: 'status:warning-picto',
63+
},
64+
})
65+
66+
if (event !== 'onConfirm') {
67+
return
68+
}
69+
70+
await run()
71+
72+
await redirectAfterDetachHost()
73+
}
74+
</script>
75+
76+
<style lang="postcss" scoped>
77+
.detach {
78+
color: var(--color-warning-txt-base);
79+
}
80+
</style>

‎@xen-orchestra/web/src/modules/host/components/actions/disable/HostDisableButton.vue‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ function openDisableHostModal() {
3737
return openActionModal({
3838
events: { onConfirm: () => disableHost() },
3939
props: {
40-
accent: 'warning',
40+
accent: 'info',
4141
action: 'disable',
4242
object: 'host',
4343
hostName: host.name_label,
44-
icon: 'status:warning-picto',
44+
icon: 'status:info-picto',
4545
},
4646
})
4747
}

‎@xen-orchestra/web/src/modules/host/components/actions/enable/HostEnableButton.vue‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ function openEnableHostModal() {
4040
return openActionModal({
4141
events: { onConfirm: () => enableHost() },
4242
props: {
43-
accent: 'warning',
43+
accent: 'info',
4444
action: 'enable',
4545
object: 'host',
4646
hostName: host.name_label,
47-
icon: 'status:warning-picto',
47+
icon: 'status:info-picto',
4848
},
4949
})
5050
}

‎@xen-orchestra/web/src/modules/host/components/actions/shutdown/HostShutdownButton.vue‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ function shutdownHost() {
3939
onConfirm: () => run(),
4040
},
4141
props: {
42-
accent: 'warning',
42+
accent: 'info',
4343
action: 'shutdown',
4444
object: 'host',
4545
hostName: host.name_label,
46-
icon: 'status:warning-picto',
46+
icon: 'status:info-picto',
4747
},
4848
})
4949
}

‎@xen-orchestra/web/src/modules/host/components/actions/start/HostStartButton.vue‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ function startHost() {
3939
onConfirm: () => run(),
4040
},
4141
props: {
42-
accent: 'warning',
42+
accent: 'info',
4343
action: 'start',
4444
object: 'host',
4545
hostName: host.name_label,
46-
icon: 'status:warning-picto',
46+
icon: 'status:info-picto',
4747
},
4848
})
4949
}

0 commit comments

Comments
 (0)