def test_register_ironic_node_update_int_values(self): node = self._get_node() ironic = mock.MagicMock() node['cpu'] = 1 node['memory'] = 2048 node['disk'] = 30 node_map = {'mac': {'aaa': 1}} def side_effect(*args, **kwargs): update_patch = [ {'path': '/name', 'value': 'node1'}, {'path': '/driver_info/ipmi_password', 'value': 'random'}, {'path': '/driver_info/ipmi_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': '/properties/capabilities', 'value': 'num_nics:6'}, {'path': '/driver_info/ipmi_username', 'value': 'test'}] for key in update_patch: key['op'] = 'add' self.assertThat(update_patch, matchers.MatchesSetwise(*(map(matchers.Equals, args[1])))) return mock.Mock(uuid='uuid1') ironic.node.update.side_effect = side_effect nodes._update_or_register_ironic_node(node, node_map, client=ironic)
def test_register_update(self): interfaces = { 'boot_interface': 'pxe', 'console_interface': 'ipmitool-socat', 'deploy_interface': 'direct', 'inspect_interface': 'inspector', 'management_interface': 'ipmitool', 'network_interface': 'neutron', 'power_interface': 'ipmitool', 'raid_interface': 'agent', 'storage_interface': 'cinder', 'vendor_interface': 'ipmitool' } node = self._get_node() node.update(interfaces) ironic = mock.MagicMock() node_map = {'mac': {'aaa': 1}} def side_effect(*args, **kwargs): update_patch = [{ 'path': '/name', 'value': 'node1' }, { 'path': '/driver_info/ipmi_password', 'value': 'random' }, { 'path': '/driver_info/ipmi_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': '/properties/capabilities', 'value': 'num_nics:6' }, { 'path': '/driver_info/ipmi_username', 'value': 'test' }] for iface, value in interfaces.items(): update_patch.append({'path': '/%s' % iface, 'value': value}) for key in update_patch: key['op'] = 'add' self.assertThat( update_patch, matchers.MatchesSetwise(*(map(matchers.Equals, args[1])))) return mock.Mock(uuid='uuid1') ironic.node.update.side_effect = side_effect nodes._update_or_register_ironic_node(node, node_map, client=ironic) ironic.node.update.assert_called_once_with(1, mock.ANY)
def test_register_ironic_node_update_int_values(self): node = self._get_node() ironic = mock.MagicMock() node['cpu'] = 1 node['memory'] = 2048 node['disk'] = 30 node_map = {'mac': {'aaa': 1}} def side_effect(*args, **kwargs): update_patch = [ {'path': '/name', 'value': 'node1'}, {'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': '/properties/capabilities', 'value': 'num_nics:6'}, {'path': '/driver_info/ssh_username', 'value': 'test'}, {'path': '/driver_info/ssh_virt_type', 'value': 'virsh'}] for key in update_patch: key['op'] = 'add' self.assertThat(update_patch, matchers.MatchesSetwise(*(map(matchers.Equals, args[1])))) return mock.Mock(uuid='uuid1') ironic.node.update.side_effect = side_effect nodes._update_or_register_ironic_node(node, node_map, client=ironic)
def test_register_node_update_with_uuid(self): node = self._get_node() node['uuid'] = 'abcdef' ironic = mock.MagicMock() node_map = {'uuids': {'abcdef'}} def side_effect(*args, **kwargs): update_patch = [ {'path': '/name', 'value': 'node1'}, {'path': '/driver_info/ipmi_password', 'value': 'random'}, {'path': '/driver_info/ipmi_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': '/properties/capabilities', 'value': 'num_nics:6'}, {'path': '/driver_info/ipmi_username', 'value': 'test'}] for key in update_patch: key['op'] = 'add' self.assertThat(update_patch, matchers.MatchesSetwise(*(map(matchers.Equals, args[1])))) return mock.Mock(uuid='abcdef') ironic.node.update.side_effect = side_effect nodes._update_or_register_ironic_node(node, node_map, client=ironic) ironic.node.update.assert_called_once_with('abcdef', mock.ANY)
def test_register_node_update_with_uuid(self): node = self._get_node() node['uuid'] = 'abcdef' ironic = mock.MagicMock() node_map = {'uuids': {'abcdef'}} def side_effect(*args, **kwargs): update_patch = [ {'path': '/name', 'value': 'node1'}, {'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': '/properties/capabilities', 'value': 'num_nics:6'}, {'path': '/driver_info/ssh_username', 'value': 'test'}, {'path': '/driver_info/ssh_virt_type', 'value': 'virsh'}] for key in update_patch: key['op'] = 'add' self.assertThat(update_patch, matchers.MatchesSetwise(*(map(matchers.Equals, args[1])))) return mock.Mock(uuid='abcdef') 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('abcdef', mock.ANY)
def _update_by_type(self, pm_type): ironic = mock.MagicMock() node_map = {'mac': {}, 'pm_addr': {}} node = self._get_node() node['pm_type'] = pm_type node_map['pm_addr']['foo.bar'] = ironic.node.get.return_value.uuid nodes._update_or_register_ironic_node(node, node_map, client=ironic) ironic.node.update.assert_called_once_with( ironic.node.get.return_value.uuid, mock.ANY)
def test_update_node_ironic_redfish(self): ironic = mock.MagicMock() node_map = {'mac': {}, 'pm_addr': {}} node = self._get_node() node.update({'pm_type': 'redfish', 'pm_system_id': '/path'}) node_map['pm_addr']['foo.bar/path'] = ironic.node.get.return_value.uuid nodes._update_or_register_ironic_node(node, node_map, client=ironic) ironic.node.update.assert_called_once_with( ironic.node.get.return_value.uuid, mock.ANY)
def _update_by_type(self, pm_type): ironic = mock.MagicMock() node_map = {'mac': {}, 'pm_addr': {}} node = self._get_node() node['pm_type'] = pm_type node_map['pm_addr']['foo.bar'] = ironic.node.get.return_value.uuid nodes._update_or_register_ironic_node(node, node_map, client=ironic) ironic.node.update.assert_called_once_with( ironic.node.get.return_value.uuid, mock.ANY)
def test_update_node_ironic_redfish(self): ironic = mock.MagicMock() node_map = {'mac': {}, 'pm_addr': {}} node = self._get_node() node.update({'pm_type': 'redfish', 'pm_system_id': '/path'}) node_map['pm_addr']['foo.bar/path'] = ironic.node.get.return_value.uuid nodes._update_or_register_ironic_node(node, node_map, client=ironic) ironic.node.update.assert_called_once_with( ironic.node.get.return_value.uuid, mock.ANY)
def test_update_node_ironic_ovirt(self): ironic = mock.MagicMock() node_map = {'mac': {}, 'pm_addr': {}} node = self._get_node() node.update({'pm_type': 'staging-ovirt', 'pm_vm_name': 'VM1'}) node_map['pm_addr']['foo.bar:VM1'] = ironic.node.get.return_value.uuid nodes._update_or_register_ironic_node(node, node_map, client=ironic) ironic.node.update.assert_called_once_with( ironic.node.get.return_value.uuid, mock.ANY)