Ensure root_gb always in patch params to avoid ValidationError

Accoring [1], the root_gb is required when validating the
node properties. While, in latest mogan codes [2], root_gb
is optional. Then, the ValidationError would occured when
creating baremetal server with mogan.

To fix this problem, ensure root_gb always in patch params.

[1]: https://github.com/openstack/nova/blob/master/nova/virt/ironic/patcher.py#L61
[2]: https://github.com/openstack/mogan/blob/master/mogan/baremetal/ironic/driver.py#L159-L161

Change-Id: I99f7a0408c234649fc81482f82018c74781f7a26
Closes-Bug: #1729533
This commit is contained in:
zhangjl 2017-11-02 17:35:17 +08:00
parent cb02f1c19b
commit c8f6ca2c8a
1 changed files with 10 additions and 2 deletions

View File

@ -153,12 +153,13 @@ class IronicDriver(base_driver.BaseEngineDriver):
# Add the required fields to deploy a node.
patch.append({'path': '/instance_info/image_source', 'op': 'add',
'value': server.image_uuid})
root_gb = node.properties.get('local_gb', 0)
if preserve_ephemeral is not None:
patch.append({'path': '/instance_info/preserve_ephemeral',
'op': 'add', 'value': str(preserve_ephemeral)})
if partitions:
patch.append({'path': '/instance_info/root_gb', 'op': 'add',
'value': str(partitions.get('root_gb', 0))})
patch.append({'path': '/instance_info/ephemeral_gb', 'op': 'add',
'value': str(partitions.get('ephemeral_gb', 0))})
patch.append({'path': '/instance_info/swap_mb', 'op': 'add',
@ -168,6 +169,13 @@ class IronicDriver(base_driver.BaseEngineDriver):
patch.append({'path': '/instance_info/capabilities',
'op': 'add', 'value': '{"boot_option": "local"}'})
# If partitions is not None, use the root_gb in partitions instead
root_gb = partitions.get('root_gb', root_gb)
# root_gb is required not optional
patch.append({'path': '/instance_info/root_gb', 'op': 'add',
'value': str(root_gb)})
try:
# FIXME(lucasagomes): The "retry_on_conflict" parameter was added
# to basically causes the deployment to fail faster in case the