def test_loading_csr_configuration(self):
     """Ensure that Cisco CSR configs can be loaded from config files."""
     cfg_file = create_tempfile(
         "[CISCO_CSR_REST:3.2.1.1]\n"
         "rest_mgmt = 10.20.30.1\n"
         "tunnel_ip = 3.2.1.3\n"
         "username = me\n"
         "password = secret\n"
         "host = compute-node\n"
         "tunnel_if = GigabitEthernet3\n"
         "timeout = 5.0\n"
     )
     expected = {
         "3.2.1.1": {
             "rest_mgmt_ip": "10.20.30.1",
             "tunnel_ip": "3.2.1.3",
             "username": "******",
             "password": "******",
             "host": "compute-node",
             "tunnel_if": "GigabitEthernet3",
             "timeout": 5.0,
         }
     }
     csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
     self.assertEqual(expected, csrs_found)
 def test_ignores_invalid_attribute_in_config(self):
     """Test ignoring of config file with invalid attribute."""
     cfg_file = create_tempfile(
         "[CISCO_CSR_REST:3.2.1.1]\n"
         "rest_mgmt = 1.1.1.1\n"
         "bogus = abcdef\n"
         "tunnel_ip = 3.2.1.3\n"
         "username = me\n"
         "password = secret\n"
         "host = compute-node\n"
         "tunnel_if = GigabitEthernet3\n"
         "timeout = 15.5\n"
     )
     expected = {
         "3.2.1.1": {
             "rest_mgmt_ip": "1.1.1.1",
             "tunnel_ip": "3.2.1.3",
             "username": "******",
             "password": "******",
             "host": "compute-node",
             "tunnel_if": "GigabitEthernet3",
             "timeout": 15.5,
         }
     }
     csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
     self.assertEqual(expected, csrs_found)
 def test_skip_loading_duplicate_csr_configuration(self):
     """Failure test that duplicate configurations are ignored."""
     cfg_file = create_tempfile('[CISCO_CSR_REST:3.2.1.1]\n'
                                'rest_mgmt = 10.20.30.1\n'
                                'tunnel_ip = 3.2.1.3\n'
                                'username = me\n'
                                'password = secret\n'
                                'host = compute-node\n'
                                'tunnel_if = GigabitEthernet3\n'
                                'timeout = 5.0\n'
                                '[CISCO_CSR_REST:3.2.1.1]\n'
                                'rest_mgmt = 5.5.5.3\n'
                                'tunnel_ip = 3.2.1.6\n'
                                'username = me\n'
                                'password = secret\n'
                                'host = compute-node\n'
                                'tunnel_if = GigabitEthernet3\n')
     expected = {
         '3.2.1.1': {
             'rest_mgmt_ip': '10.20.30.1',
             'tunnel_ip': '3.2.1.3',
             'username': '******',
             'password': '******',
             'host': 'compute-node',
             'tunnel_if': 'GigabitEthernet3',
             'timeout': 5.0
         }
     }
     csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
     self.assertEqual(expected, csrs_found)
 def test_skip_loading_duplicate_csr_configuration(self):
     """Failure test that duplicate configurations are ignored."""
     cfg_file = create_tempfile(
         '[CISCO_CSR_REST:3.2.1.1]\n'
         'rest_mgmt = 10.20.30.1\n'
         'tunnel_ip = 3.2.1.3\n'
         'username = me\n'
         'password = secret\n'
         'host = compute-node\n'
         'tunnel_if = GigabitEthernet3\n'
         'timeout = 5.0\n'
         '[CISCO_CSR_REST:3.2.1.1]\n'
         'rest_mgmt = 5.5.5.3\n'
         'tunnel_ip = 3.2.1.6\n'
         'username = me\n'
         'password = secret\n'
         'host = compute-node\n'
         'tunnel_if = GigabitEthernet3\n')
     expected = {'3.2.1.1': {'rest_mgmt_ip': '10.20.30.1',
                             'tunnel_ip': '3.2.1.3',
                             'username': '******',
                             'password': '******',
                             'host': 'compute-node',
                             'tunnel_if': 'GigabitEthernet3',
                             'timeout': 5.0}}
     csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
     self.assertEqual(expected, csrs_found)
    def test_fail_loading_config_missing_required_info(self):
        """Failure test of config missing required info."""
        cfg_file = create_tempfile(
            '[CISCO_CSR_REST:1.1.1.0]\n'
            # No rest_mgmt
            'tunnel_ip = 1.1.1.3\n'
            'username = me\n'
            'password = secret\n'
            'host = compute-node\n'
            'tunnel_if = GigabitEthernet3\n'
            'timeout = 5.0\n'

            '[CISCO_CSR_REST:2.2.2.0]\n'
            'rest_mgmt = 10.20.30.2\n'
            # No tunnel_ip
            'username = me\n'
            'password = secret\n'
            'host = compute-node\n'
            'tunnel_if = GigabitEthernet3\n'
            'timeout = 5.0\n'

            '[CISCO_CSR_REST:3.3.3.0]\n'
            'rest_mgmt = 10.20.30.3\n'
            'tunnel_ip = 3.3.3.3\n'
            # No username
            'password = secret\n'
            'host = compute-node\n'
            'tunnel_if = GigabitEthernet3\n'
            'timeout = 5.0\n'

            '[CISCO_CSR_REST:4.4.4.0]\n'
            'rest_mgmt = 10.20.30.4\n'
            'tunnel_ip = 4.4.4.4\n'
            'username = me\n'
            # No password
            'host = compute-node\n'
            'tunnel_if = GigabitEthernet3\n'
            'timeout = 5.0\n'

            '[CISCO_CSR_REST:5.5.5.0]\n'
            'rest_mgmt = 10.20.30.5\n'
            'tunnel_ip = 5.5.5.5'
            'username = me\n'
            'password = secret\n'
            # No host
            'tunnel_if = GigabitEthernet3\n'
            'timeout = 5.0\n'

            '[CISCO_CSR_REST:6.6.6.0]\n'
            'rest_mgmt = 10.20.30.6\n'
            'tunnel_ip = 6.6.6.6'
            'username = me\n'
            'password = secret\n'
            'host = compute-node\n'
            # No tunnel_if
            'timeout = 5.0\n')
        csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
        self.assertEqual({}, csrs_found)
Beispiel #6
0
    def test_fail_loading_config_missing_required_info(self):
        """Failure test of config missing required info."""
        cfg_file = create_tempfile(
            '[CISCO_CSR_REST:1.1.1.0]\n'
            # No rest_mgmt
            'tunnel_ip = 1.1.1.3\n'
            'username = me\n'
            'password = secret\n'
            'host = compute-node\n'
            'tunnel_if = GigabitEthernet3\n'
            'timeout = 5.0\n'

            '[CISCO_CSR_REST:2.2.2.0]\n'
            'rest_mgmt = 10.20.30.2\n'
            # No tunnel_ip
            'username = me\n'
            'password = secret\n'
            'host = compute-node\n'
            'tunnel_if = GigabitEthernet3\n'
            'timeout = 5.0\n'

            '[CISCO_CSR_REST:3.3.3.0]\n'
            'rest_mgmt = 10.20.30.3\n'
            'tunnel_ip = 3.3.3.3\n'
            # No username
            'password = secret\n'
            'host = compute-node\n'
            'tunnel_if = GigabitEthernet3\n'
            'timeout = 5.0\n'

            '[CISCO_CSR_REST:4.4.4.0]\n'
            'rest_mgmt = 10.20.30.4\n'
            'tunnel_ip = 4.4.4.4\n'
            'username = me\n'
            # No password
            'host = compute-node\n'
            'tunnel_if = GigabitEthernet3\n'
            'timeout = 5.0\n'

            '[CISCO_CSR_REST:5.5.5.0]\n'
            'rest_mgmt = 10.20.30.5\n'
            'tunnel_ip = 5.5.5.5'
            'username = me\n'
            'password = secret\n'
            # No host
            'tunnel_if = GigabitEthernet3\n'
            'timeout = 5.0\n'

            '[CISCO_CSR_REST:6.6.6.0]\n'
            'rest_mgmt = 10.20.30.6\n'
            'tunnel_ip = 6.6.6.6'
            'username = me\n'
            'password = secret\n'
            'host = compute-node\n'
            # No tunnel_if
            'timeout = 5.0\n')
        csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
        self.assertEqual({}, csrs_found)
 def test_invalid_management_interface(self):
     """Failure test of invalid management interface name."""
     cfg_file = create_tempfile('[CISCO_CSR_REST:3.2.1.1]\n'
                                'rest_mgmt = 1.1.1.1\n'
                                'tunnel_ip = 3.2.1.3\n'
                                'username = me\n'
                                'password = secret\n'
                                'host = compute-node\n'
                                'tunnel_if = GigabitEthernet9\n'
                                'timeout = 5.0\n')
     csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
     self.assertEqual({}, csrs_found)
 def test_fail_loading_config_with_invalid_timeout(self):
     """Failure test of invalid timeout in config info."""
     cfg_file = create_tempfile('[CISCO_CSR_REST:3.2.1.1]\n'
                                'rest_mgmt = 10.20.30.1\n'
                                'tunnel_ip = 3.2.1.3\n'
                                'username = me\n'
                                'password = secret\n'
                                'host = compute-node\n'
                                'tunnel_if = GigabitEthernet3\n'
                                'timeout = yes\n')
     csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
     self.assertEqual({}, csrs_found)
 def test_fail_loading_config_with_invalid_router_id(self):
     """Failure test of config with invalid rotuer ID."""
     cfg_file = create_tempfile('[CISCO_CSR_REST:4.3.2.1.9]\n'
                                'rest_mgmt = 10.20.30.1\n'
                                'tunnel_ip = 4.3.2.3\n'
                                'username = me\n'
                                'password = secret\n'
                                'host = compute-node\n'
                                'tunnel_if = GigabitEthernet3\n'
                                'timeout = 5.0\n')
     csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
     self.assertEqual({}, csrs_found)
 def test_fail_loading_config_with_invalid_tunnel_ip(self):
     """Failure test of configuration with invalid tunnel IP address."""
     cfg_file = create_tempfile('[CISCO_CSR_REST:3.2.1.1]\n'
                                'rest_mgmt = 1.1.1.1\n'
                                'tunnel_ip = 3.2.1.4.5\n'
                                'username = me\n'
                                'password = secret\n'
                                'host = compute-node\n'
                                'tunnel_if = GigabitEthernet3\n'
                                'timeout = 5.0\n')
     csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
     self.assertEqual({}, csrs_found)
 def test_missing_config_value(self):
     """Failure test of config file missing a value for attribute."""
     cfg_file = create_tempfile('[CISCO_CSR_REST:3.2.1.1]\n'
                                'rest_mgmt = \n'
                                'tunnel_ip = 3.2.1.3\n'
                                'username = me\n'
                                'password = secret\n'
                                'host = compute-node\n'
                                'tunnel_if = GigabitEthernet3\n'
                                'timeout = 5.0\n')
     csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
     self.assertEqual({}, csrs_found)
 def test_invalid_management_interface(self):
     """Failure test of invalid management interface name."""
     cfg_file = create_tempfile(
         '[CISCO_CSR_REST:3.2.1.1]\n'
         'rest_mgmt = 1.1.1.1\n'
         'tunnel_ip = 3.2.1.3\n'
         'username = me\n'
         'password = secret\n'
         'host = compute-node\n'
         'tunnel_if = GigabitEthernet9\n'
         'timeout = 5.0\n')
     csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
     self.assertEqual({}, csrs_found)
 def test_missing_config_value(self):
     """Failure test of config file missing a value for attribute."""
     cfg_file = create_tempfile(
         '[CISCO_CSR_REST:3.2.1.1]\n'
         'rest_mgmt = \n'
         'tunnel_ip = 3.2.1.3\n'
         'username = me\n'
         'password = secret\n'
         'host = compute-node\n'
         'tunnel_if = GigabitEthernet3\n'
         'timeout = 5.0\n')
     csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
     self.assertEqual({}, csrs_found)
 def test_fail_loading_config_with_invalid_tunnel_ip(self):
     """Failure test of configuration with invalid tunnel IP address."""
     cfg_file = create_tempfile(
         '[CISCO_CSR_REST:3.2.1.1]\n'
         'rest_mgmt = 1.1.1.1\n'
         'tunnel_ip = 3.2.1.4.5\n'
         'username = me\n'
         'password = secret\n'
         'host = compute-node\n'
         'tunnel_if = GigabitEthernet3\n'
         'timeout = 5.0\n')
     csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
     self.assertEqual({}, csrs_found)
 def test_fail_loading_config_with_invalid_router_id(self):
     """Failure test of config with invalid rotuer ID."""
     cfg_file = create_tempfile(
         '[CISCO_CSR_REST:4.3.2.1.9]\n'
         'rest_mgmt = 10.20.30.1\n'
         'tunnel_ip = 4.3.2.3\n'
         'username = me\n'
         'password = secret\n'
         'host = compute-node\n'
         'tunnel_if = GigabitEthernet3\n'
         'timeout = 5.0\n')
     csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
     self.assertEqual({}, csrs_found)
 def test_fail_loading_config_with_invalid_timeout(self):
     """Failure test of invalid timeout in config info."""
     cfg_file = create_tempfile(
         '[CISCO_CSR_REST:3.2.1.1]\n'
         'rest_mgmt = 10.20.30.1\n'
         'tunnel_ip = 3.2.1.3\n'
         'username = me\n'
         'password = secret\n'
         'host = compute-node\n'
         'tunnel_if = GigabitEthernet3\n'
         'timeout = yes\n')
     csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
     self.assertEqual({}, csrs_found)
Beispiel #17
0
 def test_loading_config_without_timeout(self):
     """Cisco CSR config without timeout will use default timeout."""
     cfg_file = create_tempfile(
         '[CISCO_CSR_REST:3.2.1.1]\n'
         'rest_mgmt = 10.20.30.1\n'
         'tunnel_ip = 3.2.1.3\n'
         'username = me\n'
         'password = secret\n'
         'host = compute-node\n'
         'tunnel_if = GigabitEthernet3\n')
     expected = {'3.2.1.1': {'rest_mgmt_ip': '10.20.30.1',
                             'tunnel_ip': '3.2.1.3',
                             'username': '******',
                             'password': '******',
                             'host': 'compute-node',
                             'tunnel_if': 'GigabitEthernet3',
                             'timeout': csr_client.TIMEOUT}}
     csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
     self.assertEqual(expected, csrs_found)
 def test_loading_config_without_timeout(self):
     """Cisco CSR config without timeout will use default timeout."""
     cfg_file = create_tempfile(
         '[CISCO_CSR_REST:3.2.1.1]\n'
         'rest_mgmt = 10.20.30.1\n'
         'tunnel_ip = 3.2.1.3\n'
         'username = me\n'
         'password = secret\n'
         'host = compute-node\n'
         'tunnel_if = GigabitEthernet3\n')
     expected = {'3.2.1.1': {'rest_mgmt_ip': '10.20.30.1',
                             'tunnel_ip': '3.2.1.3',
                             'username': '******',
                             'password': '******',
                             'host': 'compute-node',
                             'tunnel_if': 'GigabitEthernet3',
                             'timeout': csr_client.TIMEOUT}}
     csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
     self.assertEqual(expected, csrs_found)
Beispiel #19
0
 def test_ignores_invalid_attribute_in_config(self):
     """Test ignoring of config file with invalid attribute."""
     cfg_file = create_tempfile(
         '[CISCO_CSR_REST:3.2.1.1]\n'
         'rest_mgmt = 1.1.1.1\n'
         'bogus = abcdef\n'
         'tunnel_ip = 3.2.1.3\n'
         'username = me\n'
         'password = secret\n'
         'host = compute-node\n'
         'tunnel_if = GigabitEthernet3\n'
         'timeout = 15.5\n')
     expected = {'3.2.1.1': {'rest_mgmt_ip': '1.1.1.1',
                             'tunnel_ip': '3.2.1.3',
                             'username': '******',
                             'password': '******',
                             'host': 'compute-node',
                             'tunnel_if': 'GigabitEthernet3',
                             'timeout': 15.5}}
     csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
     self.assertEqual(expected, csrs_found)
 def test_ignores_invalid_attribute_in_config(self):
     """Test ignoring of config file with invalid attribute."""
     cfg_file = create_tempfile(
         '[CISCO_CSR_REST:3.2.1.1]\n'
         'rest_mgmt = 1.1.1.1\n'
         'bogus = abcdef\n'
         'tunnel_ip = 3.2.1.3\n'
         'username = me\n'
         'password = secret\n'
         'host = compute-node\n'
         'tunnel_if = GigabitEthernet3\n'
         'timeout = 15.5\n')
     expected = {'3.2.1.1': {'rest_mgmt_ip': '1.1.1.1',
                             'tunnel_ip': '3.2.1.3',
                             'username': '******',
                             'password': '******',
                             'host': 'compute-node',
                             'tunnel_if': 'GigabitEthernet3',
                             'timeout': 15.5}}
     csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
     self.assertEqual(expected, csrs_found)
 def test_loading_config_without_timeout(self):
     """Cisco CSR config without timeout will use default timeout."""
     cfg_file = create_tempfile(
         "[CISCO_CSR_REST:3.2.1.1]\n"
         "rest_mgmt = 10.20.30.1\n"
         "tunnel_ip = 3.2.1.3\n"
         "username = me\n"
         "password = secret\n"
         "host = compute-node\n"
         "tunnel_if = GigabitEthernet3\n"
     )
     expected = {
         "3.2.1.1": {
             "rest_mgmt_ip": "10.20.30.1",
             "tunnel_ip": "3.2.1.3",
             "username": "******",
             "password": "******",
             "host": "compute-node",
             "tunnel_if": "GigabitEthernet3",
             "timeout": csr_client.TIMEOUT,
         }
     }
     csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
     self.assertEqual(expected, csrs_found)
 def test_failure_no_csr_configurations_entries(self):
     """Failure test config file without any CSR definitions."""
     cfg_file = create_tempfile('[SOME_CONFIG:123]\n'
                                'username = me\n')
     csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
     self.assertEqual({}, csrs_found)
 def test_failure_no_configurations_entries(self):
     """Failure test config file without any CSR definitions."""
     cfg_file = create_tempfile('NO CISCO SECTION AT ALL\n')
     csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
     self.assertEqual({}, csrs_found)
 def test_failure_no_csr_configurations_entries(self):
     """Failure test config file without any CSR definitions."""
     cfg_file = create_tempfile('[SOME_CONFIG:123]\n' 'username = me\n')
     csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
     self.assertEqual({}, csrs_found)
 def test_failure_no_configurations_entries(self):
     """Failure test config file without any CSR definitions."""
     cfg_file = create_tempfile('NO CISCO SECTION AT ALL\n')
     csrs_found = cfg_loader.get_available_csrs_from_config([cfg_file])
     self.assertEqual({}, csrs_found)