From c8f6ca2c8a8ebe930026be66651b66aa7c908ac3 Mon Sep 17 00:00:00 2001 From: zhangjl Date: Thu, 2 Nov 2017 17:35:17 +0800 Subject: [PATCH] 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 --- mogan/baremetal/ironic/driver.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mogan/baremetal/ironic/driver.py b/mogan/baremetal/ironic/driver.py index fd9a6ea7..f0f916d0 100644 --- a/mogan/baremetal/ironic/driver.py +++ b/mogan/baremetal/ironic/driver.py @@ -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