Beispiel #1
0
 def setUp(self):
     ovn_conf.register_opts()
     cfg.CONF.set_override('extension_drivers',
                           self._extension_drivers,
                           group='ml2')
     cfg.CONF.set_override('enable_distributed_floating_ip',
                           'False',
                           group='ovn')
     extensions.register_custom_supported_check(qos_api.ALIAS,
                                                lambda: True,
                                                plugin_agnostic=True)
     super(TestOVNClientQosExtension, self).setUp()
     self.setup_coreplugin(self.CORE_PLUGIN_CLASS, load_plugins=True)
     self._mock_qos_loaded = mock.patch.object(
         core_qos.QosCoreResourceExtension, 'plugin_loaded')
     self.mock_qos_loaded = self._mock_qos_loaded.start()
     self.txn = _Context()
     mock_driver = mock.Mock()
     mock_driver._nb_idl.transaction.return_value = self.txn
     self.qos_driver = qos_extension.OVNClientQosExtension(
         driver=mock_driver)
     self._mock_rules = mock.patch.object(self.qos_driver,
                                          '_update_port_qos_rules')
     self.mock_rules = self._mock_rules.start()
     self.addCleanup(self._mock_rules.stop)
     self.ctx = context.get_admin_context()
     self.project_id = uuidutils.generate_uuid()
     self._initialize_objs()
Beispiel #2
0
class Sorting(api_extensions.ExtensionDescriptor):
    """Fake extension that indicates that sorting is enabled."""

    extensions.register_custom_supported_check(
        _ALIAS, lambda: True, plugin_agnostic=True
    )

    @classmethod
    def get_name(cls):
        return "Sorting support"

    @classmethod
    def get_alias(cls):
        return _ALIAS

    @classmethod
    def get_description(cls):
        return "Extension that indicates that sorting is enabled."

    @classmethod
    def get_updated(cls):
        return "2016-06-12T00:00:00-00:00"

    @classmethod
    def get_resources(cls):
        return []

    def get_extended_resources(self, version):
        return {}
Beispiel #3
0
class Project_id(api_extensions.ExtensionDescriptor):
    """Extension that indicates that project_id is enabled.

    This extension indicates that the Keystone V3 'project_id' field
    is supported in the API.
    """

    extensions.register_custom_supported_check(_ALIAS,
                                               lambda: True,
                                               plugin_agnostic=True)

    @classmethod
    def get_name(cls):
        return "project_id field enabled"

    @classmethod
    def get_alias(cls):
        return _ALIAS

    @classmethod
    def get_description(cls):
        return "Extension that indicates that project_id field is enabled."

    @classmethod
    def get_updated(cls):
        return "2016-09-09T09:09:09-09:09"

    @classmethod
    def get_resources(cls):
        return []

    def get_extended_resources(self, version):
        return {}
class Pagination(api_extensions.APIExtensionDescriptor):
    """Fake extension that indicates that pagination is enabled."""

    api_definition = apidef

    extensions.register_custom_supported_check(apidef.ALIAS,
                                               lambda: True,
                                               plugin_agnostic=True)
class Project_id(api_extensions.APIExtensionDescriptor):
    """Extension that indicates that project_id is enabled.

    This extension indicates that the Keystone V3 'project_id' field
    is supported in the API.
    """

    api_definition = apidef

    extensions.register_custom_supported_check(apidef.ALIAS,
                                               lambda: True,
                                               plugin_agnostic=True)
Beispiel #6
0
    def test_custom_supported_implementation(self):
        self.useFixture(CustomExtensionCheckMapMemento())

        class FakePlugin(object):
            pass

        class FakeExtension(ext_stubs.StubExtension):
            extensions.register_custom_supported_check('stub_extension',
                                                       lambda: True,
                                                       plugin_agnostic=True)

        ext = FakeExtension()

        plugin_info = {lib_const.CORE: FakePlugin()}
        ext_mgr = extensions.PluginAwareExtensionManager('', plugin_info)
        ext_mgr.add_extension(ext)
        self.assertIn("stub_extension", ext_mgr.extensions)

        extensions.register_custom_supported_check('stub_extension',
                                                   lambda: False,
                                                   plugin_agnostic=True)
        ext_mgr = extensions.PluginAwareExtensionManager('', plugin_info)
        ext_mgr.add_extension(ext)
        self.assertNotIn("stub_extension", ext_mgr.extensions)
Beispiel #7
0
    def test_custom_supported_implementation(self):
        self.useFixture(CustomExtensionCheckMapMemento())

        class FakePlugin(object):
            pass

        class FakeExtension(ext_stubs.StubExtension):
            extensions.register_custom_supported_check(
                'stub_extension', lambda: True, plugin_agnostic=True
            )

        ext = FakeExtension()

        plugin_info = {lib_const.CORE: FakePlugin()}
        ext_mgr = extensions.PluginAwareExtensionManager('', plugin_info)
        ext_mgr.add_extension(ext)
        self.assertIn("stub_extension", ext_mgr.extensions)

        extensions.register_custom_supported_check(
            'stub_extension', lambda: False, plugin_agnostic=True
        )
        ext_mgr = extensions.PluginAwareExtensionManager('', plugin_info)
        ext_mgr.add_extension(ext)
        self.assertNotIn("stub_extension", ext_mgr.extensions)
Beispiel #8
0
class Quotasv2(api_extensions.ExtensionDescriptor):
    """Quotas management support."""

    extensions.register_custom_supported_check(RESOURCE_COLLECTION,
                                               lambda: True,
                                               plugin_agnostic=True)

    @classmethod
    def get_name(cls):
        return "Quota management support"

    @classmethod
    def get_alias(cls):
        return RESOURCE_COLLECTION

    @classmethod
    def get_description(cls):
        description = 'Expose functions for quotas management'
        if cfg.CONF.QUOTAS.quota_driver == DB_QUOTA_DRIVER:
            description += ' per project'
        return description

    @classmethod
    def get_updated(cls):
        return "2012-07-29T10:00:00-00:00"

    @classmethod
    def get_resources(cls):
        """Returns Ext Resources."""
        controller = resource.Resource(QuotaSetsController(
            directory.get_plugin()),
                                       faults=faults.FAULT_MAP)
        return [
            extensions.ResourceExtension(
                Quotasv2.get_alias(),
                controller,
                member_actions={DEFAULT_QUOTAS_ACTION: 'GET'},
                collection_actions={
                    'tenant': 'GET',
                    'project': 'GET'
                })
        ]

    def get_extended_resources(self, version):
        if version == "2.0":
            return EXTENDED_ATTRIBUTES_2_0
        else:
            return {}
Beispiel #9
0
class A10deviceinstance(extensions.ExtensionDescriptor):

    nextensions.register_custom_supported_check(_ALIAS,
                                                lambda: True,
                                                plugin_agnostic=True)

    def get_name(cls):
        return "A10 Device Instances"

    @classmethod
    def get_alias(cls):
        return constants.A10_DEVICE_INSTANCE_EXT

    @classmethod
    def get_namespace(cls):
        return "http://docs.openstack.org/ext/neutron/a10_device_instance/api/v1.0"

    @classmethod
    def get_updated(cls):
        return "2015-11-18T16:17:00-07:00"

    @classmethod
    def get_description(cls):
        return ("A10 Device Instances")

    @classmethod
    def get_resources(cls):
        """Returns external resources."""
        my_plurals = resource_helper.build_plural_mappings(
            {}, RESOURCE_ATTRIBUTE_MAP)
        attributes.PLURALS.update(my_plurals)
        attr_map = RESOURCE_ATTRIBUTE_MAP
        resources = resource_helper.build_resource_info(
            my_plurals, attr_map, constants.A10_DEVICE_INSTANCE)

        return resources

    def update_attributes_map(self, attributes):
        super(A10deviceinstance, self).update_attributes_map(
            attributes, extension_attrs_map=RESOURCE_ATTRIBUTE_MAP)

    def get_extended_resources(self, version):
        if version == "2.0":
            return RESOURCE_ATTRIBUTE_MAP
        else:
            return {}
class A10Certificate(extensions.ExtensionDescriptor):
    nextensions.register_custom_supported_check(constants.A10_CERTIFICATE_EXT,
                                                lambda: True,
                                                plugin_agnostic=True)

    @classmethod
    def get_name(cls):
        return "A10 LBaaS Certificate Management"

    @classmethod
    def get_alias(cls):
        return constants.A10_CERTIFICATE_EXT

    @classmethod
    def get_namespace(cls):
        return "http://docs.openstack.org/ext/neutron/a10-certificates/api/v1.0"

    @classmethod
    def get_updated(cls):
        return "2016-06-19T16:20:13-07:00"

    @classmethod
    def get_description(cls):
        return ("A10 Networks SSL Certificiate Management")

    @classmethod
    def get_resources(cls):
        """Returns external resources."""
        my_plurals = resource_helper.build_plural_mappings(
            {}, RESOURCE_ATTRIBUTE_MAP)
        attributes.PLURALS.update(my_plurals)
        attr_map = RESOURCE_ATTRIBUTE_MAP
        ext_resources = resource_helper.build_resource_info(
            my_plurals, attr_map, constants.A10_CERTIFICATE)

        return ext_resources

    def update_attributes_map(self, attributes):
        super(A10Certificate, self).update_attributes_map(
            attributes, extension_attrs_map=RESOURCE_ATTRIBUTE_MAP)

    def get_extended_resources(self, version):
        if version == "2.0":
            return RESOURCE_ATTRIBUTE_MAP
        else:
            return {}
Beispiel #11
0
class Quotasv2_detail(api_extensions.ExtensionDescriptor):
    """Quota details management support."""

    # Ensure new extension is not loaded with old conf driver.
    extensions.register_custom_supported_check(
        ALIAS, lambda: QUOTA_DRIVER in DB_QUOTA_DRIVERS, plugin_agnostic=True)

    @classmethod
    def get_name(cls):
        return "Quota details management support"

    @classmethod
    def get_alias(cls):
        return ALIAS

    @classmethod
    def get_description(cls):
        return 'Expose functions for quotas usage statistics per project'

    @classmethod
    def get_updated(cls):
        return "2017-02-10T10:00:00-00:00"

    @classmethod
    def get_resources(cls):
        """Returns Extension Resources."""
        controller = resource.Resource(DetailQuotaSetsController(
            directory.get_plugin()),
                                       faults=faults.FAULT_MAP)
        return [
            extensions.ResourceExtension(RESOURCE_COLLECTION,
                                         controller,
                                         member_actions={'details': 'GET'},
                                         collection_actions={
                                             'tenant': 'GET',
                                             'project': 'GET'
                                         })
        ]

    def get_extended_resources(self, version):
        return EXTENDED_ATTRIBUTES_2_0 if version == "2.0" else {}

    def get_required_extensions(self):
        return ["quotas"]
Beispiel #12
0
 class FakeExtension(ext_stubs.StubExtension):
     extensions.register_custom_supported_check('stub_plugin_extension',
                                                lambda: True,
                                                plugin_agnostic=False)