def _get_filtered_remote_services(self): remote_services = self.driver._service._client.\ client.services.list(binary="nova-compute") multi_scg_hosts_names = set() for old_scg in self.scg_list: # Try use the latest one? scg = (commonutils.get_utils().get_scg_by_scgName( old_scg.display_name)) scg_host_list = getattr(scg, 'host_list', []) for host in scg_host_list: if host and host.get('name'): multi_scg_hosts_names.add(host.get('name')) if not multi_scg_hosts_names: LOG.info("No host listed in scg: '%s'" % str(self.scg_list)) return remote_services host_names = [ utils.normalize_host(name) for name in multi_scg_hosts_names ] filtered_services = [] for remote_service in remote_services: if utils.normalize_host(remote_service.host) in host_names: filtered_services.append(remote_service) return filtered_services
def _get_filtered_remote_services(self): remote_services = self.driver._service._client.\ client.services.list(binary="nova-compute") multi_scg_hosts_names = set() for old_scg in self.scg_list: # Try use the latest one? scg = (commonutils.get_utils(). get_scg_by_scgName(old_scg.display_name)) scg_host_list = getattr(scg, 'host_list', []) for host in scg_host_list: if host and host.get('name'): multi_scg_hosts_names.add(host.get('name')) if not multi_scg_hosts_names: LOG.info("No host listed in scg: '%s'" % str(self.scg_list)) return remote_services host_names = [utils.normalize_host(name) for name in multi_scg_hosts_names] filtered_services = [] for remote_service in remote_services: if utils.normalize_host(remote_service.host) in host_names: filtered_services.append(remote_service) return filtered_services
def list(self, scgUUID=None, scgName=None): """ Get a list of the Storage Template that filtered by a specified SCG UUID or SCG name, if both SCG UUID and SCG name are specified, UUID has the high priority to check. :rtype: list of :class:`VolumeType` """ # Get accessible volumes by SCG if scgUUID or scgName: return (utils.get_utils().get_scg_accessible_storage_templates( scgUUID=scgUUID, scgName=scgName)) else: return ( utils.get_utils().get_multi_scg_accessible_storage_templates( None, None))
def test_list_volumes_2(self): returnvalues = [Volume(self, res, loaded=True) for res in self.volume_list if res] commonutils.get_utils().get_scg_accessible_volumes = \ mock.MagicMock(return_value=returnvalues) result = self.cs.volumes.list(True, None, 'SCGUUID', None) self.assertEquals(result[0].name, "sample-volume for cinder")
def list(self, scgUUID=None, scgName=None): """ Get a list of the Storage Template that filtered by a specified SCG UUID or SCG name, if both SCG UUID and SCG name are specified, UUID has the high priority to check. :rtype: list of :class:`VolumeType` """ # Get accessible volumes by SCG if scgUUID or scgName: return (utils.get_utils(). get_scg_accessible_storage_templates(scgUUID=scgUUID, scgName=scgName)) else: return (utils.get_utils(). get_multi_scg_accessible_storage_templates(None, None))
def test_list_volumes_1(self): returnvalues = [Volume(self, res, loaded=True) for res in self.volume_list if res] commonutils.get_utils().get_multi_scg_accessible_volumes = \ mock.MagicMock(return_value=returnvalues) result = self.cs.volumes.list() self.assertEquals(result[0].id, 1234) self.assertEquals(result[1].name, "pvc sample-volume for cinder")
def test_list_volumes_2(self): returnvalues = [ Volume(self, res, loaded=True) for res in self.volume_list if res ] commonutils.get_utils().get_scg_accessible_volumes = \ mock.MagicMock(return_value=returnvalues) result = self.cs.volumes.list(True, None, 'SCGUUID', None) self.assertEquals(result[0].name, "sample-volume for cinder")
def test_list_SP_2(self): expected = self.expected_sp returnvalue = [ext_cinder.StorageProvider(None, expected[0], True)] commonutils.get_utils().get_multi_scg_accessible_storage_providers = \ mock.MagicMock(return_value=returnvalue) result = self.cs.storage_providers.list() for idx, hyper in enumerate(result): self.compare_to_expected(expected[idx], hyper)
def test_list_volumes_1(self): returnvalues = [ Volume(self, res, loaded=True) for res in self.volume_list if res ] commonutils.get_utils().get_multi_scg_accessible_volumes = \ mock.MagicMock(return_value=returnvalues) result = self.cs.volumes.list() self.assertEquals(result[0].id, 1234) self.assertEquals(result[1].name, "pvc sample-volume for cinder")
def test_list_storage_templates_2(self): data = self.volumes_type_list[2] returnvalues = [VolumeType(VolumeTypeManager, res, loaded=True) for res in [data] if res] commonutils.get_utils().get_scg_accessible_storage_templates = \ mock.MagicMock(return_value=returnvalues) result = self.cs.volume_types.list("SCGUUID", None) self.assertEquals(result[0].name, "LUKS")
def test_list_storage_templates_1(self): returnvalues = [VolumeType(VolumeTypeManager, res, loaded=True) for res in self.volumes_type_list if res] commonutils.get_utils().get_multi_scg_accessible_storage_templates = \ mock.MagicMock(return_value=returnvalues) result = self.cs.volume_types.list() self.assertEquals(result[0].id, "6627888e-9f59-4996-8c22-5d528c3273f") self.assertEquals(result[1].name, "dm-crypt") self.assertEquals(result[2].name, "LUKS")
def test_list_storage_templates_2(self): data = self.volumes_type_list[2] returnvalues = [ VolumeType(VolumeTypeManager, res, loaded=True) for res in [data] if res ] commonutils.get_utils().get_scg_accessible_storage_templates = \ mock.MagicMock(return_value=returnvalues) result = self.cs.volume_types.list("SCGUUID", None) self.assertEquals(result[0].name, "LUKS")
def test_list_storage_templates_1(self): returnvalues = [ VolumeType(VolumeTypeManager, res, loaded=True) for res in self.volumes_type_list if res ] commonutils.get_utils().get_multi_scg_accessible_storage_templates = \ mock.MagicMock(return_value=returnvalues) result = self.cs.volume_types.list() self.assertEquals(result[0].id, "6627888e-9f59-4996-8c22-5d528c3273f") self.assertEquals(result[1].name, "dm-crypt") self.assertEquals(result[2].name, "LUKS")
def list(self, detailed=True, search_opts=None, scgUUID=None, scgName=None): """ Get a list of the Storage Template that filtered by a specified SCG UUID or SCG name, if both SCG UUID and SCG name are specified, UUID has the high priority to check. :rtype: list of :class:`StorageProvider` """ # Get accessible volumes by SCG if scgUUID or scgName: return (utils.get_utils(). get_scg_accessible_storage_providers( scgUUID=scgUUID, scgName=scgName, detailed=detailed, search_opts=search_opts) ) else: return (utils.get_utils(). get_multi_scg_accessible_storage_providers( None, None, detailed=detailed, search_opts=search_opts) )
def list(self, detailed=True, search_opts=None, scgUUID=None, scgName=None): """ Get a list of the volumes that filtered by a specified SCG UUID or SCG name, if both SCG UUID and SCG name are specified, UUID has the high priority to check. :rtype: list of :class:`Volume` """ # Get accessible volumes by SCG if scgUUID or scgName: return (utils.get_utils().get_scg_accessible_volumes( scgUUID=scgUUID, scgName=scgName, detailed=detailed, search_opts=search_opts)) else: return (utils.get_utils().get_multi_scg_accessible_volumes( None, None, detailed=detailed, search_opts=search_opts))
def list(self, detailed=True, search_opts=None, scgUUID=None, scgName=None): """ Get a list of the Servers that filtered by a specified SCG UUID or SCG name, if both SCG UUID and SCG name are specified, UUID has the high priority to check. :rtype: list of :class:`Server` """ if scgUUID or scgName: return utils.get_utils().get_scg_accessible_servers(scgUUID, scgName, detailed, search_opts ) else: # This will get all scgs accessible servers return utils.get_utils().\ get_multi_scg_accessible_servers(None, None, detailed, search_opts )
def test_list(self): comm_utils.get_utils = MagicMock() comm_utils.get_utils().get_multi_scg_accessible_servers = MagicMock() self.cs.manager.list() comm_utils.get_utils().get_multi_scg_accessible_servers.\ assert_called_once_with(None, None, True, None)