def test_multiple_plugins_specified_for_service_type(self):
        cfg.CONF.set_override("service_plugins", [
            "quantum.tests.unit.dummy_plugin."
            "QuantumDummyPlugin", "quantum.tests.unit.dummy_plugin."
            "QuantumDummyPlugin"
        ])

        try:
            QuantumManager.get_instance().get_service_plugins()
            self.assertTrue(
                False, "Shouldn't load multiple plugins "
                "for the same type")
        except Exception as e:
            LOG.debug(str(e))
    def test_multiple_plugins_specified_for_service_type(self):
        cfg.CONF.set_override("service_plugins",
                              ["quantum.tests.unit.dummy_plugin."
                               "QuantumDummyPlugin",
                               "quantum.tests.unit.dummy_plugin."
                               "QuantumDummyPlugin"])

        try:
            QuantumManager.get_instance().get_service_plugins()
            self.assertTrue(False,
                            "Shouldn't load multiple plugins "
                            "for the same type")
        except Exception as e:
            LOG.debug(str(e))
Exemple #3
0
    def setUp(self):
        plugin = 'quantum.quantum_plugin_base_v2.QuantumPluginBaseV2'

        # Ensure 'stale' patched copies of the plugin are never returned
        QuantumManager._instance = None

        # Ensure existing ExtensionManager is not used
        PluginAwareExtensionManager._instance = None

        # Save the global RESOURCE_ATTRIBUTE_MAP
        self.saved_attr_map = {}
        for resource, attrs in attributes.RESOURCE_ATTRIBUTE_MAP.iteritems():
            self.saved_attr_map[resource] = attrs.copy()

        # Create the default configurations
        args = ['--config-file', etcdir('quantum.conf.test')]
        config.parse(args=args)

        # Update the plugin and extensions path
        cfg.CONF.set_override('core_plugin', plugin)
        cfg.CONF.set_override('api_extensions_path', EXTDIR)

        self._plugin_patcher = mock.patch(plugin, autospec=True)
        self.plugin = self._plugin_patcher.start()

        # Instantiate mock plugin and enable the V2attributes extension
        QuantumManager.get_plugin().supported_extension_aliases = ["v2attrs"]

        api = router.APIRouter()
        self.api = webtest.TestApp(api)
    def setUp(self):
        super(ProvidernetExtensionTestCase, self).setUp()

        plugin = "quantum.quantum_plugin_base_v2.QuantumPluginBaseV2"
        # Ensure 'stale' patched copies of the plugin are never returned
        QuantumManager._instance = None

        # Ensure existing ExtensionManager is not used
        extensions.PluginAwareExtensionManager._instance = None

        # Save the global RESOURCE_ATTRIBUTE_MAP
        self.saved_attr_map = {}
        for resource, attrs in attributes.RESOURCE_ATTRIBUTE_MAP.iteritems():
            self.saved_attr_map[resource] = attrs.copy()

        # Update the plugin and extensions path
        cfg.CONF.set_override("core_plugin", plugin)
        cfg.CONF.set_override("allow_pagination", True)
        cfg.CONF.set_override("allow_sorting", True)
        self._plugin_patcher = mock.patch(plugin, autospec=True)
        self.plugin = self._plugin_patcher.start()
        # Ensure Quota checks never fail because of mock
        instance = self.plugin.return_value
        instance.get_networks_count.return_value = 1
        # Instantiate mock plugin and enable the 'provider' extension
        QuantumManager.get_plugin().supported_extension_aliases = ["provider"]
        ext_mgr = ProviderExtensionManager()
        self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr)
        self.addCleanup(self._plugin_patcher.stop)
        self.addCleanup(cfg.CONF.reset)
        self.addCleanup(self._restore_attribute_map)
        self.api = webtest.TestApp(router.APIRouter())
Exemple #5
0
 def get_resources(cls):
     """Returns Ext Resources."""
     parent_resource = dict(member_name="tenant",
                            collection_name="extensions/csco/tenants")
     controller = CredentialController(QuantumManager.get_plugin())
     return [extensions.ResourceExtension('credentials', controller,
                                          parent=parent_resource)]
 def get_resources(cls):
     controller = UdpChannelsController(QuantumManager.get_plugin())
     parent_resource = dict(member_name="network",
         collection_name="extensions/udp/tenants/" +\
                         ":(tenant_id)/networks")
     return [extensions.ResourceExtension('channels', controller,
         parent=parent_resource)]
Exemple #7
0
    def setUp(self):
        super(ProvidernetExtensionTestCase, self).setUp()

        plugin = 'quantum.quantum_plugin_base_v2.QuantumPluginBaseV2'
        # Ensure 'stale' patched copies of the plugin are never returned
        QuantumManager._instance = None

        # Ensure existing ExtensionManager is not used
        extensions.PluginAwareExtensionManager._instance = None

        # Save the global RESOURCE_ATTRIBUTE_MAP
        self.saved_attr_map = {}
        for resource, attrs in attributes.RESOURCE_ATTRIBUTE_MAP.iteritems():
            self.saved_attr_map[resource] = attrs.copy()

        # Update the plugin and extensions path
        cfg.CONF.set_override('core_plugin', plugin)
        cfg.CONF.set_override('allow_pagination', True)
        cfg.CONF.set_override('allow_sorting', True)
        self._plugin_patcher = mock.patch(plugin, autospec=True)
        self.plugin = self._plugin_patcher.start()
        # Ensure Quota checks never fail because of mock
        instance = self.plugin.return_value
        instance.get_networks_count.return_value = 1
        # Instantiate mock plugin and enable the 'provider' extension
        QuantumManager.get_plugin().supported_extension_aliases = ([
            "provider"
        ])
        ext_mgr = ProviderExtensionManager()
        self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr)
        self.addCleanup(self._plugin_patcher.stop)
        self.addCleanup(cfg.CONF.reset)
        self.addCleanup(self._restore_attribute_map)
        self.api = webtest.TestApp(router.APIRouter())
 def setUp(self):
     self.httpPatch = patch('httplib.HTTPConnection', create=True,
                            new=HTTPConnectionMock)
     self.httpPatch.start()
     test_l3_plugin.L3NatDBTestCase.setUp = new_L3_setUp
     super(RouterDBTestCase, self).setUp()
     self.plugin_obj = QuantumManager.get_plugin()
Exemple #9
0
 def get_resources(cls):
     """ Returns Ext Resources """
     controller = QuotaSetsController(QuantumManager.get_plugin())
     return [extensions.ResourceExtension(
         Quotasv2.get_alias(),
         controller,
         collection_actions={'tenant': 'GET'})]
    def setUp(self):

        """ Set up function """

        super(QosExtensionTest, self).setUp()
        parent_resource = dict(member_name="tenant",
                               collection_name="extensions/csco/tenants")
        controller = qos.QosController(QuantumManager.get_plugin())
        res_ext = extensions.ResourceExtension('qos', controller,
                                               parent=parent_resource)

        self.test_app = setup_extensions_test_app(
            SimpleExtensionManager(res_ext))
        self.contenttype = 'application/json'
        self.qos_path = '/extensions/csco/tenants/tt/qos'
        self.qos_second_path = '/extensions/csco/tenants/tt/qos/'
        self.test_qos_data = {
            'qos': {
                'qos_name': 'cisco_test_qos',
                'qos_desc': {
                    'PPS': 50,
                    'TTL': 5,
                },
            },
        }
        self._l2network_plugin = l2network_plugin.L2Network()
Exemple #11
0
    def setUp(self):
        plugin = 'quantum.quantum_plugin_base_v2.QuantumPluginBaseV2'

        # Ensure 'stale' patched copies of the plugin are never returned
        QuantumManager._instance = None

        # Ensure existing ExtensionManager is not used
        PluginAwareExtensionManager._instance = None

        # Save the global RESOURCE_ATTRIBUTE_MAP
        self.saved_attr_map = {}
        for resource, attrs in attributes.RESOURCE_ATTRIBUTE_MAP.iteritems():
            self.saved_attr_map[resource] = attrs.copy()

        # Create the default configurations
        args = ['--config-file', etcdir('quantum.conf.test')]
        config.parse(args=args)

        # Update the plugin and extensions path
        cfg.CONF.set_override('core_plugin', plugin)
        cfg.CONF.set_override('api_extensions_path', EXTDIR)

        self._plugin_patcher = mock.patch(plugin, autospec=True)
        self.plugin = self._plugin_patcher.start()

        # Instantiate mock plugin and enable the V2attributes extension
        QuantumManager.get_plugin().supported_extension_aliases = ["v2attrs"]

        api = router.APIRouter()
        self.api = webtest.TestApp(api)
Exemple #12
0
    def setUp(self, plugin=None):
        super(PortSecurityTestCase, self).setUp()

        # Check if a plugin supports security groups
        plugin_obj = QuantumManager.get_plugin()
        self._skip_security_group = (
            'security-group' not in plugin_obj.supported_extension_aliases)
Exemple #13
0
 def get_resources(self):
     resource = base.create_resource(
         "packet_filters", "packet_filter", QuantumManager.get_plugin(), PACKET_FILTER_ATTR_MAP
     )
     qresource = quota.CountableResource("packet_filter", quota._count_resource, "quota_packet_filter")
     quota.QUOTAS.register_resource(qresource)
     return [extensions.ResourceExtension("packet_filters", resource)]
    def setUp(self, plugin=None):
        super(PortSecurityTestCase, self).setUp()

        # Check if a plugin supports security groups
        plugin_obj = QuantumManager.get_plugin()
        self._skip_security_group = ('security-group' not in
                                     plugin_obj.supported_extension_aliases)
 def delete_network(self, context, id):
     """
     Perform this operation in the context of the configured device
     plugins.
     """
     try:
         base_plugin_ref = QuantumManager.get_plugin()
         n = base_plugin_ref.get_network(context, id)
         tenant_id = n['tenant_id']
         vlan_id = self._get_segmentation_id(id)
         args = [context, id]
         ovs_output = self._invoke_plugin_per_device(
             const.VSWITCH_PLUGIN, self._func_name(), args)
         args = [
             tenant_id, id, {
                 const.VLANID: vlan_id
             }, {
                 const.CONTEXT: context
             }, {
                 const.BASE_PLUGIN_REF: base_plugin_ref
             }
         ]
         if self._validate_vlan_id(vlan_id):
             self._invoke_plugin_per_device(const.NEXUS_PLUGIN,
                                            self._func_name(), args)
         return ovs_output[0]
     except:
         raise
Exemple #16
0
    def setUp(self):
        """ Set up function """

        super(QosExtensionTest, self).setUp()
        parent_resource = dict(member_name="tenant",
                               collection_name="extensions/csco/tenants")
        controller = qos.QosController(QuantumManager.get_plugin())
        res_ext = extensions.ResourceExtension('qos',
                                               controller,
                                               parent=parent_resource)

        self.test_app = setup_extensions_test_app(
            SimpleExtensionManager(res_ext))
        self.contenttype = 'application/json'
        self.qos_path = '/extensions/csco/tenants/tt/qos'
        self.qos_second_path = '/extensions/csco/tenants/tt/qos/'
        self.test_qos_data = {
            'qos': {
                'qos_name': 'cisco_test_qos',
                'qos_desc': {
                    'PPS': 50,
                    'TTL': 5,
                },
            },
        }
        self._l2network_plugin = l2network_plugin.L2Network()
 def get_resources(cls):
     controller = PortsMetadataController(QuantumManager.get_plugin())
     parent_resource = {
         "member_name": "network",
         "collection_name":
             "extensions/attributes/tenants/:(tenant_id)/networks"}
     return [extensions.ResourceExtension('ports', controller,
         parent=parent_resource)]
 def setUp(self):
     self.httpPatch = patch('httplib.HTTPConnection',
                            create=True,
                            new=HTTPConnectionMock)
     self.httpPatch.start()
     test_l3_plugin.L3NatDBTestCase.setUp = new_L3_setUp
     super(RouterDBTestCase, self).setUp()
     self.plugin_obj = QuantumManager.get_plugin()
Exemple #19
0
 def get_resources(cls):
     """ Returns Ext Resources """
     controller = QuotaSetsController(QuantumManager.get_plugin())
     return [
         extensions.ResourceExtension(Quotasv2.get_alias(),
                                      controller,
                                      collection_actions={'tenant': 'GET'})
     ]
Exemple #20
0
 def get_resources(cls):
     """ Returns all defined resources """
     controller = StatsController(QuantumManager.get_plugin())
     parent_resource = dict(member_name="port",
                            collection_name="extensions/ovs/tenants/" + \
                            ":(tenant_id)/networks/:(network_id)/ports")
     return [extensions.ResourceExtension('stats', controller,
                                          parent=parent_resource)]
    def _get_plugin_ref(self):
        plugin_obj = QuantumManager.get_plugin()
        if getattr(plugin_obj, "_master"):
            plugin_ref = plugin_obj
        else:
            plugin_ref = getattr(plugin_obj, "_model").\
                _plugins[const.VSWITCH_PLUGIN]

        return plugin_ref
Exemple #22
0
 def test_load_plugin_with_full_options(self):
     q_config.parse([
         '--config-file', BASE_CONF_PATH, '--config-file', NVP_INI_FULL_PATH
     ])
     cfg.CONF.set_override('core_plugin', NVP_PLUGIN_PATH)
     plugin = QuantumManager().get_plugin()
     cluster = plugin.cluster
     self._assert_required_options(cluster)
     self._assert_extra_options(cluster)
Exemple #23
0
    def _get_plugin_ref(self):
        plugin_obj = QuantumManager.get_plugin()
        if getattr(plugin_obj, "_master"):
            plugin_ref = plugin_obj
        else:
            plugin_ref = getattr(plugin_obj, "_model").\
                _plugins[const.VSWITCH_PLUGIN]

        return plugin_ref
Exemple #24
0
 def get_resources(self):
     resource = base.create_resource('packet_filters', 'packet_filter',
                                     QuantumManager.get_plugin(),
                                     PACKET_FILTER_ATTR_MAP)
     qresource = quota.CountableResource('packet_filter',
                                         quota._count_resource,
                                         'quota_packet_filter')
     quota.QUOTAS.register_resource(qresource)
     return [extensions.ResourceExtension('packet_filters', resource)]
 def test_network_admin_state(self):
     name = 'network_test'
     admin_status_up = False
     tenant_id = 'tenant_test'
     network = {'network': {'name': name,
                            'admin_state_up': admin_status_up,
                            'tenant_id': tenant_id}}
     plugin = QuantumManager.get_plugin()
     self.assertEqual(plugin._network_admin_state(network), network)
Exemple #26
0
 def get_instance(cls):
     if cls._instance is None:
         plugin_provider = cfg.CONF.core_plugin
         if plugin_provider in ENABLED_EXTS:
             for model in ENABLED_EXTS[plugin_provider]["ext_db_models"]:
                 LOG.debug("loading model %s", model)
                 model_class = importutils.import_class(model)
         cls._instance = cls(get_extensions_path(), QuantumManager.get_plugin())
     return cls._instance
Exemple #27
0
 def test_load_api_extensions(self):
     q_config.parse([
         '--config-file', NVP_BASE_CONF_PATH, '--config-file',
         NVP_INI_FULL_PATH
     ])
     cfg.CONF.set_override('core_plugin', NVP_PLUGIN_PATH)
     # Load the configuration, and initialize the plugin
     QuantumManager().get_plugin()
     self.assertIn('extensions', cfg.CONF.api_extensions_path)
Exemple #28
0
 def get_resources(cls):
     """Returns Ext Resources."""
     controller = resource.Resource(
         QuotaSetsController(QuantumManager.get_plugin()),
         faults=base.FAULT_MAP)
     return [extensions.ResourceExtension(
         Quotasv2.get_alias(),
         controller,
         collection_actions={'tenant': 'GET'})]
 def test_ports_vif_details(self):
     cfg.CONF.set_default('allow_overlapping_ips', True)
     plugin = QuantumManager.get_plugin()
     with contextlib.nested(self.port(), self.port()) as (port1, port2):
         ctx = context.get_admin_context()
         ports = plugin.get_ports(ctx)
         self.assertEqual(len(ports), 2)
         for port in ports:
             self.assertEqual(port['binding:vif_type'],
                              portbindings.VIF_TYPE_HYPERV)
Exemple #30
0
 def get_resources(cls):
     controller = UdpChannelsController(QuantumManager.get_plugin())
     parent_resource = dict(member_name="network",
         collection_name="extensions/udp/tenants/" +\
                         ":(tenant_id)/networks")
     return [
         extensions.ResourceExtension('channels',
                                      controller,
                                      parent=parent_resource)
     ]
Exemple #31
0
 def test_core_plugin_supports_services(self):
     cfg.CONF.set_override("core_plugin",
                           "quantum.tests.unit.test_quantum_manager."
                           "MultiServiceCorePlugin")
     mgr = QuantumManager.get_instance()
     svc_plugins = mgr.get_service_plugins()
     self.assertEqual(3, len(svc_plugins))
     self.assertIn(constants.CORE, svc_plugins.keys())
     self.assertIn(constants.LOADBALANCER, svc_plugins.keys())
     self.assertIn(constants.DUMMY, svc_plugins.keys())
 def test_ports_vif_details(self):
     cfg.CONF.set_default('allow_overlapping_ips', True)
     plugin = QuantumManager.get_plugin()
     with contextlib.nested(self.port(), self.port()) as (port1, port2):
         ctx = context.get_admin_context()
         ports = plugin.get_ports(ctx)
         self.assertEqual(len(ports), 2)
         for port in ports:
             self.assertEqual(port['binding:vif_type'],
                              portbindings.VIF_TYPE_HYPERV)
 def get_resources(cls):
     """ Returns all defined resources """
     parent_resource = dict(member_name="tenant",
                            collection_name="extensions/csco/tenants")
     member_actions = {'associate_portprofile': "PUT",
                       'disassociate_portprofile': "PUT"}
     controller = PortprofilesController(QuantumManager.get_plugin())
     return [extensions.ResourceExtension('portprofiles', controller,
                                          parent=parent_resource,
                                          member_actions=member_actions)]
Exemple #34
0
 def get_resources(cls):
     """ Returns Ext Resource """
     parent_resource = dict(member_name="tenant",
                            collection_name="extensions/csco/tenants")
     member_actions = {'schedule_host': "PUT",
                       'associate_port': "PUT"}
     controller = NovatenantsController(QuantumManager.get_plugin())
     return [extensions.ResourceExtension('novatenants', controller,
                                          parent=parent_resource,
                                          member_actions=member_actions)]
Exemple #35
0
 def get_instance(cls):
     if cls._instance is None:
         plugin_provider = cfg.CONF.core_plugin
         if plugin_provider in ENABLED_EXTS:
             for model in ENABLED_EXTS[plugin_provider]['ext_db_models']:
                 LOG.debug('loading model %s', model)
                 model_class = importutils.import_class(model)
         cls._instance = cls(get_extensions_path(),
                             QuantumManager.get_plugin())
     return cls._instance
Exemple #36
0
 def get_resources(cls):
     """Returns Ext Resources."""
     controller = resource.Resource(QuotaSetsController(
         QuantumManager.get_plugin()),
                                    faults=base.FAULT_MAP)
     return [
         extensions.ResourceExtension(Quotasv2.get_alias(),
                                      controller,
                                      collection_actions={'tenant': 'GET'})
     ]
 def test_port_vif_details(self):
     plugin = QuantumManager.get_plugin()
     with self.port(name="name") as port:
         port_id = port["port"]["id"]
         self.assertEqual(port["port"]["binding:vif_type"], portbindings.VIF_TYPE_HYPERV)
         # By default user is admin - now test non admin user
         ctx = context.Context(user_id=None, tenant_id=self._tenant_id, is_admin=False, read_deleted="no")
         non_admin_port = plugin.get_port(ctx, port_id)
         self.assertTrue("status" in non_admin_port)
         self.assertFalse("binding:vif_type" in non_admin_port)
Exemple #38
0
 def get_resources(cls):
     """ Returns Ext Resource """
     parent_resource = dict(member_name="tenant",
                            collection_name="extensions/csco/tenants")
     member_actions = {'schedule_host': "PUT",
                       'associate_port': "PUT",
                       'detach_port': "PUT"}
     controller = EnginetenantsController(QuantumManager.get_plugin())
     return [extensions.ResourceExtension('enginetenants', controller,
                                          parent=parent_resource,
                                          member_actions=member_actions)]
Exemple #39
0
 def get_resources(self):
     resource = base.create_resource('packet_filters', 'packet_filter',
                                     QuantumManager.get_plugin(),
                                     PACKET_FILTER_ATTR_MAP)
     qresource = quota.CountableResource('packet_filter',
                                         quota._count_resource,
                                         'quota_packet_filter')
     quota.QUOTAS.register_resource(qresource)
     return [extensions.ResourceExtension('packet_filters',
                                          resource,
                                          attr_map=PACKET_FILTER_ATTR_MAP)]
Exemple #40
0
 def test_load_plugin_with_deprecated_options(self):
     q_config.parse([
         '--config-file', BASE_CONF_PATH, '--config-file', NVP_INI_DEPR_PATH
     ])
     cfg.CONF.set_override('core_plugin', NVP_PLUGIN_PATH)
     plugin = QuantumManager().get_plugin()
     cluster = plugin.cluster
     self._assert_required_options(cluster)
     # Verify nvp_controller_connection has been fully parsed
     self.assertEqual(4, cluster.req_timeout)
     self.assertEqual(3, cluster.http_timeout)
     self.assertEqual(2, cluster.retries)
     self.assertEqual(1, cluster.redirects)
Exemple #41
0
 def get_instance(cls):
     if cls._instance is None:
         """
         plugin_provider = cfg.CONF.core_plugin
         if plugin_provider in ENABLED_EXTS:
             for model in ENABLED_EXTS[plugin_provider]['ext_db_models']:
                 LOG.debug('loading model %s', model)
                 model_class = importutils.import_class(model)
         """
         # (Trinath) Update for only Service Plugins 
         cls._instance = cls(get_extensions_path(),
                             QuantumManager.get_service_plugins())
     return cls._instance
Exemple #42
0
 def get_resources(cls):
     controller = PortsMetadataController(QuantumManager.get_plugin())
     parent_resource = {
         "member_name":
         "network",
         "collection_name":
         "extensions/attributes/tenants/:(tenant_id)/networks"
     }
     return [
         extensions.ResourceExtension('ports',
                                      controller,
                                      parent=parent_resource)
     ]
    def setUp(self):
        """ Set up function """

        parent_resource = dict(member_name="tenant", collection_name="extensions/csco/tenants")
        controller = qos.QosController(QuantumManager.get_plugin())
        res_ext = extensions.ResourceExtension("qos", controller, parent=parent_resource)

        self.test_app = setup_extensions_test_app(SimpleExtensionManager(res_ext))
        self.contenttype = "application/json"
        self.qos_path = "/extensions/csco/tenants/tt/qos"
        self.qos_second_path = "/extensions/csco/tenants/tt/qos/"
        self.test_qos_data = {"qos": {"qos_name": "cisco_test_qos", "qos_desc": {"PPS": 50, "TTL": 5}}}
        self._l2network_plugin = l2network_plugin.L2Network()
    def setUp(self):
        """ Set up function """

        parent_resource = dict(member_name="tenant", collection_name="extensions/csco/tenants")
        controller = credential.CredentialController(QuantumManager.get_plugin())
        res_ext = extensions.ResourceExtension("credentials", controller, parent=parent_resource)
        self.test_app = setup_extensions_test_app(SimpleExtensionManager(res_ext))
        self.contenttype = "application/json"
        self.credential_path = "/extensions/csco/tenants/tt/credentials"
        self.cred_second_path = "/extensions/csco/tenants/tt/credentials/"
        self.test_credential_data = {
            "credential": {"credential_name": "cred8", "user_name": "newUser2", "password": "******"}
        }
        self._l2network_plugin = l2network_plugin.L2Network()
 def test_port_vif_details(self):
     plugin = QuantumManager.get_plugin()
     with self.port(name='name') as port:
         port_id = port['port']['id']
         self.assertEqual(port['port']['binding:vif_type'],
                          portbindings.VIF_TYPE_BRIDGE)
         # By default user is admin - now test non admin user
         ctx = context.Context(user_id=None,
                               tenant_id=self._tenant_id,
                               is_admin=False,
                               read_deleted="no")
         non_admin_port = plugin.get_port(ctx, port_id)
         self.assertTrue('status' in non_admin_port)
         self.assertFalse('binding:vif_type' in non_admin_port)
    def test_service_plugin_is_loaded(self):
        cfg.CONF.set_override("core_plugin",
                              test_config.get('plugin_name_v2',
                                              DB_PLUGIN_KLASS))
        cfg.CONF.set_override("service_plugins",
                              ["quantum.tests.unit.dummy_plugin."
                               "DummyServicePlugin"])
        mgr = QuantumManager.get_instance()
        plugin = mgr.get_service_plugins()[constants.DUMMY]

        self.assertTrue(
            isinstance(plugin,
                       (dummy_plugin.DummyServicePlugin, types.ClassType)),
            "loaded plugin should be of type QuantumDummyPlugin")
Exemple #47
0
    def test_service_plugin_is_loaded(self):
        cfg.CONF.set_override("core_plugin",
                              test_config.get('plugin_name_v2',
                                              DB_PLUGIN_KLASS))
        cfg.CONF.set_override("service_plugins",
                              ["quantum.tests.unit.dummy_plugin."
                               "DummyServicePlugin"])
        mgr = QuantumManager.get_instance()
        plugin = mgr.get_service_plugins()[constants.DUMMY]

        self.assertTrue(
            isinstance(plugin,
                       (dummy_plugin.DummyServicePlugin, types.ClassType)),
            "loaded plugin should be of type QuantumDummyPlugin")
    def setUp(self, plugin=None):
        super(SecurityGroupsTestCase, self).setUp()
        db._ENGINE = None
        db._MAKER = None
        # Make sure at each test a new instance of the plugin is returned
        QuantumManager._instance = None
        # Make sure at each test according extensions for the plugin is loaded
        PluginAwareExtensionManager._instance = None
        # Save the attributes map in case the plugin will alter it
        # loading extensions
        # Note(salvatore-orlando): shallow copy is not good enough in
        # this case, but copy.deepcopy does not seem to work, since it
        # causes test failures
        self._attribute_map_bk = {}
        for item in attributes.RESOURCE_ATTRIBUTE_MAP:
            self._attribute_map_bk[item] = (attributes.
                                            RESOURCE_ATTRIBUTE_MAP[item].
                                            copy())
        json_deserializer = JSONDeserializer()
        self._deserializers = {
            'application/json': json_deserializer,
        }

        if not plugin:
            plugin = test_config.get('plugin_name_v2', DB_PLUGIN_KLASS)

        # Create the default configurations
        args = ['--config-file', etcdir('quantum.conf.test')]
        # If test_config specifies some config-file, use it, as well
        for config_file in test_config.get('config_files', []):
            args.extend(['--config-file', config_file])
        config.parse(args=args)
        # Update the plugin
        cfg.CONF.set_override('core_plugin', plugin)
        self.api = APIRouter()

        def _is_native_bulk_supported():
            plugin_obj = QuantumManager.get_plugin()
            native_bulk_attr_name = ("_%s__native_bulk_support"
                                     % plugin_obj.__class__.__name__)
            return getattr(plugin_obj, native_bulk_attr_name, False)

        self._skip_native_bulk = not _is_native_bulk_supported()

        QuantumManager.get_plugin().supported_extension_aliases = (
            ["security-groups"])
        ext_mgr = SecurityGroupTestExtensionManager()
        if ext_mgr:
            self.ext_api = test_extensions.setup_extensions_middleware(ext_mgr)
    def setUp(self, plugin=None):
        super(SecurityGroupsTestCase, self).setUp()
        db._ENGINE = None
        db._MAKER = None
        # Make sure at each test a new instance of the plugin is returned
        QuantumManager._instance = None
        # Make sure at each test according extensions for the plugin is loaded
        PluginAwareExtensionManager._instance = None
        # Save the attributes map in case the plugin will alter it
        # loading extensions
        # Note(salvatore-orlando): shallow copy is not good enough in
        # this case, but copy.deepcopy does not seem to work, since it
        # causes test failures
        self._attribute_map_bk = {}
        for item in attributes.RESOURCE_ATTRIBUTE_MAP:
            self._attribute_map_bk[item] = (
                attributes.RESOURCE_ATTRIBUTE_MAP[item].copy())
        json_deserializer = JSONDeserializer()
        self._deserializers = {
            'application/json': json_deserializer,
        }

        if not plugin:
            plugin = test_config.get('plugin_name_v2', DB_PLUGIN_KLASS)

        # Create the default configurations
        args = ['--config-file', etcdir('quantum.conf.test')]
        # If test_config specifies some config-file, use it, as well
        for config_file in test_config.get('config_files', []):
            args.extend(['--config-file', config_file])
        config.parse(args=args)
        # Update the plugin
        cfg.CONF.set_override('core_plugin', plugin)
        self.api = APIRouter()

        def _is_native_bulk_supported():
            plugin_obj = QuantumManager.get_plugin()
            native_bulk_attr_name = ("_%s__native_bulk_support" %
                                     plugin_obj.__class__.__name__)
            return getattr(plugin_obj, native_bulk_attr_name, False)

        self._skip_native_bulk = not _is_native_bulk_supported()

        QuantumManager.get_plugin().supported_extension_aliases = ([
            "security-groups"
        ])
        ext_mgr = SecurityGroupTestExtensionManager()
        if ext_mgr:
            self.ext_api = test_extensions.setup_extensions_middleware(ext_mgr)
Exemple #50
0
 def get_resources(cls):
     """ Returns all defined resources """
     parent_resource = dict(member_name="tenant",
                            collection_name="extensions/csco/tenants")
     member_actions = {
         'associate_portprofile': "PUT",
         'disassociate_portprofile': "PUT"
     }
     controller = PortprofilesController(QuantumManager.get_plugin())
     return [
         extensions.ResourceExtension('portprofiles',
                                      controller,
                                      parent=parent_resource,
                                      member_actions=member_actions)
     ]
 def test_ports_vif_details(self):
     cfg.CONF.set_default("allow_overlapping_ips", True)
     plugin = QuantumManager.get_plugin()
     with contextlib.nested(self.port(), self.port()) as (port1, port2):
         ctx = context.get_admin_context()
         ports = plugin.get_ports(ctx)
         self.assertEqual(len(ports), 2)
         for port in ports:
             self.assertEqual(port["binding:vif_type"], portbindings.VIF_TYPE_HYPERV)
         # By default user is admin - now test non admin user
         ctx = context.Context(user_id=None, tenant_id=self._tenant_id, is_admin=False, read_deleted="no")
         ports = plugin.get_ports(ctx)
         self.assertEqual(len(ports), 2)
         for non_admin_port in ports:
             self.assertTrue("status" in non_admin_port)
             self.assertFalse("binding:vif_type" in non_admin_port)
Exemple #52
0
 def test_port_vif_details(self):
     plugin = QuantumManager.get_plugin()
     with self.port(name='name') as port:
         port_id = port['port']['id']
         # Check a response of create_port
         self._check_response_portbindings(port['port'])
         # Check a response of get_port
         ctx = context.get_admin_context()
         port = plugin.get_port(ctx, port_id)
         self._check_response_portbindings(port)
         # By default user is admin - now test non admin user
         ctx = context.Context(user_id=None,
                               tenant_id=self._tenant_id,
                               is_admin=False,
                               read_deleted="no")
         non_admin_port = plugin.get_port(ctx, port_id)
         self._check_response_no_portbindings(non_admin_port)
 def test_port_vif_details(self):
     plugin = QuantumManager.get_plugin()
     with self.port(name='name') as port:
         port_id = port['port']['id']
         # Check a response of create_port
         self._check_response_portbindings(port['port'])
         # Check a response of get_port
         ctx = context.get_admin_context()
         port = plugin.get_port(ctx, port_id)
         self._check_response_portbindings(port)
         # By default user is admin - now test non admin user
         ctx = context.Context(user_id=None,
                               tenant_id=self._tenant_id,
                               is_admin=False,
                               read_deleted="no")
         non_admin_port = plugin.get_port(ctx, port_id)
         self._check_response_no_portbindings(non_admin_port)
 def test_ports_vif_details(self):
     plugin = QuantumManager.get_plugin()
     cfg.CONF.set_default('allow_overlapping_ips', True)
     with contextlib.nested(self.port(), self.port()):
         ctx = context.get_admin_context()
         ports = plugin.get_ports(ctx)
         self.assertEqual(len(ports), 2)
         for port in ports:
             self._check_response_portbindings(port)
         # By default user is admin - now test non admin user
         ctx = context.Context(user_id=None,
                               tenant_id=self._tenant_id,
                               is_admin=False,
                               read_deleted="no")
         ports = self._list('ports', quantum_context=ctx)['ports']
         self.assertEqual(len(ports), 2)
         for non_admin_port in ports:
             self._check_response_no_portbindings(non_admin_port)
 def test_ports_vif_details(self):
     cfg.CONF.set_default('allow_overlapping_ips', True)
     plugin = QuantumManager.get_plugin()
     with contextlib.nested(self.port(), self.port()) as (port1, port2):
         ctx = context.get_admin_context()
         ports = plugin.get_ports(ctx)
         self.assertEqual(len(ports), 2)
         for port in ports:
             self.assertEqual(port['binding:vif_type'],
                              portbindings.VIF_TYPE_BRIDGE)
         # By default user is admin - now test non admin user
         ctx = context.Context(user_id=None,
                               tenant_id=self._tenant_id,
                               is_admin=False,
                               read_deleted="no")
         ports = plugin.get_ports(ctx)
         self.assertEqual(len(ports), 2)
         for non_admin_port in ports:
             self.assertTrue('status' in non_admin_port)
             self.assertFalse('binding:vif_type' in non_admin_port)