Sandro Bonazzola has uploaded a new change for review.

Change subject: [wip] packaging: setup: additional host support
......................................................................

[wip] packaging: setup: additional host support

draft implementation of additional host support.
still in testing, missing ux for choosing host
identification inside the hosted engine, actually
conflicting with the first host identification.

Change-Id: Ibbfd842cb54bcb5bea6bd8bbca771202c6a1c2c9
Signed-off-by: Sandro Bonazzola <[email protected]>
---
M src/ovirt_hosted_engine_setup/constants.py
M src/plugins/ovirt-hosted-engine-setup/core/conf.py
M src/plugins/ovirt-hosted-engine-setup/engine/os_install.py
M src/plugins/ovirt-hosted-engine-setup/storage/storage.py
M src/plugins/ovirt-hosted-engine-setup/vm/boot_cdrom.py
M src/plugins/ovirt-hosted-engine-setup/vm/configurevm.py
M src/plugins/ovirt-hosted-engine-setup/vm/cpu.py
M src/plugins/ovirt-hosted-engine-setup/vm/image.py
M src/plugins/ovirt-hosted-engine-setup/vm/memory.py
M src/plugins/ovirt-hosted-engine-setup/vm/runvm.py
M templates/hosted-engine.conf.in
11 files changed, 139 insertions(+), 2 deletions(-)


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

diff --git a/src/ovirt_hosted_engine_setup/constants.py 
b/src/ovirt_hosted_engine_setup/constants.py
index 4293425..64f6ace 100644
--- a/src/ovirt_hosted_engine_setup/constants.py
+++ b/src/ovirt_hosted_engine_setup/constants.py
@@ -153,6 +153,7 @@
 @util.codegen
 class Const(object):
     MINIMUM_SPACE_STORAGEDOMAIN_MB = 20480
+    FIRST_HOST_ID = 1
 
 
 @util.export
@@ -160,6 +161,8 @@
 class CoreEnv(object):
     ANSWER_FILE = 'OVEHOSTED_CORE/answerFile'
     REQUIREMENTS_CHECK_ENABLED = 'OVEHOSTED_CORE/checkRequirements'
+    ADDITIONAL_HOST_ENABLED = 'OVEHOSTED_CORE/additionalHostEnabled'
+    IS_ADDITIONAL_HOST = 'OVEHOSTED_CORE/isAdditionalHost'
 
 
 @util.export
@@ -223,6 +226,11 @@
 @util.codegen
 @ohostedattrsclass
 class StorageEnv(object):
+    @ohostedattrs(
+        answerfile=True,
+    )
+    def HOST_ID(self):
+        return 'OVEHOSTED_STORAGE/hostID'
 
     @ohostedattrs(
         answerfile=True,
@@ -353,6 +361,7 @@
 class Stages(object):
     CONFIG_BOOT_DEVICE = 'ohosted.boot.configuration.available'
     CONFIG_STORAGE = 'ohosted.storage.configuration.available'
+    CONFIG_ADDITIONAL_HOST = 'ohosted.core.additional.host'
     VDSMD_START = 'ohosted.vdsm.started'
     VDSMD_PKI = 'ohosted.vdsm.pki.available'
     VDSMD_CONFIGURED = 'ohosted.vdsm.configured'
diff --git a/src/plugins/ovirt-hosted-engine-setup/core/conf.py 
b/src/plugins/ovirt-hosted-engine-setup/core/conf.py
index fce3825..a2ec1e5 100644
--- a/src/plugins/ovirt-hosted-engine-setup/core/conf.py
+++ b/src/plugins/ovirt-hosted-engine-setup/core/conf.py
@@ -84,6 +84,7 @@
                     ohostedcons.VMEnv.VM_UUID
                 ],
                 '@CONF_FILE@': ohostedcons.FileLocations.ENGINE_VM_CONF,
+                '@HOST_ID@': self.environment[ohostedcons.StorageEnv.HOST_ID],
             }
         )
         with transaction.Transaction() as localtransaction:
diff --git a/src/plugins/ovirt-hosted-engine-setup/engine/os_install.py 
b/src/plugins/ovirt-hosted-engine-setup/engine/os_install.py
index 92dca29..0bbbf5c 100644
--- a/src/plugins/ovirt-hosted-engine-setup/engine/os_install.py
+++ b/src/plugins/ovirt-hosted-engine-setup/engine/os_install.py
@@ -54,6 +54,9 @@
             ohostedcons.Stages.VM_RUNNING,
         ],
         name=ohostedcons.Stages.OS_INSTALLED,
+        condition=lambda self: not self.environment[
+            ohostedcons.CoreEnv.IS_ADDITIONAL_HOST
+        ],
     )
     def _misc(self):
         self.environment[ohostedcons.VMEnv.SUBST]['@BOOT@'] = 'c'
diff --git a/src/plugins/ovirt-hosted-engine-setup/storage/storage.py 
b/src/plugins/ovirt-hosted-engine-setup/storage/storage.py
index b029dcd..d043470 100644
--- a/src/plugins/ovirt-hosted-engine-setup/storage/storage.py
+++ b/src/plugins/ovirt-hosted-engine-setup/storage/storage.py
@@ -83,6 +83,80 @@
             raiseOnError=False
         )
 
+    def _handleAdditionalHost(self):
+        if not self.environment[
+            ohostedcons.CoreEnv.ADDITIONAL_HOST_ENABLED
+        ]:
+            self.environment[ohostedcons.CoreEnv.IS_ADDITIONAL_HOST] = False
+            self.logger.info(_('Installing on first host'))
+        else:
+            interactive = self.environment[
+                ohostedcons.CoreEnv.IS_ADDITIONAL_HOST
+            ] is None
+            if interactive:
+                self.logger.info('interactive')
+                self.environment[
+                    ohostedcons.CoreEnv.IS_ADDITIONAL_HOST
+                ] = self.dialog.queryString(
+                    name='ovehosted_additional_host',
+                    note=_(
+                        'The specified storage location already contains a '
+                        'data domain. Is this an additional host setup '
+                        '(@VALUES@) [@DEFAULT@] ?'
+                    ),
+                    prompt=True,
+                    validValues=[_('Yes'), _('No')],
+                    caseSensitive=False,
+                    default=_('Yes')
+                ) == _('Yes').lower()
+        if not self.environment[ohostedcons.CoreEnv.IS_ADDITIONAL_HOST]:
+            self.environment[
+                ohostedcons.StorageEnv.HOST_ID
+            ] = ohostedcons.Const.FIRST_HOST_ID
+        else:
+            self.logger.info(_('Installing on additional host'))
+            interactive = self.environment[
+                ohostedcons.StorageEnv.HOST_ID
+            ] is None
+            valid = False
+            while not valid:
+                if interactive:
+                    self.environment[
+                        ohostedcons.StorageEnv.HOST_ID
+                    ] = self.dialog.queryString(
+                        name='ovehosted_host_id',
+                        note=_(
+                            'Please specify the Host ID '
+                            '[Must be integer: @DEFAULT@]: '
+                        ),
+                        prompt=True,
+                        default=ohostedcons.Const.FIRST_HOST_ID + 1,
+                    )
+                try:
+                    valid = True
+                    if int(
+                        self.environment[ohostedcons.StorageEnv.HOST_ID]
+                    ) == ohostedcons.Const.FIRST_HOST_ID:
+                        valid = False
+                        if interactive:
+                            self.logger.error(
+                                _('Cannot use the same ID used by first host')
+                            )
+                        else:
+                            raise RuntimeError(
+                                _('Cannot use the same ID used by first host')
+                            )
+                except ValueError:
+                    valid = False
+                    if interactive:
+                        self.logger.error(
+                            _('Invalid value for Host ID: must be integer')
+                        )
+                    else:
+                        raise RuntimeError(
+                            _('Invalid value for Host ID: must be integer')
+                        )
+
     def _validateDomain(self, connection):
         path = tempfile.mkdtemp()
         try:
@@ -110,6 +184,10 @@
             ):
                 self.domain_exists = True
                 self.environment[
+                    ohostedcons.CoreEnv.ADDITIONAL_HOST_ENABLED
+                ] = True
+                self._handleAdditionalHost()
+                self.environment[
                     ohostedcons.StorageEnv.STORAGE_DOMAIN_NAME
                 ] = domain_info['name']
 
@@ -132,6 +210,10 @@
                 break
         if not self.domain_exists:
             self._storageServerConnection(disconnect=True)
+        else:
+            self.environment[
+                ohostedcons.CoreEnv.ADDITIONAL_HOST_ENABLED
+            ] = True
 
     def _getStorageDomainsList(self, spUUID=None):
         if not spUUID:
@@ -247,7 +329,7 @@
         self.logger.debug('connectStoragePool')
         spUUID = self.environment[ohostedcons.StorageEnv.SP_UUID]
         sdUUID = self.environment[ohostedcons.StorageEnv.SD_UUID]
-        ID = 1
+        ID = self.environment[ohostedcons.StorageEnv.HOST_ID]
         scsi_key = spUUID
         master = sdUUID
         master_ver = 1
@@ -331,6 +413,18 @@
             ohostedcons.StorageEnv.DOMAIN_TYPE,
             None
         )
+        self.environment.setdefault(
+            ohostedcons.StorageEnv.HOST_ID,
+            None
+        )
+        self.environment.setdefault(
+            ohostedcons.CoreEnv.ADDITIONAL_HOST_ENABLED,
+            False
+        )
+        self.environment.setdefault(
+            ohostedcons.CoreEnv.IS_ADDITIONAL_HOST,
+            None
+        )
 
     @plugin.event(
         stage=plugin.Stages.STAGE_SETUP,
diff --git a/src/plugins/ovirt-hosted-engine-setup/vm/boot_cdrom.py 
b/src/plugins/ovirt-hosted-engine-setup/vm/boot_cdrom.py
index a6bd351..765ca51 100644
--- a/src/plugins/ovirt-hosted-engine-setup/vm/boot_cdrom.py
+++ b/src/plugins/ovirt-hosted-engine-setup/vm/boot_cdrom.py
@@ -86,7 +86,8 @@
             ohostedcons.Stages.CONFIG_BOOT_DEVICE,
         ],
         condition=lambda self: (
-            self.environment[ohostedcons.VMEnv.BOOT] == 'cdrom'
+            self.environment[ohostedcons.VMEnv.BOOT] == 'cdrom' and
+            not self.environment[ohostedcons.CoreEnv.IS_ADDITIONAL_HOST]
         )
     )
     def _customization(self):
diff --git a/src/plugins/ovirt-hosted-engine-setup/vm/configurevm.py 
b/src/plugins/ovirt-hosted-engine-setup/vm/configurevm.py
index d014bee..9033c1c 100644
--- a/src/plugins/ovirt-hosted-engine-setup/vm/configurevm.py
+++ b/src/plugins/ovirt-hosted-engine-setup/vm/configurevm.py
@@ -81,6 +81,9 @@
     @plugin.event(
         stage=plugin.Stages.STAGE_CUSTOMIZATION,
         name=ohostedcons.Stages.CONFIG_BOOT_DEVICE,
+        condition=lambda self: not self.environment[
+            ohostedcons.CoreEnv.IS_ADDITIONAL_HOST
+        ],
     )
     def _customization(self):
         #TODO: support boot from OVF
@@ -133,6 +136,9 @@
             ohostedcons.Stages.BRIDGE_AVAILABLE,
         ],
         name=ohostedcons.Stages.VM_CONFIGURED,
+        condition=lambda self: not self.environment[
+            ohostedcons.CoreEnv.IS_ADDITIONAL_HOST
+        ],
     )
     def _misc(self):
         self.logger.info(_('Configuring VM'))
diff --git a/src/plugins/ovirt-hosted-engine-setup/vm/cpu.py 
b/src/plugins/ovirt-hosted-engine-setup/vm/cpu.py
index a47ab16..5c3d208 100644
--- a/src/plugins/ovirt-hosted-engine-setup/vm/cpu.py
+++ b/src/plugins/ovirt-hosted-engine-setup/vm/cpu.py
@@ -56,6 +56,9 @@
 
     @plugin.event(
         stage=plugin.Stages.STAGE_CUSTOMIZATION,
+        condition=lambda self: not self.environment[
+            ohostedcons.CoreEnv.IS_ADDITIONAL_HOST
+        ],
     )
     def _customization(self):
         interactive = self.environment[
diff --git a/src/plugins/ovirt-hosted-engine-setup/vm/image.py 
b/src/plugins/ovirt-hosted-engine-setup/vm/image.py
index 790b182..720f815 100644
--- a/src/plugins/ovirt-hosted-engine-setup/vm/image.py
+++ b/src/plugins/ovirt-hosted-engine-setup/vm/image.py
@@ -68,6 +68,9 @@
 
     @plugin.event(
         stage=plugin.Stages.STAGE_CUSTOMIZATION,
+        condition=lambda self: not self.environment[
+            ohostedcons.CoreEnv.IS_ADDITIONAL_HOST
+        ],
     )
     def _disk_customization(self):
         interactive = self.environment[
@@ -135,6 +138,9 @@
             ohostedcons.Stages.STORAGE_AVAILABLE,
         ],
         name=ohostedcons.Stages.VM_IMAGE_AVAILABLE,
+        condition=lambda self: not self.environment[
+            ohostedcons.CoreEnv.IS_ADDITIONAL_HOST
+        ],
     )
     def _misc(self):
         sdUUID = self.environment[ohostedcons.StorageEnv.SD_UUID]
diff --git a/src/plugins/ovirt-hosted-engine-setup/vm/memory.py 
b/src/plugins/ovirt-hosted-engine-setup/vm/memory.py
index a9dc84d..4686c7a 100644
--- a/src/plugins/ovirt-hosted-engine-setup/vm/memory.py
+++ b/src/plugins/ovirt-hosted-engine-setup/vm/memory.py
@@ -56,6 +56,9 @@
 
     @plugin.event(
         stage=plugin.Stages.STAGE_CUSTOMIZATION,
+        condition=lambda self: not self.environment[
+            ohostedcons.CoreEnv.IS_ADDITIONAL_HOST
+        ],
     )
     def _customization(self):
         interactive = self.environment[
diff --git a/src/plugins/ovirt-hosted-engine-setup/vm/runvm.py 
b/src/plugins/ovirt-hosted-engine-setup/vm/runvm.py
index ada27df..39428ae 100644
--- a/src/plugins/ovirt-hosted-engine-setup/vm/runvm.py
+++ b/src/plugins/ovirt-hosted-engine-setup/vm/runvm.py
@@ -198,6 +198,9 @@
 
     @plugin.event(
         stage=plugin.Stages.STAGE_CUSTOMIZATION,
+        condition=lambda self: not self.environment[
+            ohostedcons.CoreEnv.IS_ADDITIONAL_HOST
+        ],
     )
     def _customization(self):
         validConsole = False
@@ -243,6 +246,9 @@
         stage=plugin.Stages.STAGE_CLOSEUP,
         name=ohostedcons.Stages.VM_RUNNING,
         priority=plugin.Stages.PRIORITY_LOW,
+        condition=lambda self: not self.environment[
+            ohostedcons.CoreEnv.IS_ADDITIONAL_HOST
+        ],
     )
     def _boot_from_install_media(self):
         #Need to be done after firewall closeup for allowing the user to
@@ -304,6 +310,9 @@
             ohostedcons.Stages.OS_INSTALLED,
         ],
         name=ohostedcons.Stages.INSTALLED_VM_RUNNING,
+        condition=lambda self: not self.environment[
+            ohostedcons.CoreEnv.IS_ADDITIONAL_HOST
+        ],
     )
     def _boot_from_hd(self):
         self._create()
diff --git a/templates/hosted-engine.conf.in b/templates/hosted-engine.conf.in
index c84ef95..395c112 100644
--- a/templates/hosted-engine.conf.in
+++ b/templates/hosted-engine.conf.in
@@ -4,3 +4,5 @@
 storage=@SHARED_STORAGE@
 conf=@CONF_FILE@
 service_start_time=0
+host_id=@HOST_ID@
+console=@CONSOLE_TYPE@


-- 
To view, visit http://gerrit.ovirt.org/17083
To unsubscribe, visit http://gerrit.ovirt.org/settings

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

Reply via email to