From 8a91a6a857985f9b827eb8cec49c2eabce6a445e Mon Sep 17 00:00:00 2001 From: Reet Srivastava Date: Tue, 16 Sep 2025 15:23:10 +0530 Subject: [PATCH] feat: Add Unrescue feature to nova instance actions Change-Id: I64be95aa88fd1e4ed063bbbaef86b3696862b50a Signed-off-by: Reet Srivastava --- .../containers/Instance/actions/Unrescue.jsx | 37 +++++++++++++++++++ .../containers/Instance/actions/index.jsx | 2 + src/stores/nova/instance.js | 10 ++++- 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/pages/compute/containers/Instance/actions/Unrescue.jsx diff --git a/src/pages/compute/containers/Instance/actions/Unrescue.jsx b/src/pages/compute/containers/Instance/actions/Unrescue.jsx new file mode 100644 index 00000000..78b41856 --- /dev/null +++ b/src/pages/compute/containers/Instance/actions/Unrescue.jsx @@ -0,0 +1,37 @@ +import { ConfirmAction } from 'src/containers/Action'; +import globalServerStore from 'src/stores/nova/instance'; +import { isNotLockedOrAdmin, checkStatus } from 'resources/nova/instance'; + +export default class UnRescueInstanceAction extends ConfirmAction { + get id() { + return 'unrescue'; + } + + get title() { + return t('Unrescue'); + } + + get buttonText() { + return t('Unrescue'); + } + + get isAsyncAction() { + return true; + } + + allowedCheckFunc = (item) => { + if (!item) { + return true; + } + // Allow Unrescue only if instance is rescue and not locked + return ( + isNotLockedOrAdmin(item, this.isAdminPage) && + checkStatus(['rescue'], item) + ); + }; + + onSubmit = (item) => { + const { id } = item || this.item; + return globalServerStore.unrescue({ id }); + }; +} diff --git a/src/pages/compute/containers/Instance/actions/index.jsx b/src/pages/compute/containers/Instance/actions/index.jsx index a2de4cd7..cd9adfb4 100644 --- a/src/pages/compute/containers/Instance/actions/index.jsx +++ b/src/pages/compute/containers/Instance/actions/index.jsx @@ -49,6 +49,7 @@ import ConfirmResize from './ConfirmResize'; import RevertResize from './RevertResize'; import ModifyTags from './ModifyTags'; import Rescue from './Rescue'; +import Unrescue from './Unrescue'; const statusActions = [ StartAction, @@ -64,6 +65,7 @@ const statusActions = [ Shelve, Unshelve, Rescue, + Unrescue, ]; const resourceActions = [ diff --git a/src/stores/nova/instance.js b/src/stores/nova/instance.js index 286d6b8d..596590e4 100644 --- a/src/stores/nova/instance.js +++ b/src/stores/nova/instance.js @@ -238,7 +238,7 @@ export class ServerStore extends Base { sgItems = result.map((it) => this.mapperSecurityGroupRule(it.security_group) ); - } catch (e) { } + } catch (e) {} this.securityGroups = { data: sgItems || [], interfaces: ports, @@ -356,6 +356,14 @@ export class ServerStore extends Base { return this.client.action(id, rescue); } + @action + async unrescue({ id }) { + const body = { + unrescue: null, + }; + return this.operation({ body, id }); + } + @action async softReboot({ id }) { const body = {