Simone Tiraboschi has uploaded a new change for review. Change subject: vdsm: use vdscli instead of vdsClient for storage operations ......................................................................
vdsm: use vdscli instead of vdsClient for storage operations Dropping vdsClient usage in favor of vdscli API for storage operations. vdsClient includes a non modificable 60 secs timeout with could not be enough on long storage operations. Change-Id: Iec7db5ccf55752266fa668a8b1e8f914cd632521 Bug-Url: https://bugzilla.redhat.com/1173638 Signed-off-by: Simone Tiraboschi <stira...@redhat.com> --- M src/ovirt_hosted_engine_setup/constants.py M src/ovirt_hosted_engine_setup/mixins.py M src/ovirt_hosted_engine_setup/tasks.py M src/plugins/ovirt-hosted-engine-setup/storage/iscsi.py M src/plugins/ovirt-hosted-engine-setup/storage/storage.py M src/plugins/ovirt-hosted-engine-setup/system/vdsmenv.py M src/plugins/ovirt-hosted-engine-setup/vm/boot_disk.py M src/plugins/ovirt-hosted-engine-setup/vm/configurevm.py M src/plugins/ovirt-hosted-engine-setup/vm/image.py 9 files changed, 94 insertions(+), 78 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup refs/changes/59/37559/1 diff --git a/src/ovirt_hosted_engine_setup/constants.py b/src/ovirt_hosted_engine_setup/constants.py index a37f4ce..1af24b6 100644 --- a/src/ovirt_hosted_engine_setup/constants.py +++ b/src/ovirt_hosted_engine_setup/constants.py @@ -288,6 +288,7 @@ HA_NOTIF_SMTP_PORT = 'smtp-port' HA_NOTIF_SMTP_SOURCE_EMAIL = 'source-email' HA_NOTIF_SMTP_DEST_EMAILS = 'destination-emails' + BLANK_UUID = '00000000-0000-0000-0000-000000000000' @util.export @@ -685,7 +686,8 @@ VDSMD_SERVICE = 'OVEHOSTED_VDSM/serviceName' VDSM_UID = 'OVEHOSTED_VDSM/vdsmUid' KVM_GID = 'OVEHOSTED_VDSM/kvmGid' - VDS_CLI = 'OVEHOSTED_VDSM/vdsClient' + VDS_CLI = 'OVEHOSTED_VDSM/vdscli' + VDS_CLIENT = 'OVEHOSTED_VDSM/vdsClient' @ohostedattrs( answerfile=True, diff --git a/src/ovirt_hosted_engine_setup/mixins.py b/src/ovirt_hosted_engine_setup/mixins.py index ad2029b..fdd4891 100644 --- a/src/ovirt_hosted_engine_setup/mixins.py +++ b/src/ovirt_hosted_engine_setup/mixins.py @@ -61,7 +61,7 @@ def _generateUserMessage(self, console_type): displayPort = 5900 displaySecurePort = 5901 - serv = self.environment[ohostedcons.VDSMEnv.VDS_CLI] + serv = self.environment[ohostedcons.VDSMEnv.VDS_CLIENT] try: stats = serv.s.getVmStats( self.environment[ohostedcons.VMEnv.VM_UUID] diff --git a/src/ovirt_hosted_engine_setup/tasks.py b/src/ovirt_hosted_engine_setup/tasks.py index b988b73..173fed8 100644 --- a/src/ovirt_hosted_engine_setup/tasks.py +++ b/src/ovirt_hosted_engine_setup/tasks.py @@ -42,7 +42,7 @@ self.environment = environment def wait(self): - serv = self.environment[ohostedcons.VDSMEnv.VDS_CLI] + serv = self.environment[ohostedcons.VDSMEnv.VDS_CLIENT] wait = True while wait: self.logger.debug('Waiting for existing tasks to complete') @@ -83,7 +83,7 @@ self.environment = environment def wait(self): - serv = self.environment[ohostedcons.VDSMEnv.VDS_CLI] + serv = self.environment[ohostedcons.VDSMEnv.VDS_CLIENT] down = False destroyed = False while not down: @@ -120,7 +120,7 @@ self.environment = environment def wait(self, sdUUID): - serv = self.environment[ohostedcons.VDSMEnv.VDS_CLI] + serv = self.environment[ohostedcons.VDSMEnv.VDS_CLIENT] acquired = False while not acquired: time.sleep(self.POLLING_INTERVAL) diff --git a/src/plugins/ovirt-hosted-engine-setup/storage/iscsi.py b/src/plugins/ovirt-hosted-engine-setup/storage/iscsi.py index 04376ae..b7de6af 100644 --- a/src/plugins/ovirt-hosted-engine-setup/storage/iscsi.py +++ b/src/plugins/ovirt-hosted-engine-setup/storage/iscsi.py @@ -52,11 +52,7 @@ def __init__(self, context): super(Plugin, self).__init__(context=context) self._interactive = False - self.serv = None - self.vdsClient = util.loadModule( - path=ohostedcons.FileLocations.VDS_CLIENT_DIR, - name='vdsClient' - ) + self.cli = None def _customize_ip_address(self): valid = False @@ -232,7 +228,7 @@ return str(lun) def _iscsi_discovery(self, address, port, user, password): - targets = self.serv.s.discoverSendTargets( + targets = self.cli.discoverSendTargets( { 'connection': address, 'port': port, @@ -249,7 +245,7 @@ retry = self._MAXRETRY iscsi_lun_list = [] for _try in range(0, retry): - devices = self.serv.s.getDeviceList( + devices = self.cli.getDeviceList( ohostedcons.VDSMConstants.ISCSI_DOMAIN ) self.logger.debug(devices) @@ -270,9 +266,9 @@ password, ) self.logger.info('Connecting to the storage server') - res = self.serv.s.connectStorageServer( + res = self.cli.connectStorageServer( ohostedcons.VDSMConstants.ISCSI_DOMAIN, - self.vdsClient.BLANK_UUID, + ohostedcons.Const.BLANK_UUID, [ { 'connection': ip, @@ -281,7 +277,7 @@ 'user': user, 'password': password, 'port': port, - 'id': self.vdsClient.BLANK_UUID, + 'id': ohostedcons.Const.BLANK_UUID, } ] ) @@ -421,7 +417,7 @@ ), ) def _customization(self): - self.serv = self.environment[ohostedcons.VDSMEnv.VDS_CLI] + self.cli = self.environment[ohostedcons.VDSMEnv.VDS_CLI] valid_access = False valid_lun = False address = None @@ -502,7 +498,7 @@ if self.environment[ohostedcons.StorageEnv.VG_UUID] is None: # If we don't have a volume group we must create it self.logger.info(_('Creating Volume Group')) - dom = self.serv.s.createVG( + dom = self.cli.createVG( self.environment[ohostedcons.StorageEnv.SD_UUID], [ iscsi_device['GUID'], @@ -516,7 +512,7 @@ ohostedcons.StorageEnv.VG_UUID ] = dom['uuid'] - vginfo = self.serv.s.getVGInfo( + vginfo = self.cli.getVGInfo( self.environment[ohostedcons.StorageEnv.VG_UUID] ) self.logger.debug(vginfo) diff --git a/src/plugins/ovirt-hosted-engine-setup/storage/storage.py b/src/plugins/ovirt-hosted-engine-setup/storage/storage.py index 2ba7c6d..df6bb8e 100644 --- a/src/plugins/ovirt-hosted-engine-setup/storage/storage.py +++ b/src/plugins/ovirt-hosted-engine-setup/storage/storage.py @@ -61,11 +61,7 @@ def __init__(self, context): super(Plugin, self).__init__(context=context) - self.vdsClient = util.loadModule( - path=ohostedcons.FileLocations.VDS_CLIENT_DIR, - name='vdsClient' - ) - self.serv = None + self.cli = None self.waiter = None self.storageType = None self.protocol_version = None @@ -284,7 +280,7 @@ ohostedcons.VDSMConstants.ISCSI_DOMAIN, ): if self.environment[ohostedcons.StorageEnv.VG_UUID] is not None: - vginfo = self.serv.s.getVGInfo( + vginfo = self.cli.getVGInfo( self.environment[ohostedcons.StorageEnv.VG_UUID] ) if vginfo['status']['code'] != 0: @@ -374,10 +370,10 @@ def _getStorageDomainsList(self, spUUID=None): if not spUUID: - spUUID = self.vdsClient.BLANK_UUID + spUUID = ohostedcons.Const.BLANK_UUID self.logger.debug('getStorageDomainsList') domains = [] - response = self.serv.s.getStorageDomainsList(spUUID) + response = self.cli.getStorageDomainsList(spUUID) self.logger.debug(response) if response['status']['code'] == 0: for entry in response['domlist']: @@ -386,7 +382,7 @@ def _validateStorageDomain(self, sdUUID): self.logger.debug('validateStorageDomain') - response = self.serv.s.validateStorageDomain(sdUUID) + response = self.cli.validateStorageDomain(sdUUID) self.logger.debug(response) if response['status']['code']: return response['status']['code'], response['status']['message'] @@ -395,7 +391,7 @@ def _getStorageDomainInfo(self, sdUUID): self.logger.debug('getStorageDomainInfo') info = {} - response = self.serv.s.getStorageDomainInfo(sdUUID) + response = self.cli.getStorageDomainInfo(sdUUID) self.logger.debug(response) if response['status']['code'] == 0: for key, respinfo in response['info'].iteritems(): @@ -405,7 +401,7 @@ def _getStoragePoolInfo(self, spUUID): self.logger.debug('getStoragePoolInfo') info = {} - response = self.serv.s.getStoragePoolInfo(spUUID) + response = self.cli.getStoragePoolInfo(spUUID) self.logger.debug(response) if response['status']['code'] == 0: for key in response['info'].keys(): @@ -413,13 +409,13 @@ return info def _storageServerConnection(self, disconnect=False): - method = self.serv.s.connectStorageServer + method = self.cli.connectStorageServer debug_msg = 'connectStorageServer' if disconnect: - method = self.serv.s.disconnectStorageServer + method = self.cli.disconnectStorageServer debug_msg = 'disconnectStorageServer' self.logger.debug(debug_msg) - spUUID = self.vdsClient.BLANK_UUID + spUUID = ohostedcons.Const.BLANK_UUID conList = None if self.storageType in ( ohostedcons.VDSMConstants.NFS_DOMAIN, @@ -507,19 +503,19 @@ raise RuntimeError(_('Invalid Storage Type')) domainType = ohostedcons.VDSMConstants.DATA_DOMAIN version = 3 - status, message = self.serv.createStorageDomain(args=[ + status = self.cli.createStorageDomain( self.storageType, sdUUID, domainName, typeSpecificArgs, domainType, version - ]) - if status != 0: - raise RuntimeError(message) - self.logger.debug(self.serv.s.repoStats()) + ) + if status['status']['code'] != 0: + raise RuntimeError(status['status']['message']) + self.logger.debug(self.cli.repoStats()) self.logger.debug( - self.serv.s.getStorageDomainStats(sdUUID) + self.cli.getStorageDomainStats(sdUUID) ) def _createStoragePool(self): @@ -531,22 +527,40 @@ ohostedcons.StorageEnv.STORAGE_DATACENTER_NAME ] masterDom = sdUUID - domList = sdUUID # str: domain,domain,... + domList = [sdUUID] mVer = 1 - status, message = self.serv.createStoragePool(args=[ + self.logger.debug(( + 'createStoragePool(args=[' + 'poolType={poolType},' + 'spUUID={spUUID},' + 'poolName={poolName},' + 'masterDom={masterDom},' + 'domList={domList},' + 'mVer={mVer}' + '])' + ).format( + poolType=poolType, + spUUID=spUUID, + poolName=poolName, + masterDom=masterDom, + domList=domList, + mVer=mVer, + )) + + status = self.cli.createStoragePool( poolType, spUUID, poolName, masterDom, domList, mVer - ]) - if status != 0: - raise RuntimeError(message) + ) + if status['status']['code'] != 0: + raise RuntimeError(status['status']['message']) def _startMonitoringDomain(self): self.logger.debug('_startMonitoringDomain') - status = self.serv.s.startMonitoringDomain( + status = self.cli.startMonitoringDomain( self.environment[ohostedcons.StorageEnv.SD_UUID], self.environment[ohostedcons.StorageEnv.HOST_ID] ) @@ -559,7 +573,7 @@ def _stopMonitoringDomain(self): self.logger.debug('_stopMonitoringDomain') - status = self.serv.s.stopMonitoringDomain( + status = self.cli.stopMonitoringDomain( self.environment[ohostedcons.StorageEnv.SD_UUID], self.environment[ohostedcons.StorageEnv.HOST_ID] ) @@ -574,7 +588,7 @@ scsi_key = spUUID master = sdUUID master_ver = 1 - method = self.serv.connectStoragePool + method = self.cli.connectStoragePool method_args = [ spUUID, ID, @@ -582,18 +596,18 @@ ] debug_msg = 'connectStoragePool' if disconnect: - method = self.serv.disconnectStoragePool + method = self.cli.disconnectStoragePool debug_msg = 'disconnectStoragePool' else: method_args += [ master, master_ver, - sdUUID+'=active', + {sdUUID: 'active'}, ] self.logger.debug(debug_msg) - status, message = method(args=method_args) - if status != 0: - raise RuntimeError(message) + status = method(*method_args) + if status['status']['code'] != 0: + raise RuntimeError(status['status']['message']) self._connected = not disconnect def _spmStart(self): @@ -605,7 +619,7 @@ scsiFencing = 'false' maxHostID = ohostedcons.Const.MAX_HOST_ID version = 3 - status, status_uuid = self.serv.spmStart(args=[ + status = self.cli.spmStart( spUUID, prevID, prevLVER, @@ -613,43 +627,40 @@ scsiFencing, maxHostID, version - ]) - if status != 0: - raise RuntimeError(status_uuid) - self.logger.debug(status_uuid) + ) + if status['status']['code'] != 0: + raise RuntimeError(status['status']['message']) def _spmStop(self): self.logger.debug('spmStop') spUUID = self.environment[ohostedcons.StorageEnv.SP_UUID] - status, status_uuid = self.serv.spmStop( - args=[ - spUUID, - ], + status = self.cli.spmStop( + spUUID, ) - if status != 0: - raise RuntimeError(status_uuid) - self.logger.debug(status_uuid) + if status['status']['code'] != 0: + raise RuntimeError(status['status']['message']) + self.logger.debug(status) def _activateStorageDomain(self): self.logger.debug('activateStorageDomain') sdUUID = self.environment[ohostedcons.StorageEnv.SD_UUID] spUUID = self.environment[ohostedcons.StorageEnv.SP_UUID] - status, message = self.serv.activateStorageDomain(args=[ + status = self.cli.activateStorageDomain( sdUUID, spUUID - ]) - if status != 0: - raise RuntimeError(message) + ) + if status['status']['code'] != 0: + raise RuntimeError(status['status']['message']) self.waiter.wait() - self.logger.debug(self.serv.s.getSpmStatus(spUUID)) - info = self.serv.s.getStoragePoolInfo(spUUID) + self.logger.debug(self.cli.getSpmStatus(spUUID)) + info = self.cli.getStoragePoolInfo(spUUID) self.logger.debug(info) - self.logger.debug(self.serv.s.repoStats()) + self.logger.debug(self.cli.repoStats()) def _check_existing_pools(self): self.logger.debug('_check_existing_pools') self.logger.debug('getConnectedStoragePoolsList') - pools = self.serv.s.getConnectedStoragePoolsList() + pools = self.cli.getConnectedStoragePoolsList() self.logger.debug(pools) if pools['status']['code'] != 0: raise RuntimeError(pools['status']['message']) @@ -832,7 +843,7 @@ 'During customization use CTRL-D to abort.' ) ) - self.serv = self.environment[ohostedcons.VDSMEnv.VDS_CLI] + self.cli = self.environment[ohostedcons.VDSMEnv.VDS_CLI] self._check_existing_pools() domain_type = self.environment[ohostedcons.StorageEnv.DOMAIN_TYPE] if domain_type is None: @@ -906,7 +917,7 @@ ) def _misc(self): self.waiter = tasks.TaskWaiter(self.environment) - self.serv = self.environment[ohostedcons.VDSMEnv.VDS_CLI] + self.cli = self.environment[ohostedcons.VDSMEnv.VDS_CLI] self._check_existing_pools() if self.storageType in ( ohostedcons.VDSMConstants.NFS_DOMAIN, @@ -922,7 +933,7 @@ elif self.storageType in ( ohostedcons.VDSMConstants.ISCSI_DOMAIN, ): - devices = self.serv.s.getDeviceList( + devices = self.cli.getDeviceList( ohostedcons.VDSMConstants.ISCSI_DOMAIN ) self.logger.debug(devices) diff --git a/src/plugins/ovirt-hosted-engine-setup/system/vdsmenv.py b/src/plugins/ovirt-hosted-engine-setup/system/vdsmenv.py index 60cbd91..59db87b 100644 --- a/src/plugins/ovirt-hosted-engine-setup/system/vdsmenv.py +++ b/src/plugins/ovirt-hosted-engine-setup/system/vdsmenv.py @@ -69,7 +69,10 @@ hostPort = vdscli.cannonizeHostPort('localhost') serv.do_connect(hostPort) - self.environment[ohostedcons.VDSMEnv.VDS_CLI] = serv + cli = vdscli.connect() + self.environment[ohostedcons.VDSMEnv.VDS_CLI] = cli + + self.environment[ohostedcons.VDSMEnv.VDS_CLIENT] = serv vdsmReady = False retry = 0 while not vdsmReady and retry < self.MAX_RETRY: @@ -103,6 +106,10 @@ grp.getgrnam('kvm').gr_gid ) self.environment.setdefault( + ohostedcons.VDSMEnv.VDS_CLIENT, + None + ) + self.environment.setdefault( ohostedcons.VDSMEnv.VDS_CLI, None ) diff --git a/src/plugins/ovirt-hosted-engine-setup/vm/boot_disk.py b/src/plugins/ovirt-hosted-engine-setup/vm/boot_disk.py index b40af8d..f9d228b 100644 --- a/src/plugins/ovirt-hosted-engine-setup/vm/boot_disk.py +++ b/src/plugins/ovirt-hosted-engine-setup/vm/boot_disk.py @@ -115,7 +115,7 @@ info = json.decoder.JSONDecoder().decode('\n'.join(stdout)) source_size = int(info['virtual-size']) - serv = self._parent.environment[ohostedcons.VDSMEnv.VDS_CLI] + serv = self._parent.environment[ohostedcons.VDSMEnv.VDS_CLIENT] size = serv.s.getVolumeSize( self._parent.environment[ohostedcons.StorageEnv.SD_UUID], self._parent.environment[ohostedcons.StorageEnv.SP_UUID], diff --git a/src/plugins/ovirt-hosted-engine-setup/vm/configurevm.py b/src/plugins/ovirt-hosted-engine-setup/vm/configurevm.py index e65095e..8ccaefb 100644 --- a/src/plugins/ovirt-hosted-engine-setup/vm/configurevm.py +++ b/src/plugins/ovirt-hosted-engine-setup/vm/configurevm.py @@ -95,7 +95,7 @@ name=ohostedcons.Stages.VDSMD_LATE_SETUP_READY, ) def _late_setup(self): - serv = self.environment[ohostedcons.VDSMEnv.VDS_CLI] + serv = self.environment[ohostedcons.VDSMEnv.VDS_CLIENT] response = serv.s.list() if response['status']['code'] == 0: self.logger.debug(response['vmList']) diff --git a/src/plugins/ovirt-hosted-engine-setup/vm/image.py b/src/plugins/ovirt-hosted-engine-setup/vm/image.py index 8cfe01c..4617a8d 100644 --- a/src/plugins/ovirt-hosted-engine-setup/vm/image.py +++ b/src/plugins/ovirt-hosted-engine-setup/vm/image.py @@ -183,7 +183,7 @@ spUUID = self.environment[ohostedcons.StorageEnv.SP_UUID] imgUUID = self.environment[ohostedcons.StorageEnv.IMG_UUID] volUUID = self.environment[ohostedcons.StorageEnv.VOL_UUID] - serv = self.environment[ohostedcons.VDSMEnv.VDS_CLI] + serv = self.environment[ohostedcons.VDSMEnv.VDS_CLIENT] if self.environment[ohostedcons.StorageEnv.DOMAIN_TYPE] in ( ohostedcons.DomainTypes.ISCSI, -- To view, visit http://gerrit.ovirt.org/37559 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iec7db5ccf55752266fa668a8b1e8f914cd632521 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-hosted-engine-setup Gerrit-Branch: ovirt-hosted-engine-setup-1.2 Gerrit-Owner: Simone Tiraboschi <stira...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches