Sandro Bonazzola has uploaded a new change for review. Change subject: packaging: setup: storage: refactored plugin ......................................................................
packaging: setup: storage: refactored plugin Refactored storage plugin splitting NFS specific code in a new nfs plugin. Will allow to add iSCSI specific code in its own plugin. Change-Id: Ided3e1f8e71abc2d0e3ec80e1cd2c2f3cca1f1df Signed-off-by: Sandro Bonazzola <sbona...@redhat.com> --- M src/ovirt_hosted_engine_setup/constants.py M src/plugins/ovirt-hosted-engine-setup/core/remote_answerfile.py M src/plugins/ovirt-hosted-engine-setup/storage/Makefile.am M src/plugins/ovirt-hosted-engine-setup/storage/__init__.py A src/plugins/ovirt-hosted-engine-setup/storage/nfs.py M src/plugins/ovirt-hosted-engine-setup/storage/storage.py 6 files changed, 422 insertions(+), 324 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup refs/changes/88/26488/1 diff --git a/src/ovirt_hosted_engine_setup/constants.py b/src/ovirt_hosted_engine_setup/constants.py index fcaf500..068e0cc 100644 --- a/src/ovirt_hosted_engine_setup/constants.py +++ b/src/ovirt_hosted_engine_setup/constants.py @@ -594,7 +594,9 @@ @util.codegen class Stages(object): CONFIG_BOOT_DEVICE = 'ohosted.boot.configuration.available' - CONFIG_STORAGE = 'ohosted.storage.configuration.available' + CONFIG_STORAGE_EARLY = 'ohosted.storage.configuration.early' + CONFIG_STORAGE_LATE = 'ohosted.storage.configuration.late' + CONFIG_STORAGE_NFS = 'ohosted.storage.nfs.configuration.available' CONFIG_ADDITIONAL_HOST = 'ohosted.core.additional.host' REQUIRE_ANSWER_FILE = 'ohosted.core.require.answerfile' CONFIG_OVF_IMPORT = 'ohosted.configuration.ovf' diff --git a/src/plugins/ovirt-hosted-engine-setup/core/remote_answerfile.py b/src/plugins/ovirt-hosted-engine-setup/core/remote_answerfile.py index 8294597..de6a8b1 100644 --- a/src/plugins/ovirt-hosted-engine-setup/core/remote_answerfile.py +++ b/src/plugins/ovirt-hosted-engine-setup/core/remote_answerfile.py @@ -1,6 +1,6 @@ # # ovirt-hosted-engine-setup -- ovirt hosted engine setup -# Copyright (C) 2013 Red Hat, Inc. +# Copyright (C) 2013-2014 Red Hat, Inc. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -224,7 +224,7 @@ name=ohostedcons.Stages.REQUIRE_ANSWER_FILE, stage=plugin.Stages.STAGE_CUSTOMIZATION, after=( - ohostedcons.Stages.CONFIG_STORAGE, + ohostedcons.Stages.DIALOG_TITLES_E_STORAGE, ohostedcons.Stages.DIALOG_TITLES_S_SYSTEM, ), before=( diff --git a/src/plugins/ovirt-hosted-engine-setup/storage/Makefile.am b/src/plugins/ovirt-hosted-engine-setup/storage/Makefile.am index e70aa6d..1ce7bd8 100644 --- a/src/plugins/ovirt-hosted-engine-setup/storage/Makefile.am +++ b/src/plugins/ovirt-hosted-engine-setup/storage/Makefile.am @@ -1,6 +1,6 @@ # # ovirt-hosted-engine-setup -- ovirt with a manager in a VM -# Copyright (C) 2013 Red Hat, Inc. +# Copyright (C) 2013-2014 Red Hat, Inc. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -26,6 +26,7 @@ mydir=$(ovirthostedengineplugindir)/ovirt-hosted-engine-setup/storage dist_my_PYTHON = \ __init__.py \ + nfs.py \ storage.py \ $(NULL) diff --git a/src/plugins/ovirt-hosted-engine-setup/storage/__init__.py b/src/plugins/ovirt-hosted-engine-setup/storage/__init__.py index e77a3d2..4c8f748 100644 --- a/src/plugins/ovirt-hosted-engine-setup/storage/__init__.py +++ b/src/plugins/ovirt-hosted-engine-setup/storage/__init__.py @@ -1,6 +1,6 @@ # # ovirt-hosted-engine-setup -- ovirt hosted engine setup -# Copyright (C) 2013 Red Hat, Inc. +# Copyright (C) 2013-2014 Red Hat, Inc. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -24,11 +24,13 @@ from otopi import util +from . import nfs from . import storage @util.export def createPlugins(context): + nfs.Plugin(context=context) storage.Plugin(context=context) diff --git a/src/plugins/ovirt-hosted-engine-setup/storage/nfs.py b/src/plugins/ovirt-hosted-engine-setup/storage/nfs.py new file mode 100644 index 0000000..fa62b38 --- /dev/null +++ b/src/plugins/ovirt-hosted-engine-setup/storage/nfs.py @@ -0,0 +1,269 @@ +# +# ovirt-hosted-engine-setup -- ovirt hosted engine setup +# Copyright (C) 2014 Red Hat, Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# + + +""" +Local storage domain plugin. +""" + +import os +import gettext +import tempfile +import time + + +from otopi import util +from otopi import plugin + + +from ovirt_hosted_engine_setup import constants as ohostedcons +from ovirt_hosted_engine_setup import domains as ohosteddomains + + +_ = lambda m: gettext.dgettext(message=m, domain='ovirt-hosted-engine-setup') + + +@util.export +class Plugin(plugin.PluginBase): + """ + NFS / GlusterFS storage plugin. + """ + + UMOUNT_TRIES = 10 + + def __init__(self, context): + super(Plugin, self).__init__(context=context) + self._checker = ohosteddomains.DomainChecker() + + def _mount(self, path, connection, domain_type): + fstype = '' + opts = [] + + if domain_type == 'nfs3': + fstype = 'nfs' + opts.append('vers=3') + elif domain_type == 'nfs4': + fstype = 'nfs' + opts.append('vers=4') + + if fstype == 'nfs': + opts.append('retry=1') + + mount_cmd = ( + self.command.get('mount'), + '-t%s' % fstype, + ) + + if opts: + mount_cmd += ( + '-o%s' % ','.join(opts), + ) + + mount_cmd += ( + connection, + path, + ) + + rc, _stdout, stderr = self.execute( + mount_cmd, + raiseOnError=False + ) + error = '\n'.join(stderr) + if rc != 0: + self.logger.error( + _( + 'Error while mounting specified storage path: {error}' + ).format( + error=error, + ) + ) + raise RuntimeError(error) + + def _umount(self, path): + rc = -1 + tries = self.UMOUNT_TRIES + while tries > 0: + rc, _stdout, _stderr = self.execute( + ( + self.command.get('umount'), + path + ), + raiseOnError=False + ) + if rc == 0: + tries = -1 + else: + tries -= 1 + time.sleep(1) + #rc, stdout and stderr are automatically logged as debug + self.execute( + ( + self.command.get('lsof'), + '+D%s' % path, + '-xfl' + ), + raiseOnError=False + ) + return rc + + def _check_domain_rights(self, path): + rc, _stdout, _stderr = self.execute( + ( + self.command.get('sudo'), + '-u', 'vdsm', + '-g', 'kvm', + 'test', + '-r', path, + '-a', + '-w', path, + '-a', + '-x', path, + ), + raiseOnError=False + ) + if rc != 0: + raise RuntimeError( + _( + 'permission settings on the specified storage do not ' + 'allow access to the storage to vdsm user and kvm group. ' + 'Verify permission settings on the specified storage ' + 'or specify another location' + ) + ) + + def _validateDomain(self, connection, domain_type): + path = tempfile.mkdtemp() + try: + self._mount(path, connection, domain_type) + self._checker.check_valid_path(path) + self._check_domain_rights(path) + self._checker.check_base_writable(path) + self._checker.check_available_space( + path, + ohostedcons.Const.MINIMUM_SPACE_STORAGEDOMAIN_MB + ) + finally: + if self._umount(path) == 0: + os.rmdir(path) + else: + self.logger.warning( + _('Cannot unmount {path}').format( + path=path, + ) + ) + + @plugin.event( + stage=plugin.Stages.STAGE_SETUP, + ) + def _setup(self): + self.command.detect('lsof') + self.command.detect('sudo') + self.command.detect('mount') + self.command.detect('umount') + + @plugin.event( + stage=plugin.Stages.STAGE_CUSTOMIZATION, + name=ohostedcons.Stages.CONFIG_STORAGE_NFS, + after=( + ohostedcons.Stages.CONFIG_STORAGE_EARLY, + ), + before=( + ohostedcons.Stages.CONFIG_STORAGE_LATE, + ), + condition=( + lambda self: self.environment[ + ohostedcons.StorageEnv.DOMAIN_TYPE + ] in ( + #glusterfs, + 'nfs3', + 'nfs4', + ) + ), + ) + def _customization(self): + interactive = self.environment[ + ohostedcons.StorageEnv.STORAGE_DOMAIN_CONNECTION + ] is None + validDomain = False + while not validDomain: + if interactive: + self.environment[ + ohostedcons.StorageEnv.STORAGE_DOMAIN_CONNECTION + ] = self.dialog.queryString( + name='OVEHOSTED_STORAGE_DOMAIN_CONNECTION', + note=_( + 'Please specify the full shared storage ' + 'connection path to use (example: host:/path): ' + ), + prompt=True, + caseSensitive=True, + ) + try: + self._validateDomain( + connection=self.environment[ + ohostedcons.StorageEnv.STORAGE_DOMAIN_CONNECTION + ], + domain_type=self.environment[ + ohostedcons.StorageEnv.DOMAIN_TYPE + ], + ) + validDomain = True + except (ValueError, RuntimeError) as e: + if interactive: + self.logger.debug('exception', exc_info=True) + self.logger.error( + _( + 'Cannot access storage connection ' + '{connection}: {error}' + ).format( + connection=self.environment[ + ohostedcons.StorageEnv. + STORAGE_DOMAIN_CONNECTION + ], + error=e, + ) + ) + else: + raise e + except ohosteddomains.InsufficientSpaceError as e: + self.logger.debug('exception', exc_info=True) + self.logger.debug(e) + min_requirement = '%0.2f' % ( + ohostedcons.Const.MINIMUM_SPACE_STORAGEDOMAIN_MB / 1024.0 + ) + if interactive: + self.logger.error( + _( + 'Storage domain for self hosted engine ' + 'is too small: ' + 'you should have at least {min_r} GB free'.format( + min_r=min_requirement, + ) + ) + ) + else: + raise RuntimeError( + _( + 'Storage domain for self hosted engine ' + 'is too small: ' + 'you should have at least {min_r} GB free'.format( + min_r=min_requirement, + ) + ) + ) diff --git a/src/plugins/ovirt-hosted-engine-setup/storage/storage.py b/src/plugins/ovirt-hosted-engine-setup/storage/storage.py index e19e052..d3f776b 100644 --- a/src/plugins/ovirt-hosted-engine-setup/storage/storage.py +++ b/src/plugins/ovirt-hosted-engine-setup/storage/storage.py @@ -1,6 +1,6 @@ # # ovirt-hosted-engine-setup -- ovirt hosted engine setup -# Copyright (C) 2013 Red Hat, Inc. +# Copyright (C) 2013-2014 Red Hat, Inc. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -22,13 +22,10 @@ Local storage domain plugin. """ -import os import re import uuid import gettext import stat -import tempfile -import time from otopi import constants as otopicons @@ -37,7 +34,6 @@ from ovirt_hosted_engine_setup import constants as ohostedcons -from ovirt_hosted_engine_setup import domains as ohosteddomains from ovirt_hosted_engine_setup import tasks from ovirt_hosted_engine_setup import util as ohostedutil @@ -58,7 +54,6 @@ GLUSTERFS_DOMAIN = 7 DATA_DOMAIN = 1 - UMOUNT_TRIES = 10 _RE_NOT_ALPHANUMERIC = re.compile(r"[^-\w]") _NOT_VALID_NAME_MSG = _( @@ -70,7 +65,6 @@ def __init__(self, context): super(Plugin, self).__init__(context=context) - self._checker = ohosteddomains.DomainChecker() self.vdsClient = util.loadModule( path=ohostedcons.FileLocations.VDS_CLIENT_DIR, name='vdsClient' @@ -83,77 +77,6 @@ self.pool_exists = False self._connected = False self._monitoring = False - - def _mount(self, path, connection, domain_type): - fstype = '' - opts = [] - - if domain_type == 'nfs3': - fstype = 'nfs' - opts.append('vers=3') - elif domain_type == 'nfs4': - fstype = 'nfs' - opts.append('vers=4') - - if fstype == 'nfs': - opts.append('retry=1') - - mount_cmd = ( - self.command.get('mount'), - '-t%s' % fstype, - ) - - if opts: - mount_cmd += ( - '-o%s' % ','.join(opts), - ) - - mount_cmd += ( - connection, - path, - ) - - rc, stdout, stderr = self.execute( - mount_cmd, - raiseOnError=False - ) - error = '\n'.join(stderr) - if rc != 0: - self.logger.error( - _( - 'Error while mounting specified storage path: {error}' - ).format( - error=error, - ) - ) - raise RuntimeError(error) - - def _umount(self, path): - rc = -1 - tries = self.UMOUNT_TRIES - while tries > 0: - rc, _stdout, _stderr = self.execute( - ( - self.command.get('umount'), - path - ), - raiseOnError=False - ) - if rc == 0: - tries = -1 - else: - tries -= 1 - time.sleep(1) - #rc, stdout and stderr are automatically logged as debug - self.execute( - ( - self.command.get('lsof'), - '+D%s' % path, - '-xfl' - ), - raiseOnError=False - ) - return rc def _re_deploying_host(self): interactive = self.environment[ohostedcons.CoreEnv.RE_DEPLOY] is None @@ -289,31 +212,6 @@ _('Invalid value for Host ID: must be integer') ) - def _check_domain_rights(self, path): - rc, _stdout, _stderr = self.execute( - ( - self.command.get('sudo'), - '-u', 'vdsm', - '-g', 'kvm', - 'test', - '-r', path, - '-a', - '-w', path, - '-a', - '-x', path, - ), - raiseOnError=False - ) - if rc != 0: - raise RuntimeError( - _( - 'permission settings on the specified storage do not ' - 'allow access to the storage to vdsm user and kvm group. ' - 'Verify permission settings on the specified storage ' - 'or specify another location' - ) - ) - def _validName(self, name): if ( name is None or @@ -321,27 +219,6 @@ ): return False return True - - def _validateDomain(self, connection, domain_type): - path = tempfile.mkdtemp() - try: - self._mount(path, connection, domain_type) - self._checker.check_valid_path(path) - self._check_domain_rights(path) - self._checker.check_base_writable(path) - self._checker.check_available_space( - path, - ohostedcons.Const.MINIMUM_SPACE_STORAGEDOMAIN_MB - ) - finally: - if self._umount(path) == 0: - os.rmdir(path) - else: - self.logger.warning( - _('Cannot unmount {path}').format( - path=path, - ) - ) def _getExistingDomain(self): self._storageServerConnection() @@ -622,6 +499,97 @@ _('Cannot setup Hosted Engine with connected storage pools') ) + def _customizeStorageDomainName(self): + interactive = self.environment[ + ohostedcons.StorageEnv.STORAGE_DOMAIN_NAME + ] is None + while not self._validName( + self.environment[ + ohostedcons.StorageEnv.STORAGE_DOMAIN_NAME + ] + ): + self.environment[ + ohostedcons.StorageEnv.STORAGE_DOMAIN_NAME + ] = self.dialog.queryString( + name='OVEHOSTED_STORAGE_DOMAIN_NAME', + note=_( + 'Please provide storage domain name. ' + '[@DEFAULT@]: ' + ), + prompt=True, + caseSensitive=True, + default=ohostedcons.Defaults.DEFAULT_STORAGE_DOMAIN_NAME, + ) + if not self._validName( + self.environment[ + ohostedcons.StorageEnv.STORAGE_DOMAIN_NAME + ] + ): + if interactive: + self.dialog.note( + text=_( + 'Storage domain name cannot be empty. ' + '{notvalid}' + ).format( + notvalid=self._NOT_VALID_NAME_MSG + ) + ) + else: + raise RuntimeError( + _( + 'Storage domain name cannot be empty. ' + '{notvalid}' + ).format( + notvalid=self._NOT_VALID_NAME_MSG + ) + ) + + def _customizeStorageDatacenterName(self): + interactive = self.environment[ + ohostedcons.StorageEnv.STORAGE_DATACENTER_NAME + ] is None + while not self._validName( + self.environment[ + ohostedcons.StorageEnv.STORAGE_DATACENTER_NAME + ] + ): + self.environment[ + ohostedcons.StorageEnv.STORAGE_DATACENTER_NAME + ] = self.dialog.queryString( + name='OVEHOSTED_STORAGE_DATACENTER_NAME', + note=_( + 'Local storage datacenter name is an internal name ' + 'and currently will not be shown in engine\'s admin UI.' + 'Please enter local datacenter name [@DEFAULT@]: ' + ), + prompt=True, + caseSensitive=True, + default=ohostedcons.Defaults.DEFAULT_STORAGE_DATACENTER_NAME, + ) + if not self._validName( + self.environment[ + ohostedcons.StorageEnv.STORAGE_DATACENTER_NAME + ] + ): + if interactive: + self.dialog.note( + text=_( + 'Data center name cannot be empty. ' + '{notvalid}' + ).format( + notvalid=self._NOT_VALID_NAME_MSG + ) + ) + else: + raise RuntimeError( + _( + 'Data center name cannot be empty. ' + '{notvalid}' + ).format( + notvalid=self._NOT_VALID_NAME_MSG + ) + ) + @plugin.event( stage=plugin.Stages.STAGE_INIT, ) @@ -676,26 +644,17 @@ ) @plugin.event( - stage=plugin.Stages.STAGE_SETUP, - ) - def _setup(self): - self.command.detect('mount') - self.command.detect('umount') - self.command.detect('lsof') - self.command.detect('sudo') - - @plugin.event( stage=plugin.Stages.STAGE_CUSTOMIZATION, - name=ohostedcons.Stages.CONFIG_STORAGE, + name=ohostedcons.Stages.CONFIG_STORAGE_EARLY, priority=plugin.Stages.PRIORITY_FIRST, after=( ohostedcons.Stages.DIALOG_TITLES_S_STORAGE, ), before=( - ohostedcons.Stages.DIALOG_TITLES_E_STORAGE, + ohostedcons.Stages.CONFIG_STORAGE_NFS, ), ) - def _customization(self): + def _early_customization(self): self.dialog.note( _( 'During customization use CTRL-D to abort.' @@ -703,103 +662,28 @@ ) self.serv = self.environment[ohostedcons.VDSMEnv.VDS_CLI] self._check_existing_pools() - interactive = ( - self.environment[ - ohostedcons.StorageEnv.STORAGE_DOMAIN_CONNECTION - ] is None or + if self.environment[ + ohostedcons.StorageEnv.DOMAIN_TYPE + ] is None: self.environment[ ohostedcons.StorageEnv.DOMAIN_TYPE - ] is None - ) - validDomain = False - while not validDomain: - try: - if interactive: - self.environment[ - ohostedcons.StorageEnv.DOMAIN_TYPE - ] = self.dialog.queryString( - name='OVEHOSTED_STORAGE_DOMAIN_TYPE', - note=_( - 'Please specify the storage ' - 'you would like to use (@VALUES@)[@DEFAULT@]: ' - ), - prompt=True, - caseSensitive=True, - validValues=( - # Enable when glusterfs issues are solved: - # 'glusterfs', - 'nfs3', - 'nfs4', - ), - default='nfs3', - ) + ] = self.dialog.queryString( + name='OVEHOSTED_STORAGE_DOMAIN_TYPE', + note=_( + 'Please specify the storage ' + 'you would like to use (@VALUES@)[@DEFAULT@]: ' + ), + prompt=True, + caseSensitive=True, + validValues=( + # Enable when glusterfs issues are solved: + # 'glusterfs', + 'nfs3', + 'nfs4', + ), + default='nfs3', + ) - self.environment[ - ohostedcons.StorageEnv.STORAGE_DOMAIN_CONNECTION - ] = self.dialog.queryString( - name='OVEHOSTED_STORAGE_DOMAIN_CONNECTION', - note=_( - 'Please specify the full shared storage ' - 'connection path to use (example: host:/path): ' - ), - prompt=True, - caseSensitive=True, - ) - - self._validateDomain( - connection=self.environment[ - ohostedcons.StorageEnv.STORAGE_DOMAIN_CONNECTION - ], - domain_type=self.environment[ - ohostedcons.StorageEnv.DOMAIN_TYPE - ], - ) - - validDomain = True - - except (ValueError, RuntimeError) as e: - if interactive: - self.logger.debug('exception', exc_info=True) - self.logger.error( - _( - 'Cannot access storage connection ' - '{connection}: {error}' - ).format( - connection=self.environment[ - ohostedcons.StorageEnv. - STORAGE_DOMAIN_CONNECTION - ], - error=e, - ) - ) - else: - raise e - except ohosteddomains.InsufficientSpaceError as e: - self.logger.debug('exception', exc_info=True) - self.logger.debug(e) - min_requirement = '%0.2f' % ( - ohostedcons.Const.MINIMUM_SPACE_STORAGEDOMAIN_MB / 1024.0 - ) - if interactive: - self.logger.error( - _( - 'Storage domain for self hosted engine ' - 'is too small: ' - 'you should have at least {min_r} GB free'.format( - min_r=min_requirement, - ) - ) - ) - else: - raise RuntimeError( - _( - 'Storage domain for self hosted engine ' - 'is too small: ' - 'you should have at least {min_r} GB free'.format( - min_r=min_requirement, - ) - ) - ) if self.environment[ ohostedcons.StorageEnv.DOMAIN_TYPE ] == 'nfs3': @@ -814,96 +698,36 @@ ohostedcons.StorageEnv.DOMAIN_TYPE ] == 'glusterfs': self.storageType = self.GLUSTERFS_DOMAIN + else: + raise RuntimeError( + _( + 'Invalid domain type: {dtype}' + ).format( + dtype=self.environment[ + ohostedcons.StorageEnv.DOMAIN_TYPE + ], + ) + ) + # Here the execution flow go to specific plugin activated by domain + # type. + + @plugin.event( + stage=plugin.Stages.STAGE_CUSTOMIZATION, + name=ohostedcons.Stages.CONFIG_STORAGE_LATE, + priority=plugin.Stages.PRIORITY_FIRST, + after=( + ohostedcons.Stages.CONFIG_STORAGE_NFS, + ), + before=( + ohostedcons.Stages.DIALOG_TITLES_E_STORAGE, + ), + ) + def _late_customization(self): + # This will be executed after specific plugin activated by domain + # type finishes. self._getExistingDomain() - - interactive = self.environment[ - ohostedcons.StorageEnv.STORAGE_DOMAIN_NAME - ] is None - while not self._validName( - self.environment[ - ohostedcons.StorageEnv.STORAGE_DOMAIN_NAME - ] - ): - self.environment[ - ohostedcons.StorageEnv.STORAGE_DOMAIN_NAME - ] = self.dialog.queryString( - name='OVEHOSTED_STORAGE_DOMAIN_NAME', - note=_( - 'Please provide storage domain name. ' - '[@DEFAULT@]: ' - ), - prompt=True, - caseSensitive=True, - default=ohostedcons.Defaults.DEFAULT_STORAGE_DOMAIN_NAME, - ) - if not self._validName( - self.environment[ - ohostedcons.StorageEnv.STORAGE_DOMAIN_NAME - ] - ): - if interactive: - self.dialog.note( - text=_( - 'Storage domain name cannot be empty. ' - '{notvalid}' - ).format( - notvalid=self._NOT_VALID_NAME_MSG - ) - ) - else: - raise RuntimeError( - _( - 'Storage domain name cannot be empty. ' - '{notvalid}' - ).format( - notvalid=self._NOT_VALID_NAME_MSG - ) - ) - - interactive = self.environment[ - ohostedcons.StorageEnv.STORAGE_DATACENTER_NAME - ] is None - while not self._validName( - self.environment[ - ohostedcons.StorageEnv.STORAGE_DATACENTER_NAME - ] - ): - self.environment[ - ohostedcons.StorageEnv.STORAGE_DATACENTER_NAME - ] = self.dialog.queryString( - name='OVEHOSTED_STORAGE_DATACENTER_NAME', - note=_( - 'Local storage datacenter name is an internal name ' - 'and currently will not be shown in engine\'s admin UI.' - 'Please enter local datacenter name [@DEFAULT@]: ' - ), - prompt=True, - caseSensitive=True, - default=ohostedcons.Defaults.DEFAULT_STORAGE_DATACENTER_NAME, - ) - if not self._validName( - self.environment[ - ohostedcons.StorageEnv.STORAGE_DATACENTER_NAME - ] - ): - if interactive: - self.dialog.note( - text=_( - 'Data center name cannot be empty. ' - '{notvalid}' - ).format( - notvalid=self._NOT_VALID_NAME_MSG - ) - ) - else: - raise RuntimeError( - _( - 'Data center name cannot be empty. ' - '{notvalid}' - ).format( - notvalid=self._NOT_VALID_NAME_MSG - ) - ) + self._customizeStorageDomainName() + self._customizeStorageDatacenterName() @plugin.event( stage=plugin.Stages.STAGE_MISC, -- To view, visit http://gerrit.ovirt.org/26488 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ided3e1f8e71abc2d0e3ec80e1cd2c2f3cca1f1df Gerrit-PatchSet: 1 Gerrit-Project: ovirt-hosted-engine-setup Gerrit-Branch: master Gerrit-Owner: Sandro Bonazzola <sbona...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches