Artyom Lukianov has uploaded a new change for review. Change subject: packaging: setup: check if host not exist under engine before add it ......................................................................
packaging: setup: check if host not exist under engine before add it Check if host already not exist under engine, before add it Change-Id: Id46cdd877c23ac3522998c9d579330b43857bf7b Bug-Url: https://bugzilla.redhat.com/1065350 Signed-off-by: Lukianov Artyom <[email protected]> --- M src/plugins/ovirt-hosted-engine-setup/engine/add_host.py 1 file changed, 47 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup refs/changes/02/40102/1 diff --git a/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py b/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py index 81071a7..95939ef 100644 --- a/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py +++ b/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py @@ -164,6 +164,17 @@ ) ) + def _get_host_uuid(self): + self.logger.debug('Acquiring UUID from localhost') + rc, stdout, stderr = self.execute( + (self.command.get('dmidecode'), '-s', 'system-uuid') + ) + if rc != 0: + self.logger.error( + _('Failed to retrieve uuid from localhost') + ) + return stdout[0] + def _wait_host_ready(self, engine_api, host): self.logger.info(_( 'Waiting for the host to become operational in the engine. ' @@ -421,6 +432,7 @@ self.command.detect('ip') self.command.detect('selinuxenabled') self.command.detect('restorecon') + self.command.detect('dmidecode') @plugin.event( stage=plugin.Stages.STAGE_CUSTOMIZATION, @@ -624,6 +636,41 @@ ohostedcons.EngineEnv.HOST_CLUSTER_NAME ] = cluster_name self.logger.debug('Adding the host to the cluster') + h_uuid = self._get_host_uuid() + host_hw_l = [ + h.get_hardware_information() for h in engine_api.hosts.list() + ] + uuid_l = [host_hw.get_uuid() for host_hw in host_hw_l] + if h_uuid in uuid_l: + response = None + while response is None: + response = self.dialog.queryString( + name='OVEHOSTED_ADD_EXIST_HOST', + note=_( + 'Host with the same UUID already exists ' + 'under engine. ' + 'Please remove host from engine or ' + 'abort deployment:\n\n' + '(1) Retry\n' + '(2) Abort Deployment\n' + '\n(@VALUES@)[@DEFAULT@]: ' + ), + prompt=True, + validValues=(_('1'), _('2')), + default=_('1'), + caseSensitive=False + ) + if response == _('1').lower(): + self.dialog.note( + _('Adding host to the engine...\n') + ) + elif response == _('2').lower(): + raise RuntimeError(_('HE deployment aborted by user')) + else: + self.logger.error( + 'Invalid option \'{0}\''.format(response) + ) + response = None engine_api.hosts.add( self._ovirtsdk_xml.params.Host( name=self.environment[ -- To view, visit https://gerrit.ovirt.org/40102 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id46cdd877c23ac3522998c9d579330b43857bf7b Gerrit-PatchSet: 1 Gerrit-Project: ovirt-hosted-engine-setup Gerrit-Branch: master Gerrit-Owner: Artyom Lukianov <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
