File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020 </template >
2121 <HostPowerStateActions :host />
2222 </MenuList >
23+
24+ <MenuList placement="bottom-end">
25+ <template #trigger =" { open } " >
26+ <UiButtonIcon
27+ v-tooltip =" {
28+ placement: ' left' ,
29+ content: t (' more-actions' ),
30+ } "
31+ icon="action:more-actions "
32+ accent="brand"
33+ size="medium"
34+ @click =" open ($event )"
35+ />
36+ </template >
37+ <HostMoreActions :host />
38+ </MenuList >
2339 </template >
2440 </UiHeadBar >
2541</template >
2642
2743<script lang="ts" setup>
2844import type { XenApiHost } from ' @/libs/xen-api/xen-api.types.ts'
2945import HostPowerStateActions from ' @/modules/host/components/actions/HostPowerStateActions.vue'
46+ import HostMoreActions from ' @/modules/host/components/HostMoreActions.vue'
3047import { useHostUtils } from ' @/modules/host/composables/host-utils.composable.ts'
3148import { useHostMetricsStore } from ' @/stores/xen-api/host-metrics.store.ts'
3249import { usePoolStore } from ' @/stores/xen-api/pool.store.ts'
3350import VtsIcon from ' @core/components/icon/VtsIcon.vue'
3451import MenuList from ' @core/components/menu/MenuList.vue'
3552import VtsObjectIcon from ' @core/components/object-icon/VtsObjectIcon.vue'
53+ import UiButtonIcon from ' @core/components/ui/button-icon/UiButtonIcon.vue'
3654import UiDropdownButton from ' @core/components/ui/dropdown-button/UiDropdownButton.vue'
3755import UiHeadBar from ' @core/components/ui/head-bar/UiHeadBar.vue'
3856import { vTooltip } from ' @core/directives/tooltip.directive.ts'
Original file line number Diff line number Diff line change 3333 @click =" open ($event )"
3434 />
3535 </template >
36- <HostTreeActions :host />
36+ <HostMoreActions :host show-change-state-button />
3737 </MenuList >
3838 </template >
3939 </UiTreeItemLabel >
4848<script lang="ts" setup>
4949import InfraVmItems from ' @/components/infra/InfraVmItems.vue'
5050import type { XenApiHost } from ' @/libs/xen-api/xen-api.types.ts'
51- import HostTreeActions from ' @/modules/host/components/actions/HostTreeActions .vue'
51+ import HostMoreActions from ' @/modules/host/components/HostMoreActions .vue'
5252import { useHostUtils } from ' @/modules/host/composables/host-utils.composable.ts'
5353import { useHostStore } from ' @/stores/xen-api/host.store.ts'
5454import { usePoolStore } from ' @/stores/xen-api/pool.store.ts'
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ export function createHostOperations(xenApi: XenApi) {
1616
1717 const shutdown = ( hostRef : HostRef ) => xenApi . call ( 'host.shutdown' , [ hostRef ] )
1818
19+ const destroy = ( hostRef : HostRef ) => xenApi . call ( 'host.destroy' , [ hostRef ] )
20+
1921 const clearHost = async ( hostRef : HostRef , force : boolean ) => {
2022 await disable ( hostRef )
2123
@@ -33,6 +35,8 @@ export function createHostOperations(xenApi: XenApi) {
3335
3436 return {
3537 powerOn,
38+ shutdown,
39+ destroy,
3640 cleanReboot : async ( hostRef : HostRef , forceReboot : boolean ) => {
3741 await clearHost ( hostRef , forceReboot )
3842
Original file line number Diff line number Diff line change 11<template >
2- <MenuItem icon="action:change-state " class="change-state">
2+ <MenuItem v-if = " showChangeStateButton " icon="action:change-state " class="change-state">
33 {{ t('action:change-state') }}
44 <template #submenu >
55 <HostPowerStateActions :host />
66 </template >
77 </MenuItem >
8+ <HostForgetButton :host />
89 <VtsDivider type="stretch" />
910 <HostDownloadButton :host-opaque-ref =" host .$ref " />
1011</template >
1112
1213<script setup lang="ts">
1314import type { XenApiHost } from ' @/libs/xen-api/xen-api.types.ts'
1415import HostDownloadButton from ' @/modules/host/components/actions/download/HostDownloadButton.vue'
16+ import HostForgetButton from ' @/modules/host/components/actions/forget/HostForgetButton.vue'
1517import HostPowerStateActions from ' @/modules/host/components/actions/HostPowerStateActions.vue'
1618import VtsDivider from ' @core/components/divider/VtsDivider.vue'
1719import MenuItem from ' @core/components/menu/MenuItem.vue'
1820import { useI18n } from ' vue-i18n'
1921
2022defineProps <{
2123 host: XenApiHost
24+ showChangeStateButton? : boolean
2225}>()
2326
2427const { t } = useI18n ()
Original file line number Diff line number Diff line change 1+ <template >
2+ <MenuItem
3+ v-tooltip =" ! canForgetHost && forgetHostErrorMessage "
4+ :busy =" isForgettingHost "
5+ class="host-forget-button"
6+ :disabled =" ! canForgetHost "
7+ icon="action:forget "
8+ @click =" forgetHost ()"
9+ >
10+ {{ t('action:forget') }}
11+ </MenuItem >
12+ </template >
13+
14+ <script lang="ts" setup>
15+ import type { XenApiHost } from ' @/libs/xen-api/xen-api.types.ts'
16+ import { useHostForgetJob } from ' @/modules/host/jobs/host-forget.job.ts'
17+ import MenuItem from ' @core/components/menu/MenuItem.vue'
18+ import { useActionModal } from ' @core/composables/modals/use-action-modal.ts'
19+ import { vTooltip } from ' @core/directives/tooltip.directive.ts'
20+ import { useI18n } from ' vue-i18n'
21+
22+ const { host } = defineProps <{
23+ host: XenApiHost
24+ }>()
25+
26+ const { t } = useI18n ()
27+
28+ const { open : openActionModal } = useActionModal ()
29+
30+ const {
31+ run,
32+ canRun : canForgetHost,
33+ isRunning : isForgettingHost,
34+ errorMessage : forgetHostErrorMessage,
35+ } = useHostForgetJob (() => host )
36+
37+ function forgetHost() {
38+ return openActionModal ({
39+ props: {
40+ accent: ' danger' ,
41+ action: ' forget' ,
42+ object: ' host' ,
43+ hostName: host .name_label ,
44+ icon: ' status:danger-circle' ,
45+ },
46+ events: {
47+ onConfirm : async () => {
48+ void run ()
49+ },
50+ },
51+ })
52+ }
53+ </script >
54+
55+ <style lang="postcss" scoped>
56+ .host-forget-button {
57+ color : var (--color-danger-item-base );
58+ }
59+ </style >
Original file line number Diff line number Diff line change 1+ import { hostArg } from '@/modules/host/jobs/host-args.ts'
2+ import { useHostMetricsStore } from '@/stores/xen-api/host-metrics.store.ts'
3+ import { useXenApiStore } from '@/stores/xen-api.store.ts'
4+ import { defineJob , JobError , JobRunningError } from '@core/packages/job'
5+ import { useI18n } from 'vue-i18n'
6+
7+ export const useHostForgetJob = defineJob ( 'host.forget' , [ hostArg ] , ( ) => {
8+ const xapi = useXenApiStore ( ) . getXapi ( )
9+ const { t } = useI18n ( )
10+ const { isHostHalted } = useHostMetricsStore ( ) . subscribe ( )
11+
12+ return {
13+ run : host => xapi . host . destroy ( host . $ref ) ,
14+
15+ validate : ( isRunning , host ) => {
16+ if ( host === undefined ) {
17+ throw new JobError ( t ( 'job:host-forget:missing-host' ) )
18+ }
19+
20+ if ( ! isHostHalted ( host ) ) {
21+ throw new JobError ( t ( 'job:host-forget:bad-power-state' ) )
22+ }
23+
24+ if ( isRunning ) {
25+ throw new JobRunningError ( t ( 'job:host-forget:in-progress' ) )
26+ }
27+ } ,
28+ }
29+ } )
You can’t perform that action at this time.
0 commit comments