Exemple #1
0
    def __init__(self):
        """Initialize the segmentation manager.

        Checks which device plugins are configured, and load the inventories
        those device plugins for which the inventory is configured.
        """
        conf.CiscoConfigOptions()

        self._plugins = {}
        self._plugins['vswitch_plugin'] = importutils.import_object(
            'neutron.plugins.cisco.n1kv.n1kv_neutron_plugin.'
            'N1kvNeutronPluginV2')

        if ((const.VSWITCH_PLUGIN in self._plugins) and
            hasattr(self._plugins[const.VSWITCH_PLUGIN],
                    "supported_extension_aliases")):
            self.supported_extension_aliases.extend(
                self._plugins[const.VSWITCH_PLUGIN].
                supported_extension_aliases)

        # Initialize credential store after database initialization
        cred.Store.initialize()
        LOG.debug("%(module)s.%(name)s init done",
                  {'module': __name__,
                   'name': self.__class__.__name__})
Exemple #2
0
    def __init__(self):
        """Initialize the segmentation manager.

        Checks which device plugins are configured, and load the inventories
        those device plugins for which the inventory is configured.
        """
        conf.CiscoConfigOptions()

        self._plugins = {}
        for key in conf.CISCO_PLUGINS.keys():
            plugin_obj = conf.CISCO_PLUGINS[key]
            if plugin_obj is not None:
                self._plugins[key] = importutils.import_object(plugin_obj)
                LOG.debug(_("Loaded device plugin %s"),
                          conf.CISCO_PLUGINS[key])

        if ((const.VSWITCH_PLUGIN in self._plugins)
                and hasattr(self._plugins[const.VSWITCH_PLUGIN],
                            "supported_extension_aliases")):
            self.supported_extension_aliases.extend(self._plugins[
                const.VSWITCH_PLUGIN].supported_extension_aliases)

        # Initialize credential store after database initialization
        cred.Store.initialize()
        LOG.debug(_("%(module)s.%(name)s init done"), {
            'module': __name__,
            'name': self.__class__.__name__
        })

        # Check whether we have a valid Nexus driver loaded
        self.is_nexus_plugin = False
        nexus_driver = conf.CISCO.nexus_driver
        if nexus_driver.endswith('CiscoNEXUSDriver'):
            self.is_nexus_plugin = True
    def __init__(self):
        """Initialize the segmentation manager.

        Checks which device plugins are configured, and load the inventories
        those device plugins for which the inventory is configured.
        """
        conf.CiscoConfigOptions()

        for key in conf.CISCO_PLUGINS.keys():
            plugin_obj = conf.CISCO_PLUGINS[key]
            if plugin_obj is not None:
                self._plugins[key] = importutils.import_object(plugin_obj)
                LOG.debug(_("Loaded device plugin %s\n"),
                          conf.CISCO_PLUGINS[key])

        if ((const.VSWITCH_PLUGIN in self._plugins) and
            hasattr(self._plugins[const.VSWITCH_PLUGIN],
                    "supported_extension_aliases")):
            self.supported_extension_aliases.extend(
                self._plugins[const.VSWITCH_PLUGIN].
                supported_extension_aliases)
        # At this point, all the database models should have been loaded. It's
        # possible that configure_db() may have been called by one of the
        # plugins loaded in above. Otherwise, this call is to make sure that
        # the database is initialized
        db_api.configure_db()

        # Initialize credential store after database initialization
        cred.Store.initialize()
        LOG.debug(_("%(module)s.%(name)s init done"),
                  {'module': __name__,
                   'name': self.__class__.__name__})

        # Check whether we have a valid Nexus driver loaded
        self.config_nexus = False
        nexus_driver = cfg.CONF.CISCO.nexus_driver
        if nexus_driver.endswith('CiscoNEXUSDriver'):
            self.config_nexus = True
 def test_create_device_dictionary(self):
     """Test creation of the device dictionary based on nexus config."""
     test_config = {
         'NEXUS_SWITCH:1.1.1.1': {
             'username': ['admin'],
             'password': ['mySecretPassword'],
             'ssh_port': [22],
             'compute1': ['1/1'],
             'compute2': ['1/2'],
         },
         'NEXUS_SWITCH:2.2.2.2': {
             'username': ['admin'],
             'password': ['mySecretPassword'],
             'ssh_port': [22],
             'compute3': ['1/1'],
             'compute4': ['1/2'],
         },
     }
     expected_dev_dict = {
         ('NEXUS_SWITCH', '1.1.1.1', 'username'): 'admin',
         ('NEXUS_SWITCH', '1.1.1.1', 'password'): 'mySecretPassword',
         ('NEXUS_SWITCH', '1.1.1.1', 'ssh_port'): 22,
         ('NEXUS_SWITCH', '1.1.1.1', 'compute1'): '1/1',
         ('NEXUS_SWITCH', '1.1.1.1', 'compute2'): '1/2',
         ('NEXUS_SWITCH', '2.2.2.2', 'username'): 'admin',
         ('NEXUS_SWITCH', '2.2.2.2', 'password'): 'mySecretPassword',
         ('NEXUS_SWITCH', '2.2.2.2', 'ssh_port'): 22,
         ('NEXUS_SWITCH', '2.2.2.2', 'compute3'): '1/1',
         ('NEXUS_SWITCH', '2.2.2.2', 'compute4'): '1/2',
     }
     with mock.patch.object(cfg, 'MultiConfigParser') as parser:
         parser.return_value.read.return_value = cfg.CONF.config_file
         parser.return_value.parsed = [test_config]
         cisco_config.CiscoConfigOptions()
         self.assertEqual(cisco_config.device_dictionary,
                          expected_dev_dict)