Merge "Deal with uppercase MAC address in register-nodes"

This commit is contained in:
Jenkins
2014-11-26 20:10:08 +00:00
committed by Gerrit Code Review
2 changed files with 28 additions and 2 deletions

View File

@@ -156,8 +156,8 @@ def _populate_node_mapping(ironic_in_use, client):
def _get_node_id(node, node_map):
if node['pm_type'] == 'pxe_ssh':
for mac in node['mac']:
if mac in node_map['mac']:
return node_map['mac'][mac]
if mac.lower() in node_map['mac']:
return node_map['mac'][mac.lower()]
else:
if node['pm_addr'] in node_map['pm_addr']:
return node_map['pm_addr'][node['pm_addr']]

View File

@@ -253,6 +253,32 @@ class NodesTest(base.TestCase):
ironic.node.update.assert_called_once_with(
ironic.node.get.return_value.uuid, mock.ANY)
def test_register_ironic_node_update_uppercase_mac(self):
node = self._get_node()
node['mac'][0] = node['mac'][0].upper()
ironic = mock.MagicMock()
node_map = {'mac': {'aaa': 1}}
def side_effect(*args, **kwargs):
update_patch = [
{'path': '/driver_info/ssh_key_contents', 'value': 'random'},
{'path': '/driver_info/ssh_address', 'value': 'foo.bar'},
{'path': '/properties/memory_mb', 'value': '2048'},
{'path': '/properties/local_gb', 'value': '30'},
{'path': '/properties/cpu_arch', 'value': 'amd64'},
{'path': '/properties/cpus', 'value': '1'},
{'path': '/driver_info/ssh_username', 'value': 'test'}]
for key in update_patch:
key['op'] = 'replace'
self.assertThat(update_patch,
matchers.MatchesSetwise(*(map(matchers.Equals,
args[1]))))
ironic.node.update.side_effect = side_effect
nodes._update_or_register_ironic_node(None, node, node_map,
client=ironic)
ironic.node.update.assert_called_once_with(
ironic.node.get.return_value.uuid, mock.ANY)
@mock.patch('time.sleep')
def test_register_ironic_node_update_locked_node(self, sleep):
node = self._get_node()