예제 #1
0
 def test_numbered_nics_map_mac(self):
     def dummy_interface_mac(name):
         mac_map = {'em1': '12:34:56:78:9a:bc',
                    'em2': '12:34:56:de:f0:12'}
         return mac_map[name]
     self.stubs.Set(utils, 'interface_mac', dummy_interface_mac)
     self._stub_active_nics(['em1', 'em2'])
     mapping = {'nic1': '12:34:56:de:f0:12', 'nic2': '12:34:56:78:9a:bc'}
     expected = {'nic1': 'em2', 'nic2': 'em1'}
     self.assertEqual(expected, objects._numbered_nics(nic_mapping=mapping))
 def test_numbered_nics_map_mac(self):
     def dummy_interface_mac(name):
         mac_map = {'em1': '12:34:56:78:9a:bc',
                    'em2': '12:34:56:de:f0:12'}
         return mac_map[name]
     self.stubs.Set(utils, 'interface_mac', dummy_interface_mac)
     self._stub_active_nics(['em1', 'em2'])
     mapping = {'nic1': '12:34:56:de:f0:12', 'nic2': '12:34:56:78:9a:bc'}
     expected = {'nic1': 'em2', 'nic2': 'em1'}
     self.assertEqual(expected, objects._numbered_nics(nic_mapping=mapping))
 def test_numbered_nics_map_error_notactive(self):
     self._stub_active_nics(['em1', 'em2'])
     mapping = {'nic1': 'em3', 'nic2': 'em1'}
     expected = {'nic2': 'em1'}
     self.assertEqual(expected, objects._numbered_nics(nic_mapping=mapping))
 def test_numbered_nics_mapped_partial(self):
     self._stub_active_nics(['em1', 'em2', 'em3', 'em4'])
     mapping = {'nic1': 'em2', 'nic2': 'em1'}
     expected = {'nic1': 'em2', 'nic2': 'em1', 'nic3': 'em3', 'nic4': 'em4'}
     self.assertEqual(expected, objects._numbered_nics(nic_mapping=mapping))
 def test_numbered_nics_default(self):
     self._stub_active_nics(['em1', 'em2'])
     expected = {'nic1': 'em1', 'nic2': 'em2'}
     self.assertEqual(expected, objects._numbered_nics())
예제 #6
0
 def test_numbered_nics_no_active(self):
     self._stub_active_nics([])
     expected = {}
     # This only emits a warning, so it should still work
     self.assertEqual(expected, objects._numbered_nics())
예제 #7
0
 def test_numbered_nics_map_error_notactive(self):
     self._stub_active_nics(['em1', 'em2'])
     mapping = {'nic1': 'em3', 'nic2': 'em1'}
     expected = {'nic2': 'em1'}
     self.assertEqual(expected, objects._numbered_nics(nic_mapping=mapping))
예제 #8
0
 def test_numbered_nics_mapped_partial(self):
     self._stub_active_nics(['em1', 'em2', 'em3', 'em4'])
     mapping = {'nic1': 'em2', 'nic2': 'em1'}
     expected = {'nic1': 'em2', 'nic2': 'em1', 'nic3': 'em3', 'nic4': 'em4'}
     self.assertEqual(expected, objects._numbered_nics(nic_mapping=mapping))
예제 #9
0
 def test_numbered_nics_default(self):
     self._stub_active_nics(['em1', 'em2'])
     expected = {'nic1': 'em1', 'nic2': 'em2'}
     self.assertEqual(expected, objects._numbered_nics())