def _info(self): """ Fetches the info (see Volume Driver API) for the vDisk. """ if self.volume_id and self.vpool: try: vdiskinfo = self.storagedriver_client.info_volume( str(self.volume_id)) except: vdiskinfo = StorageDriverClient.EMPTY_INFO() else: vdiskinfo = StorageDriverClient.EMPTY_INFO() vdiskinfodict = {} for key, value in vdiskinfo.__class__.__dict__.items(): if type(value) is property: objectvalue = getattr(vdiskinfo, key) if key == 'object_type': vdiskinfodict[key] = str(objectvalue) elif key == 'metadata_backend_config': vdiskinfodict[key] = {} if hasattr(objectvalue, 'node_configs') and callable( objectvalue.node_configs): vdiskinfodict[key] = [] for nodeconfig in objectvalue.node_configs(): vdiskinfodict[key].append({ 'ip': nodeconfig.address(), 'port': nodeconfig.port() }) else: vdiskinfodict[key] = objectvalue return vdiskinfodict
def _info(self): """ Fetches the info (see Volume Driver API) for the vDisk. """ if self.volume_id and self.vpool: try: vdiskinfo = self.storagedriver_client.info_volume(str(self.volume_id)) except: vdiskinfo = StorageDriverClient.empty_info() else: vdiskinfo = StorageDriverClient.empty_info() vdiskinfodict = {} for key, value in vdiskinfo.__class__.__dict__.items(): if type(value) is property: objectvalue = getattr(vdiskinfo, key) if key == 'object_type': vdiskinfodict[key] = str(objectvalue) elif key == 'metadata_backend_config': vdiskinfodict[key] = {} if hasattr(objectvalue, 'node_configs') and callable(objectvalue.node_configs): vdiskinfodict[key] = [] for nodeconfig in objectvalue.node_configs(): vdiskinfodict[key].append({'ip': nodeconfig.address(), 'port': nodeconfig.port()}) else: vdiskinfodict[key] = objectvalue return vdiskinfodict
def fetch_statistics(self): """ Loads statistics from this vDisk - returns unprocessed data """ # Load data from volumedriver if self.volume_id and self.vpool: try: vdiskstats = self.storagedriver_client.statistics_volume( str(self.volume_id)) except Exception as ex: VDisk._logger.error( 'Error loading statistics_volume from {0}: {1}'.format( self.volume_id, ex)) vdiskstats = StorageDriverClient.EMPTY_STATISTICS() else: vdiskstats = StorageDriverClient.EMPTY_STATISTICS() # Load volumedriver data in dictionary vdiskstatsdict = {} try: pc = vdiskstats.performance_counters vdiskstatsdict[ 'backend_data_read'] = pc.backend_read_request_size.sum() vdiskstatsdict[ 'backend_data_written'] = pc.backend_write_request_size.sum() vdiskstatsdict[ 'backend_read_operations'] = pc.backend_read_request_size.events( ) vdiskstatsdict[ 'backend_write_operations'] = pc.backend_write_request_size.events( ) vdiskstatsdict['data_read'] = pc.read_request_size.sum() vdiskstatsdict['data_written'] = pc.write_request_size.sum() vdiskstatsdict['read_operations'] = pc.read_request_size.events() vdiskstatsdict['write_operations'] = pc.write_request_size.events() for key in [ 'cluster_cache_hits', 'cluster_cache_misses', 'metadata_store_hits', 'metadata_store_misses', 'sco_cache_hits', 'sco_cache_misses', 'stored' ]: vdiskstatsdict[key] = getattr(vdiskstats, key) # Do some more manual calculations block_size = self.metadata.get('lba_size', 0) * self.metadata.get( 'cluster_multiplier', 0) if block_size == 0: block_size = 4096 vdiskstatsdict['4k_read_operations'] = vdiskstatsdict[ 'data_read'] / block_size vdiskstatsdict['4k_write_operations'] = vdiskstatsdict[ 'data_written'] / block_size # Pre-calculate sums for key, items in StorageDriverClient.STAT_SUMS.iteritems(): vdiskstatsdict[key] = 0 for item in items: vdiskstatsdict[key] += vdiskstatsdict[item] except: pass return vdiskstatsdict
def move_away(storagerouter_guid): """ Moves away all vDisks from all Storage Drivers this Storage Router is serving """ storagedrivers = StorageRouter(storagerouter_guid).storagedrivers if len(storagedrivers) > 0: storagedriver_client = StorageDriverClient().load(storagedrivers[0].vpool) for storagedriver in storagedrivers: storagedriver_client.mark_node_offline(str(storagedriver.storagedriver_id))
def move_away(storagerouter_guid): """ Moves away all vDisks from all Storage Drivers this Storage Router is serving """ storagedrivers = StorageRouter(storagerouter_guid).storagedrivers if len(storagedrivers) > 0: storagedriver_client = StorageDriverClient().load( storagedrivers[0].vpool) for storagedriver in storagedrivers: storagedriver_client.mark_node_offline( str(storagedriver.storagedriver_id))
def list_volumes(vpool_guid=None): """ List all known volumes on a specific vpool or on all """ if vpool_guid is not None: vpool = VPool(vpool_guid) storagedriver_client = StorageDriverClient.load(vpool) response = storagedriver_client.list_volumes() else: response = [] for vpool in VPoolList.get_vpools(): storagedriver_client = StorageDriverClient.load(vpool) response.extend(storagedriver_client.list_volumes()) return response
def reload_client(self): """ Reloads the StorageDriver Client """ self._frozen = False self._storagedriver_client = StorageDriverClient.load(self) self._frozen = True
def update_status(storagedriver_id): """ Sets Storage Driver offline in case hypervisor management Center reports the hypervisor pmachine related to this Storage Driver as unavailable. :param storagedriver_id: ID of the storagedriver to update its status """ pmachine = PMachineList.get_by_storagedriver_id(storagedriver_id) storagedriver = StorageDriverList.get_by_storagedriver_id(storagedriver_id) storagerouter = storagedriver.storagerouter if pmachine.mgmtcenter: # Update status pmachine.invalidate_dynamics(['host_status']) else: # No management Center, cannot update status via api logger.info('Updating status of pmachine {0} using SSHClient'.format(pmachine.name)) host_status = 'RUNNING' try: client = SSHClient(storagerouter, username='******') configuration_dir = EtcdConfiguration.get('/ovs/framework/paths|cfgdir') logger.info('SSHClient connected successfully to {0} at {1}'.format(pmachine.name, client.ip)) with Remote(client.ip, [LocalStorageRouterClient]) as remote: lsrc = remote.LocalStorageRouterClient('{0}/storagedriver/storagedriver/{1}.json'.format(configuration_dir, storagedriver.vpool.name)) lsrc.server_revision() logger.info('LocalStorageRouterClient connected successfully to {0} at {1}'.format(pmachine.name, client.ip)) except Exception as ex: logger.error('Connectivity check failed, assuming host {0} is halted. {1}'.format(pmachine.name, ex)) host_status = 'HALTED' if host_status != 'RUNNING': # Host is stopped storagedriver_client = StorageDriverClient.load(storagedriver.vpool) storagedriver_client.mark_node_offline(str(storagedriver.storagedriver_id))
def reload_client(self): """ Reloads the StorageDriver Client """ if self.vpool_guid: self._frozen = False self._storagedriver_client = StorageDriverClient.load(self.vpool) self._frozen = True
def reload_client(self): """ Reloads the StorageDriver Client """ if self.vpool: self._frozen = False self.storagedriver_client = StorageDriverClient.load(self.vpool) self._frozen = True
def _info(self): """ Fetches the info (see Volume Driver API) for the vDisk. """ vdiskinfo = StorageDriverClient.EMPTY_INFO() vdisk_state = VDisk.STATUSES.RUNNING if self.volume_id and self.vpool: try: try: vdiskinfo = self.storagedriver_client.info_volume( str(self.volume_id), req_timeout_secs=2) except VolumeRestartInProgressException: time.sleep(0.5) vdiskinfo = self.storagedriver_client.info_volume( str(self.volume_id), req_timeout_secs=2) except MaxRedirectsExceededException: vdisk_state = VDisk.STATUSES.NON_RUNNING # @todo replace RuntimeError with NodeNotReachableException except (ClusterNotReachableException, RuntimeError) as exception: if isinstance(exception, ClusterNotReachableException) or ( isinstance(exception, RuntimeError) and 'failed to send XMLRPC request' in str(exception)): self._logger.debug( 'VDisk {0} status has been set to UNKNOWN'.format( self.name)) vdisk_state = VDisk.STATUSES.UNKNOWN except Exception as ex: self._logger.debug( 'Uncaught exception occurred when requesting the volume info for vDisk {0}: {1}' .format(self.name, ex)) vdiskinfodict = {} for key, value in vdiskinfo.__class__.__dict__.items(): if type(value) is property: objectvalue = getattr(vdiskinfo, key) if key == 'object_type': vdiskinfodict[key] = str(objectvalue) elif key == 'metadata_backend_config': vdiskinfodict[key] = {} if hasattr(objectvalue, 'node_configs') and callable( objectvalue.node_configs): vdiskinfodict[key] = [] for nodeconfig in objectvalue.node_configs(): vdiskinfodict[key].append({ 'ip': nodeconfig.address(), 'port': nodeconfig.port() }) elif key == 'halted' and objectvalue is True: self._logger.debug( 'VDisk {0} status has been set to HALTED'.format( self.name)) vdisk_state = VDisk.STATUSES.HALTED else: vdiskinfodict[key] = objectvalue vdiskinfodict['live_status'] = vdisk_state return vdiskinfodict
def _statistics(self, dynamic): """ Fetches the Statistics for the vDisk. """ client = StorageDriverClient() volatile = VolatileFactory.get_client() prev_key = '{0}_{1}'.format(self._key, 'statistics_previous') # Load data from volumedriver if self.volume_id and self.vpool: try: vdiskstats = self.storagedriver_client.statistics_volume( str(self.volume_id)) except: vdiskstats = client.empty_statistics() else: vdiskstats = client.empty_statistics() # Load volumedriver data in dictionary vdiskstatsdict = {} for key, value in vdiskstats.__class__.__dict__.items(): if type(value) is property and key in client.stat_counters: vdiskstatsdict[key] = getattr(vdiskstats, key) # Precalculate sums for key, items in client.stat_sums.iteritems(): vdiskstatsdict[key] = 0 for item in items: vdiskstatsdict[key] += vdiskstatsdict[item] vdiskstatsdict['timestamp'] = time.time() # Calculate delta's based on previously loaded dictionary previousdict = volatile.get(prev_key, default={}) for key in vdiskstatsdict.keys(): if key in client.stat_keys: delta = vdiskstatsdict['timestamp'] - previousdict.get( 'timestamp', vdiskstatsdict['timestamp']) if delta < 0: vdiskstatsdict['{0}_ps'.format(key)] = 0 elif delta == 0: vdiskstatsdict['{0}_ps'.format(key)] = previousdict.get( '{0}_ps'.format(key), 0) else: vdiskstatsdict['{0}_ps'.format(key)] = max( 0, (vdiskstatsdict[key] - previousdict[key]) / delta) volatile.set(prev_key, vdiskstatsdict, dynamic.timeout * 10) # Returning the dictionary return vdiskstatsdict
def fetch_statistics(self): """ Loads statistics from this vDisk - returns unprocessed data """ # Load data from volumedriver if self.volume_id and self.vpool: try: vdiskstats = self.storagedriver_client.statistics_volume(str(self.volume_id)) vdiskinfo = self.storagedriver_client.info_volume(str(self.volume_id)) except: vdiskstats = StorageDriverClient.empty_statistics() vdiskinfo = StorageDriverClient.empty_info() else: vdiskstats = StorageDriverClient.empty_statistics() vdiskinfo = StorageDriverClient.empty_info() # Load volumedriver data in dictionary vdiskstatsdict = {} try: pc = vdiskstats.performance_counters vdiskstatsdict['backend_data_read'] = pc.backend_read_request_size.sum() vdiskstatsdict['backend_data_written'] = pc.backend_write_request_size.sum() vdiskstatsdict['backend_read_operations'] = pc.backend_read_request_size.events() vdiskstatsdict['backend_write_operations'] = pc.backend_write_request_size.events() vdiskstatsdict['data_read'] = pc.read_request_size.sum() vdiskstatsdict['data_written'] = pc.write_request_size.sum() vdiskstatsdict['read_operations'] = pc.read_request_size.events() vdiskstatsdict['write_operations'] = pc.write_request_size.events() for key in ['cluster_cache_hits', 'cluster_cache_misses', 'metadata_store_hits', 'metadata_store_misses', 'sco_cache_hits', 'sco_cache_misses']: vdiskstatsdict[key] = getattr(vdiskstats, key) # Do some more manual calculations block_size = vdiskinfo.lba_size * vdiskinfo.cluster_multiplier if block_size == 0: block_size = 4096 vdiskstatsdict['4k_read_operations'] = vdiskstatsdict['data_read'] / block_size vdiskstatsdict['4k_write_operations'] = vdiskstatsdict['data_written'] / block_size # Precalculate sums for key, items in StorageDriverClient.stat_sums.iteritems(): vdiskstatsdict[key] = 0 for item in items: vdiskstatsdict[key] += vdiskstatsdict[item] except: pass return vdiskstatsdict
def reload_client(self, client): """ Reloads the StorageDriverClient or ObjectRegistryClient """ self._frozen = False if client == 'storagedriver': self._storagedriver_client = StorageDriverClient.load(self) elif client == 'objectregistry': self._objectregistry_client = ObjectRegistryClient.load(self) self._frozen = True
def reload_client(self, client): """ Reloads the StorageDriverClient or ObjectRegistryClient """ self._frozen = False if client == "storagedriver": self._storagedriver_client = StorageDriverClient.load(self) elif client == "objectregistry": self._objectregistry_client = ObjectRegistryClient.load(self) self._frozen = True
def reload_client(self, client): """ Reloads the StorageDriverClient or ObjectRegistryClient """ if self.vpool_guid: self._frozen = False if client == 'storagedriver': self._storagedriver_client = StorageDriverClient.load(self.vpool) elif client == 'objectregistry': self._objectregistry_client = ObjectRegistryClient.load(self.vpool) self._frozen = True
def update_status(storagedriver_id): """ Sets Storage Driver offline in case hypervisor management Center reports the hypervisor pmachine related to this Storage Driver as unavailable. """ pmachine = PMachineList.get_by_storagedriver_id(storagedriver_id) if pmachine.mgmtcenter: # Update status pmachine.invalidate_dynamics(['host_status']) host_status = pmachine.host_status if host_status != 'RUNNING': # Host is stopped storagedriver = StorageDriverList.get_by_storagedriver_id(storagedriver_id) storagedriver_client = StorageDriverClient().load(storagedriver.vpool) storagedriver_client.mark_node_offline(str(storagedriver.storagedriver_id)) else: # No management Center, cannot update status via api #TODO: should we try manually (ping, ssh)? pass
def _info(self): """ Fetches the info (see Volume Driver API) for the vDisk. """ if self.volume_id and self.vpool: try: vdiskinfo = self.storagedriver_client.info_volume( str(self.volume_id)) except: vdiskinfo = StorageDriverClient().empty_info() else: vdiskinfo = StorageDriverClient().empty_info() vdiskinfodict = {} for key, value in vdiskinfo.__class__.__dict__.items(): if type(value) is property: vdiskinfodict[key] = getattr(vdiskinfo, key) if key == 'object_type': vdiskinfodict[key] = str(vdiskinfodict[key]) return vdiskinfodict
def mark_offline(storagerouter_guid): """ Marks all StorageDrivers on this StorageRouter offline :param storagerouter_guid: Guid of the Storage Router :type storagerouter_guid: str :return: None """ for storagedriver in StorageRouter(storagerouter_guid).storagedrivers: vpool = storagedriver.vpool if len(vpool.storagedrivers) > 1: storagedriver_client = StorageDriverClient.load(vpool, excluded_storagedrivers=[storagedriver]) storagedriver_client.mark_node_offline(str(storagedriver.storagedriver_id))
def reload_client(self, client): """ Reloads the StorageDriverClient, ObjectRegistryClient or ClusterRegistry client """ self._frozen = False if client == 'storagedriver': self._storagedriver_client = StorageDriverClient.load(self) elif client == 'objectregistry': self._objectregistry_client = ObjectRegistryClient.load(self) elif client == 'clusterregistry': self._clusterregistry_client = ClusterRegistryClient.load(self) self._frozen = True
def _statistics(self, dynamic): """ Fetches the Statistics for the vDisk. """ volatile = VolatileFactory.get_client() prev_key = '{0}_{1}'.format(self._key, 'statistics_previous') # Load data from volumedriver if self.volume_id and self.vpool: try: vdiskstats = self.storagedriver_client.statistics_volume(str(self.volume_id)) except: vdiskstats = StorageDriverClient.empty_statistics() else: vdiskstats = StorageDriverClient.empty_statistics() # Load volumedriver data in dictionary vdiskstatsdict = {} for key, value in vdiskstats.__class__.__dict__.items(): if type(value) is property and key in StorageDriverClient.stat_counters: vdiskstatsdict[key] = getattr(vdiskstats, key) # Precalculate sums for key, items in StorageDriverClient.stat_sums.iteritems(): vdiskstatsdict[key] = 0 for item in items: vdiskstatsdict[key] += vdiskstatsdict[item] vdiskstatsdict['timestamp'] = time.time() # Calculate delta's based on previously loaded dictionary previousdict = volatile.get(prev_key, default={}) for key in vdiskstatsdict.keys(): if key in StorageDriverClient.stat_keys: delta = vdiskstatsdict['timestamp'] - previousdict.get('timestamp', vdiskstatsdict['timestamp']) if delta < 0: vdiskstatsdict['{0}_ps'.format(key)] = 0 elif delta == 0: vdiskstatsdict['{0}_ps'.format(key)] = previousdict.get('{0}_ps'.format(key), 0) else: vdiskstatsdict['{0}_ps'.format(key)] = max(0, (vdiskstatsdict[key] - previousdict[key]) / delta) volatile.set(prev_key, vdiskstatsdict, dynamic.timeout * 10) # Returning the dictionary return vdiskstatsdict
def move_away(storagerouter_guid): """ Moves away all vDisks from all Storage Drivers this Storage Router is serving :param storagerouter_guid: Guid of the Storage Router :type storagerouter_guid: str :return: None """ storagedrivers = StorageRouter(storagerouter_guid).storagedrivers if len(storagedrivers) > 0: storagedriver_client = StorageDriverClient.load(storagedrivers[0].vpool) for storagedriver in storagedrivers: storagedriver_client.mark_node_offline(str(storagedriver.storagedriver_id))
def update_status(storagedriver_id): """ Sets Storage Driver offline in case hypervisor management Center reports the hypervisor pmachine related to this Storage Driver as unavailable. """ pmachine = PMachineList.get_by_storagedriver_id(storagedriver_id) if pmachine.mgmtcenter: # Update status pmachine.invalidate_dynamics(['host_status']) host_status = pmachine.host_status if host_status != 'RUNNING': # Host is stopped storagedriver = StorageDriverList.get_by_storagedriver_id( storagedriver_id) storagedriver_client = StorageDriverClient().load( storagedriver.vpool) storagedriver_client.mark_node_offline( str(storagedriver.storagedriver_id)) else: # No management Center, cannot update status via api #TODO: should we try manually (ping, ssh)? pass
def move_away(storagerouter_guid): """ Moves away all vDisks from all Storage Drivers this Storage Router is serving :param storagerouter_guid: Guid of the Storage Router :type storagerouter_guid: str :return: None """ storagedrivers = StorageRouter(storagerouter_guid).storagedrivers if len(storagedrivers) > 0: storagedriver_client = StorageDriverClient.load( storagedrivers[0].vpool) for storagedriver in storagedrivers: storagedriver_client.mark_node_offline( str(storagedriver.storagedriver_id))
def _statistics(self): """ Aggregates the Statistics (IOPS, Bandwidth, ...) of each vDisk served by the vPool. """ client = StorageDriverClient() vdiskstatsdict = {} for key in client.stat_keys: vdiskstatsdict[key] = 0 vdiskstatsdict['{0}_ps'.format(key)] = 0 for vdisk in self.vdisks: for key, value in vdisk.statistics.iteritems(): if key != 'timestamp': vdiskstatsdict[key] += value vdiskstatsdict['timestamp'] = time.time() return vdiskstatsdict
def reload_client(self, client): """ Reloads the StorageDriverClient or ObjectRegistryClient """ if self.vpool_guid: self._frozen = False if client == 'storagedriver': self._storagedriver_client = StorageDriverClient.load( self.vpool) elif client == 'objectregistry': self._objectregistry_client = ObjectRegistryClient.load( self.vpool) elif client == 'filesystem_metadata': self._fsmetadata_client = FSMetaDataClient.load(self.vpool) self._frozen = True
def fetch_statistics(self): """ Loads statistics from this vDisk - returns unprocessed data """ # Load data from volumedriver vdiskstats = StorageDriverClient.EMPTY_STATISTICS() if self.volume_id and self.vpool: try: vdiskstats = self.storagedriver_client.statistics_volume( str(self.volume_id), req_timeout_secs=2) except Exception as ex: VDisk._logger.error( 'Error loading statistics_volume from {0}: {1}'.format( self.volume_id, ex)) # Load volumedriver data in dictionary return VDisk.extract_statistics(vdiskstats, self)
def update_status(storagedriver_id): """ Sets Storage Driver offline in case hypervisor management Center reports the hypervisor pmachine related to this Storage Driver as unavailable. :param storagedriver_id: ID of the storagedriver to update its status """ pmachine = PMachineList.get_by_storagedriver_id(storagedriver_id) storagedriver = StorageDriverList.get_by_storagedriver_id( storagedriver_id) storagerouter = storagedriver.storagerouter if pmachine.mgmtcenter: # Update status pmachine.invalidate_dynamics(['host_status']) else: # No management Center, cannot update status via api logger.info( 'Updating status of pmachine {0} using SSHClient'.format( pmachine.name)) host_status = 'RUNNING' try: client = SSHClient(storagerouter, username='******') configuration_dir = EtcdConfiguration.get( '/ovs/framework/paths|cfgdir') logger.info( 'SSHClient connected successfully to {0} at {1}'.format( pmachine.name, client.ip)) with Remote(client.ip, [LocalStorageRouterClient]) as remote: lsrc = remote.LocalStorageRouterClient( '{0}/storagedriver/storagedriver/{1}.json'.format( configuration_dir, storagedriver.vpool.name)) lsrc.server_revision() logger.info( 'LocalStorageRouterClient connected successfully to {0} at {1}' .format(pmachine.name, client.ip)) except Exception as ex: logger.error( 'Connectivity check failed, assuming host {0} is halted. {1}' .format(pmachine.name, ex)) host_status = 'HALTED' if host_status != 'RUNNING': # Host is stopped storagedriver_client = StorageDriverClient.load( storagedriver.vpool) storagedriver_client.mark_node_offline( str(storagedriver.storagedriver_id))
def _statistics(self): """ Aggregates the Statistics (IOPS, Bandwidth, ...) of the vDisks connected to the Storage Driver. """ client = StorageDriverClient() vdiskstatsdict = {} for key in client.stat_keys: vdiskstatsdict[key] = 0 vdiskstatsdict['{0}_ps'.format(key)] = 0 if self.vpool is not None: for disk in self.vpool.vdisks: if disk.storagedriver_id == self.storagedriver_id: for key, value in disk.statistics.iteritems(): if key != 'timestamp': vdiskstatsdict[key] += value vdiskstatsdict['timestamp'] = time.time() return vdiskstatsdict
def _info(self): """ Fetches the info (see Volume Driver API) for the vDisk. """ vdiskinfo = StorageDriverClient.EMPTY_INFO() max_redirects = False if self.volume_id and self.vpool: try: try: vdiskinfo = self.storagedriver_client.info_volume( str(self.volume_id), req_timeout_secs=2) except VolumeRestartInProgressException: time.sleep(0.5) vdiskinfo = self.storagedriver_client.info_volume( str(self.volume_id), req_timeout_secs=2) except MaxRedirectsExceededException: max_redirects = True except: pass vdiskinfodict = {} for key, value in vdiskinfo.__class__.__dict__.items(): if type(value) is property: objectvalue = getattr(vdiskinfo, key) if key == 'object_type': vdiskinfodict[key] = str(objectvalue) elif key == 'metadata_backend_config': vdiskinfodict[key] = {} if hasattr(objectvalue, 'node_configs') and callable( objectvalue.node_configs): vdiskinfodict[key] = [] for nodeconfig in objectvalue.node_configs(): vdiskinfodict[key].append({ 'ip': nodeconfig.address(), 'port': nodeconfig.port() }) else: vdiskinfodict[key] = objectvalue vdiskinfodict[ 'live_status'] = 'NON-RUNNING' if max_redirects is True else ( 'RUNNING' if vdiskinfodict['halted'] is False else 'HALTED') return vdiskinfodict
def update_status(storagedriver_id): """ Sets Storage Driver offline in case hypervisor management Center reports the hypervisor pmachine related to this Storage Driver as unavailable. :param storagedriver_id: ID of the storagedriver to update its status :type storagedriver_id: str :return: None """ pmachine = PMachineList.get_by_storagedriver_id(storagedriver_id) storagedriver = StorageDriverList.get_by_storagedriver_id( storagedriver_id) storagerouter = storagedriver.storagerouter if pmachine.mgmtcenter: # Update status pmachine.invalidate_dynamics(['host_status']) host_status = pmachine.host_status else: # No management Center, cannot update status via api StorageDriverController._logger.info( 'Updating status of pmachine {0} using SSHClient'.format( pmachine.name)) path = StorageDriverConfiguration( 'storagedriver', storagedriver.vpool.guid, storagedriver.storagedriver_id).remote_path host_status = 'RUNNING' try: client = SSHClient(storagerouter, username='******') StorageDriverController._logger.info( 'SSHClient connected successfully to {0} at {1}'.format( pmachine.name, client.ip)) except UnableToConnectException as ex: StorageDriverController._logger.error( 'SSHClient connectivity check failed, assuming host {0} is halted. {1}' .format(pmachine.name, ex)) host_status = 'HALTED' else: try: with remote(client.ip, [LocalStorageRouterClient]) as rem: lsrc = rem.LocalStorageRouterClient(path) lsrc.server_revision() StorageDriverController._logger.info( 'LocalStorageRouterClient connected successfully to {0} at {1}' .format(pmachine.name, client.ip)) except (EOFError, RuntimeError, ClusterNotReachableException) as ex: StorageDriverController._logger.error( 'LocalStorageRouterClient check failed, assuming volumedriver on host {0} {1} is halted. {2}' .format(pmachine.name, client.ip, ex)) host_status = 'HALTED' if host_status != 'RUNNING': # Host is stopped storagedriver_client = StorageDriverClient.load( storagedriver.vpool) storagedriver_client.mark_node_offline( str(storagedriver.storagedriver_id)) StorageDriverController._logger.warning( 'Storagedriver {0} marked offline'.format( storagedriver.storagedriver_id))