def get_list(self, storage_server, _target_type=None, _server_port=None): target_list = list() if not _target_type: target_types = STORAGE_SERVERS else: target_types = [_target_type] for target_type in target_types: if not self.caps.nfs_target_probe and target_type == 'netfs': targets = patch_find_nfs_target(storage_server) else: xml = self._get_storage_server_spec( server=storage_server, target_type=target_type, server_port=_server_port, ) conn = self.conn.get() try: ret = conn.findStoragePoolSources(target_type, xml, 0) except libvirt.libvirtError as e: wok_log.warning( f'Query storage pool source fails because of ' f'{e.get_error_message()}' ) continue targets = self._parse_target_source_result(target_type, ret) target_list.extend(targets) # Get all netfs and iscsi paths in use used_paths = [] try: conn = self.conn.get() # Get all existing ISCSI and NFS pools pools = conn.listAllStoragePools( libvirt.VIR_CONNECT_LIST_STORAGE_POOLS_ISCSI | libvirt.VIR_CONNECT_LIST_STORAGE_POOLS_NETFS ) for pool in pools: pool_xml = pool.XMLDesc(0) root = objectify.fromstring(pool_xml) if root.get('type') == 'netfs' and root.source.dir is not None: used_paths.append(root.source.dir.get('path')) elif root.get('type') == 'iscsi' and root.source.device is not None: used_paths.append(root.source.device.get('path')) except libvirt.libvirtError as e: wok_log.warning( f'Query storage pool source fails because of {e.get_error_message()}' ) # Filter target_list to not not show the used paths target_list = [ elem for elem in target_list if elem.get('target') not in used_paths ] return [dict(t) for t in set(tuple(t.items()) for t in target_list)]
def get_list(self, storage_server, _target_type=None, _server_port=None): target_list = list() if not _target_type: target_types = STORAGE_SERVERS else: target_types = [_target_type] for target_type in target_types: if not self.caps.nfs_target_probe and target_type == 'netfs': targets = patch_find_nfs_target(storage_server) else: xml = self._get_storage_server_spec(server=storage_server, target_type=target_type, server_port=_server_port) conn = self.conn.get() try: ret = conn.findStoragePoolSources(target_type, xml, 0) except libvirt.libvirtError as e: err = "Query storage pool source fails because of %s" wok_log.warning(err, e.get_error_message()) continue targets = self._parse_target_source_result(target_type, ret) target_list.extend(targets) # Get all netfs and iscsi paths in use used_paths = [] try: conn = self.conn.get() # Get all existing ISCSI and NFS pools pools = conn.listAllStoragePools( libvirt.VIR_CONNECT_LIST_STORAGE_POOLS_ISCSI | libvirt.VIR_CONNECT_LIST_STORAGE_POOLS_NETFS) for pool in pools: pool_xml = pool.XMLDesc(0) root = objectify.fromstring(pool_xml) if root.get('type') == 'netfs' and \ root.source.dir is not None: used_paths.append(root.source.dir.get('path')) elif root.get('type') == 'iscsi' and \ root.source.device is not None: used_paths.append(root.source.device.get('path')) except libvirt.libvirtError as e: err = "Query storage pool source fails because of %s" wok_log.warning(err, e.get_error_message()) # Filter target_list to not not show the used paths target_list = [elem for elem in target_list if elem.get('target') not in used_paths] return [dict(t) for t in set(tuple(t.items()) for t in target_list)]
def get_list(self, model_args): try: name = model_args nfsshares = patch_find_nfs_target(name) if not nfsshares: raise NotFoundError("GINNFS00002E") fs_details = fs_utils._get_df_output() fs_name_list = [d['filesystem'] for d in fs_details] sharepoints = [] for nfs_share in nfsshares: nfsmount = nfs_share['host_name'] + ':' + nfs_share['target'] if nfsmount not in fs_name_list: sharepoints.append(nfs_share['target']) return {'NFSShares': sharepoints} except ValueError: raise OperationFailed("GINNFS00001E", {'name': name})
def get_list(self, model_args): try: name = model_args nfsshares = patch_find_nfs_target(name) if not nfsshares: raise NotFoundError("GINNFS00002E") fs_details = fs_utils._get_df_output() fs_name_list = [d['filesystem'] for d in fs_details] sharepoints = [] for nfs_share in nfsshares: nfsmount = nfs_share['host_name']+':'+nfs_share['target'] if nfsmount not in fs_name_list: sharepoints.append(nfs_share['target']) return {'NFSShares': sharepoints} except ValueError: raise OperationFailed("GINNFS00001E", {'name': name})