Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
    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
Ejemplo n.º 3
0
    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))
Ejemplo n.º 4
0
    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")
Ejemplo n.º 5
0
    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))
Ejemplo n.º 6
0
    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")
Ejemplo n.º 7
0
    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")
Ejemplo n.º 8
0
    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)
Ejemplo n.º 9
0
    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")
Ejemplo n.º 10
0
    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)
Ejemplo n.º 11
0
    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")
Ejemplo n.º 12
0
    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")
Ejemplo n.º 13
0
    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")
Ejemplo n.º 14
0
    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")
Ejemplo n.º 15
0
    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)
                    )
Ejemplo n.º 16
0
    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))
Ejemplo n.º 17
0
    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
                                                 )
Ejemplo n.º 18
0
 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)
Ejemplo n.º 19
0
 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)