Set resource_class=baremetal for newly enrolled nodes

We are switching to scheduling based on resource classes, so we need to set
the correct resource class on all nodes from them to be picked.

Change-Id: I027ee4ccf5db51729f036aceab047f2b65d0b368
Partial-Bug: #1708653
This commit is contained in:
Dmitry Tantsur 2017-08-15 18:26:45 +02:00
parent aa27c0bcf6
commit 43162a0726
3 changed files with 28 additions and 1 deletions

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Set the ``resource_class`` field of newly created nodes to ``baremetal``
to adapt to the recent scheduling changes. See `bug 1708653
<https://bugs.launchpad.net/tripleo/+bug/1708653>`_ for details.

View File

@ -249,6 +249,7 @@ class NodesTest(base.TestCase):
pxe_node = mock.call(driver="ipmi",
name='node1',
driver_info=pxe_node_driver_info,
resource_class='baremetal',
properties=node_properties)
port_call = mock.call(node_uuid=ironic.node.create.return_value.uuid,
address='aaa')
@ -270,6 +271,7 @@ class NodesTest(base.TestCase):
pxe_node = mock.call(driver="ipmi",
name='node1',
driver_info=pxe_node_driver_info,
resource_class='baremetal',
properties=node_properties)
port_call = mock.call(node_uuid=ironic.node.create.return_value.uuid,
address='aaa')
@ -299,6 +301,7 @@ class NodesTest(base.TestCase):
pxe_node = mock.call(driver="ipmi",
name='node1',
driver_info=pxe_node_driver_info,
resource_class='baremetal',
properties=node_properties)
port_call = mock.call(node_uuid=ironic.node.create.return_value.uuid,
address='aaa')
@ -322,6 +325,7 @@ class NodesTest(base.TestCase):
name='node1',
driver_info=pxe_node_driver_info,
properties=node_properties,
resource_class='baremetal',
uuid="abcdef")
port_call = mock.call(node_uuid=ironic.node.create.return_value.uuid,
address='aaa')
@ -346,6 +350,7 @@ class NodesTest(base.TestCase):
pxe_node = mock.call(driver="ipmi",
name='node1',
driver_info=pxe_node_driver_info,
resource_class='baremetal',
properties=node_properties)
port_call = mock.call(node_uuid=ironic.node.create.return_value.uuid,
address='aaa')
@ -380,6 +385,7 @@ class NodesTest(base.TestCase):
name='node1',
driver_info=pxe_node_driver_info,
properties=node_properties,
resource_class='baremetal',
**interfaces)
port_call = mock.call(node_uuid=ironic.node.create.return_value.uuid,
address='aaa')
@ -592,6 +598,7 @@ class NodesTest(base.TestCase):
client.node.create.assert_called_once_with(driver=mock.ANY,
name='node1',
properties=node_properties,
resource_class='baremetal',
driver_info=mock.ANY)
def test_register_ironic_node_fake_pxe(self):
@ -609,6 +616,7 @@ class NodesTest(base.TestCase):
client.node.create.assert_called_once_with(driver='fake_pxe',
name='node1',
properties=node_properties,
resource_class='baremetal',
driver_info={})
def test_register_ironic_node_pxe_ucs(self):
@ -623,6 +631,7 @@ class NodesTest(base.TestCase):
nodes.register_ironic_node(node, client=client)
client.node.create.assert_called_once_with(
driver='pxe_ucs', name='node1', properties=node_properties,
resource_class='baremetal',
driver_info={'ucs_password': 'random', 'ucs_address': 'foo.bar',
'ucs_username': 'test'})
@ -639,6 +648,7 @@ class NodesTest(base.TestCase):
nodes.register_ironic_node(node, client=client)
client.node.create.assert_called_once_with(
driver='ipmi', name='node1', properties=node_properties,
resource_class='baremetal',
driver_info={'ipmi_password': 'random', 'ipmi_address': 'foo.bar',
'ipmi_username': 'test', 'ipmi_port': '6230'})
@ -655,6 +665,7 @@ class NodesTest(base.TestCase):
nodes.register_ironic_node(node, client=client)
client.node.create.assert_called_once_with(
driver='pxe_ipmitool', name='node1', properties=node_properties,
resource_class='baremetal',
driver_info={'ipmi_password': 'random', 'ipmi_address': 'foo.bar',
'ipmi_username': 'test', 'ipmi_port': '6230'})
@ -671,6 +682,7 @@ class NodesTest(base.TestCase):
nodes.register_ironic_node(node, client=client)
client.node.create.assert_called_once_with(
driver='pxe_drac', name='node1', properties=node_properties,
resource_class='baremetal',
driver_info={'drac_password': 'random', 'drac_address': 'foo.bar',
'drac_username': 'test', 'drac_port': '6230'})
@ -687,6 +699,7 @@ class NodesTest(base.TestCase):
nodes.register_ironic_node(node, client=client)
client.node.create.assert_called_once_with(
driver='redfish', name='node1', properties=node_properties,
resource_class='baremetal',
driver_info={'redfish_password': 'random',
'redfish_address': 'foo.bar',
'redfish_username': 'test',

View File

@ -299,6 +299,12 @@ def register_ironic_node(node, client):
interface_fields = {field: node.pop(field)
for field in _KNOWN_INTERFACE_FIELDS
if field in node}
resource_class = node.pop('resource_class', 'baremetal')
if resource_class != 'baremetal':
LOG.warning('Resource class for a new node will be set to %s, which '
'is different from the default "baremetal". A custom '
'flavor will be required to deploy on such node',
resource_class)
driver_info.update(handler.convert(node))
@ -318,7 +324,8 @@ def register_ironic_node(node, client):
create_map = {"driver": node["pm_type"],
"properties": properties,
"driver_info": driver_info}
"driver_info": driver_info,
"resource_class": resource_class}
create_map.update(interface_fields)
for field in ('name', 'uuid'):
@ -390,6 +397,7 @@ _NON_DRIVER_FIELDS = {'cpu': '/properties/cpus',
'disk': '/properties/local_gb',
'arch': '/properties/cpu_arch',
'name': '/name',
'resource_class': '/resource_class',
'kernel_id': '/driver_info/deploy_kernel',
'ramdisk_id': '/driver_info/deploy_ramdisk',
'capabilities': '/properties/capabilities'}