Simone Tiraboschi has uploaded a new change for review.

Change subject: packaging: setup: automatically shutdown engine VM on automated 
setup
......................................................................

packaging: setup: automatically shutdown engine VM on automated setup

Adding support for automatically shutdown engine VM on automated setup

Change-Id: I6417a76302f71fc47bfc84c20aef9203ec4f1548
Bug-Url: https://bugzilla.redhat.com/1120780
Signed-off-by: Simone Tiraboschi <[email protected]>
---
M src/ovirt_hosted_engine_setup/constants.py
M src/plugins/ovirt-hosted-engine-setup/ha/ha_services.py
2 files changed, 35 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup 
refs/changes/02/40802/1

diff --git a/src/ovirt_hosted_engine_setup/constants.py 
b/src/ovirt_hosted_engine_setup/constants.py
index b6f9d3f..1b629a0 100644
--- a/src/ovirt_hosted_engine_setup/constants.py
+++ b/src/ovirt_hosted_engine_setup/constants.py
@@ -756,6 +756,8 @@
     def CONSOLE_TYPE(self):
         return 'OVEHOSTED_VDSM/consoleType'
 
+    AUTOMATE_VM_SHUTDOWN = 'OVEHOSTED_VM/automateVMShutdown'
+
 
 @util.export
 @util.codegen
diff --git a/src/plugins/ovirt-hosted-engine-setup/ha/ha_services.py 
b/src/plugins/ovirt-hosted-engine-setup/ha/ha_services.py
index 40704e2..bba4e5e 100644
--- a/src/plugins/ovirt-hosted-engine-setup/ha/ha_services.py
+++ b/src/plugins/ovirt-hosted-engine-setup/ha/ha_services.py
@@ -51,6 +51,15 @@
         super(Plugin, self).__init__(context=context)
 
     @plugin.event(
+        stage=plugin.Stages.STAGE_INIT,
+    )
+    def _init(self):
+        self.environment.setdefault(
+            ohostedcons.VMEnv.AUTOMATE_VM_SHUTDOWN,
+            None
+        )
+
+    @plugin.event(
         stage=plugin.Stages.STAGE_PROGRAMS,
     )
     def _programs(self):
@@ -93,13 +102,31 @@
     def _closeup(self):
         # shutdown the vm if this is first host.
         if not self.environment[ohostedcons.CoreEnv.IS_ADDITIONAL_HOST]:
-            self.dialog.note(
-                _(
-                    'Please shutdown the VM allowing the system to launch it '
-                    'as a monitored service.\n'
-                    'The system will wait until the VM is down.'
+
+            if self.environment[
+                ohostedcons.VMEnv.AUTOMATE_VM_SHUTDOWN
+            ] is None:
+                self.environment[
+                    ohostedcons.VMEnv.AUTOMATE_VM_SHUTDOWN
+                ] = self.environment[
+                    ohostedcons.VMEnv.CLOUD_INIT_EXECUTE_ESETUP
+                ]
+
+            if self.environment[
+                ohostedcons.VMEnv.AUTOMATE_VM_SHUTDOWN
+            ]:
+                self.logger.info(_('Shutting down the engine VM'))
+                cli = self.environment[ohostedcons.VDSMEnv.VDS_CLI]
+                res = cli.shutdown(self.environment[ohostedcons.VMEnv.VM_UUID])
+                self.logger.debug(res)
+            else:
+                self.dialog.note(
+                    _(
+                        'Please shutdown the VM allowing the system '
+                        'to launch it as a monitored service.\n'
+                        'The system will wait until the VM is down.'
+                    )
                 )
-            )
             waiter = tasks.VMDownWaiter(self.environment)
             if not waiter.wait():
                 # The VM is down but not destroyed


-- 
To view, visit https://gerrit.ovirt.org/40802
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6417a76302f71fc47bfc84c20aef9203ec4f1548
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-hosted-engine-setup
Gerrit-Branch: master
Gerrit-Owner: Simone Tiraboschi <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to