[PATCH v2] configurator: bugfix for removing Service VM


Conghui Chen
 

When removing Service VM from UI, the post-launched VMs should also be
removed.
Besides, add a warning window when removing Service VM.

v1->v2: add a warining window

Signed-off-by: Conghui <conghui.chen@...>
---
.../configurator/src/lib/acrn.jsx | 9 +++++++++
.../ConfigureSettingsForScenario.jsx | 19 +++++++++++++++++--
2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/misc/config_tools/configurator/src/lib/acrn.jsx b/misc/config_tools/configurator/src/lib/acrn.jsx
index c0762da2a..39eea611e 100644
--- a/misc/config_tools/configurator/src/lib/acrn.jsx
+++ b/misc/config_tools/configurator/src/lib/acrn.jsx
@@ -217,6 +217,15 @@ export class ProgramLayer extends EventBase {
this.onScenarioDataUpdateEvent()
}

+ isServiceVM = (vmID) => {
+ for (var idx in this.scenarioData.vm.SERVICE_VM) {
+ if (this.scenarioData.vm.SERVICE_VM[idx]['@id'] === vmID) {
+ return true
+ }
+ }
+ return false
+ }
+
deleteVM = (vmID) => {
// call by view
for (let vmType in this.scenarioData.vm) {
diff --git a/misc/config_tools/configurator/src/pages/Config/ConfigureSettingsForScenario/ConfigureSettingsForScenario.jsx b/misc/config_tools/configurator/src/pages/Config/ConfigureSettingsForScenario/ConfigureSettingsForScenario.jsx
index 214c91f10..94d3ff862 100644
--- a/misc/config_tools/configurator/src/pages/Config/ConfigureSettingsForScenario/ConfigureSettingsForScenario.jsx
+++ b/misc/config_tools/configurator/src/pages/Config/ConfigureSettingsForScenario/ConfigureSettingsForScenario.jsx
@@ -47,6 +47,7 @@ export default class ConfigureSettingsForScenario extends Component {

render = () => {
let {configurator} = this.context
+ let scenarioData = configurator.programLayer.scenarioData
return (<Accordion.Item eventKey="2">
<Accordion.Header>
<div className="p-1 w-100 d-flex justify-content-between align-items-center">
@@ -74,7 +75,21 @@ export default class ConfigureSettingsForScenario extends Component {
</ul>
<Button className={'deleteVM ' + (this.state.VMID === -1 ? 'd-none' : '')}
size='lg' onClick={() => {
- configurator.programLayer.deleteVM(this.state.VMID)
+ if (configurator.programLayer.isServiceVM(this.state.VMID) == true) {
+ confirm("All post-launched VMs will be deleted together!!")
+ .then((r) => {
+ if (r) {
+ configurator.programLayer.deleteVM(this.state.VMID)
+ var len=scenarioData.vm.POST_LAUNCHED_VM.length
+ for (var idx=len-1; idx>=0; idx--) {
+ let postvm = scenarioData.vm.POST_LAUNCHED_VM[idx]
+ configurator.programLayer.deleteVM(postvm['@id'])
+ }
+ }
+ })
+ } else {
+ configurator.programLayer.deleteVM(this.state.VMID)
+ }
}}>
<FontAwesomeIcon icon={faMinus} color="white" size="lg"/> Delete VM
</Button>
@@ -90,4 +105,4 @@ export default class ConfigureSettingsForScenario extends Component {
</Accordion.Item>)
}
}
-ConfigureSettingsForScenario.contextType = ACRNContext
\ No newline at end of file
+ConfigureSettingsForScenario.contextType = ACRNContext
--
2.25.1

Join acrn-dev@lists.projectacrn.org to automatically receive all group messages.