コード例 #1
0
 def __init__(self):
     conf.ML2MechCiscoConfig()
     credentials = self._build_credentials(
         conf.ML2MechCiscoConfig.nexus_dict)
     self.client = self._import_client(credentials)
     super(CiscoNexusRestapiDriver, self).__init__()
     LOG.debug("ML2 Nexus RESTAPI Drivers initialized.")
コード例 #2
0
    def test_create_device_dictionary(self):
        """Test creation of the device dictionary based on nexus config."""
        test_config = {
            'ml2_mech_cisco_nexus:1.1.1.1': {
                'username': ['admin'],
                'password': ['mySecretPassword'],
                'ssh_port': [22],
                'compute1': ['1/1'],
                'compute2': ['1/2'],
                'compute5': ['1/3,1/4']
            },
            'ml2_mech_cisco_nexus:2.2.2.2': {
                'username': ['admin'],
                'password': ['mySecretPassword'],
                'ssh_port': [22],
                'compute3': ['1/1'],
                'compute4': ['1/2'],
                'compute5': ['portchannel:20,portchannel:30']
            },
        }
        expected_dev_dict = {
            ('1.1.1.1', 'username'): 'admin',
            ('1.1.1.1', 'password'): 'mySecretPassword',
            ('1.1.1.1', 'ssh_port'): 22,
            ('2.2.2.2', 'username'): 'admin',
            ('2.2.2.2', 'password'): 'mySecretPassword',
            ('2.2.2.2', 'ssh_port'): 22,
        }
        host_map_data = [
            ('compute1', '1.1.1.1', '1/1'),
            ('compute2', '1.1.1.1', '1/2'),
            ('compute3', '2.2.2.2', '1/1'),
            ('compute4', '2.2.2.2', '1/2'),
            ('compute5', '1.1.1.1', '1/3'),
            ('compute5', '1.1.1.1', '1/4'),
            ('compute5', '2.2.2.2', 'portchannel:20'),
            ('compute5', '2.2.2.2', 'portchannel:30')
        ]

        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.ML2MechCiscoConfig()
            self.assertEqual(expected_dev_dict,
                             cisco_config.ML2MechCiscoConfig.nexus_dict)

        mappings = nexus_db_v2.get_all_host_mappings()
        idx = 0
        maps_sorted = []
        for map in mappings:
            maps_sorted.append([map.host_id, map.switch_ip,
                                map.if_id, map.ch_grp, map.is_static])
        maps_sorted.sort()
        for map in maps_sorted:
            self.assertEqual(map[0], host_map_data[idx][0])
            self.assertEqual(map[1], host_map_data[idx][1])
            self.assertEqual(map[2], host_map_data[idx][2])
            self.assertEqual(map[3], 0)
            self.assertTrue(map[4])
            idx += 1
コード例 #3
0
    def test_create_device_dictionary(self):
        """Test creation of the device dictionary based on nexus config."""
        expected_dev_dict = {
            ('1.1.1.1', 'username'): 'admin',
            ('1.1.1.1', 'password'): 'mySecretPassword',
            ('1.1.1.1', 'ssh_port'): 22,
            ('1.1.1.1', 'nve_src_intf'): '2',
            ('1.1.1.1', 'physnet'): 'physnet1',
            ('1.1.1.1', 'vpc_pool'): '5,10',
            ('1.1.1.1', 'intfcfg.portchannel'): 'user cmd1 ;user cmd2',
            ('2.2.2.2', 'username'): 'admin',
            ('2.2.2.2', 'password'): 'mySecretPassword',
            ('2.2.2.2', 'ssh_port'): 22,
        }
        host_map_data = [('compute1', '1.1.1.1', '1/1'),
                         ('compute2', '1.1.1.1', '1/2'),
                         ('compute3', '2.2.2.2', '1/1'),
                         ('compute4', '2.2.2.2', '1/2'),
                         ('compute5', '1.1.1.1', '1/3'),
                         ('compute5', '1.1.1.1', '1/4'),
                         ('compute5', '2.2.2.2', 'portchannel:20'),
                         ('compute5', '2.2.2.2', 'portchannel:30')]

        cisco_config.ML2MechCiscoConfig()
        self.assertEqual(expected_dev_dict,
                         cisco_config.ML2MechCiscoConfig.nexus_dict)

        mappings = nexus_db_v2.get_all_host_mappings()
        idx = 0
        maps_sorted = []
        for map in mappings:
            maps_sorted.append([
                map.host_id, map.switch_ip, map.if_id, map.ch_grp,
                map.is_static
            ])
        maps_sorted.sort()
        for map in maps_sorted:
            self.assertEqual(map[0], host_map_data[idx][0])
            self.assertEqual(map[1], host_map_data[idx][1])
            if_type, port = nexus_help.split_interface_name(
                host_map_data[idx][2])
            eth_name = nexus_help.format_interface_name(if_type, port)
            self.assertEqual(map[2], eth_name)
            self.assertEqual(map[3], 0)
            self.assertTrue(map[4])
            idx += 1
コード例 #4
0
    def initialize(self):
        # Create ML2 device dictionary from ml2_conf.ini entries.
        conf.ML2MechCiscoConfig()

        # Extract configuration parameters from the configuration file.
        self._nexus_switches = conf.ML2MechCiscoConfig.nexus_dict
        LOG.debug("nexus_switches found = %s", self._nexus_switches)
        # Save dynamic switch information
        self._switch_state = {}

        self.driver = nexus_network_driver.CiscoNexusDriver()

        self.monitor = CiscoNexusCfgMonitor(self.driver, self)
        self.timer = None
        self.monitor_timeout = conf.cfg.CONF.ml2_cisco.switch_heartbeat_time
        self.monitor_lock = threading.Lock()
        # Start the monitor thread
        if self.monitor_timeout > 0:
            self._monitor_thread()
コード例 #5
0
 def test_create_device_dictionary(self):
     """Test creation of the device dictionary based on nexus config."""
     test_config = {
         'ml2_mech_cisco_nexus:1.1.1.1': {
             'username': ['admin'],
             'password': ['mySecretPassword'],
             'ssh_port': [22],
             'compute1': ['1/1'],
             'compute2': ['1/2'],
             'compute5': ['1/3,1/4']
         },
         'ml2_mech_cisco_nexus:2.2.2.2': {
             'username': ['admin'],
             'password': ['mySecretPassword'],
             'ssh_port': [22],
             'compute3': ['1/1'],
             'compute4': ['1/2'],
             'compute5': ['portchannel:20,portchannel:30']
         },
     }
     expected_dev_dict = {
         ('1.1.1.1', 'username'): 'admin',
         ('1.1.1.1', 'password'): 'mySecretPassword',
         ('1.1.1.1', 'ssh_port'): 22,
         ('1.1.1.1', 'compute1'): '1/1',
         ('1.1.1.1', 'compute2'): '1/2',
         ('1.1.1.1', 'compute5'): '1/3,1/4',
         ('2.2.2.2', 'username'): 'admin',
         ('2.2.2.2', 'password'): 'mySecretPassword',
         ('2.2.2.2', 'ssh_port'): 22,
         ('2.2.2.2', 'compute3'): '1/1',
         ('2.2.2.2', 'compute4'): '1/2',
         ('2.2.2.2', 'compute5'): 'portchannel:20,portchannel:30',
     }
     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.ML2MechCiscoConfig()
         self.assertEqual(expected_dev_dict,
                          cisco_config.ML2MechCiscoConfig.nexus_dict)
コード例 #6
0
    def initialize(self):
        # Create ML2 device dictionary from ml2_conf.ini entries.
        conf.ML2MechCiscoConfig()

        # Extract configuration parameters from the configuration file.
        self._nexus_switches = conf.ML2MechCiscoConfig.nexus_dict
        LOG.debug("nexus_switches found = %s", self._nexus_switches)
        # Save dynamic switch information
        self._switch_state = {}

        self.driver = nexus_network_driver.CiscoNexusDriver()

        # This method is only called once regardless of number of
        # api/rpc workers defined.
        self._ppid = os.getpid()

        self.monitor = CiscoNexusCfgMonitor(self.driver, self)
        self.timer = None
        self.monitor_timeout = conf.cfg.CONF.ml2_cisco.switch_heartbeat_time
        self.monitor_lock = threading.Lock()
        # Start the monitor thread
        if self.monitor_timeout > 0:
            eventlet.spawn_after(DELAY_MONITOR_THREAD, self._monitor_thread)