summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhangjl <zhangjl@awcloud.com>2017-11-02 17:35:17 +0800
committerzhangjl <zhangjl@awcloud.com>2017-11-02 17:35:17 +0800
commitc8f6ca2c8a8ebe930026be66651b66aa7c908ac3 (patch)
treef8898226df918b897345a91d2e78276fe62bc07f
parentcb02f1c19ba460d1c5c6b8851a21d9948bad3e0e (diff)
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
Notes
Notes (review): Code-Review+2: Zhenguo Niu <Niu.ZGlinux@gmail.com> Code-Review+1: Xinran WANG <xin-ran.wang@intel.com> Code-Review+2: ShaoHe Feng <shaohe.feng@intel.com> Workflow+1: ShaoHe Feng <shaohe.feng@intel.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Mon, 20 Nov 2017 09:29:00 +0000 Reviewed-on: https://review.openstack.org/517235 Project: openstack/mogan Branch: refs/heads/master
-rw-r--r--mogan/baremetal/ironic/driver.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/mogan/baremetal/ironic/driver.py b/mogan/baremetal/ironic/driver.py
index fd9a6ea..f0f916d 100644
--- a/mogan/baremetal/ironic/driver.py
+++ b/mogan/baremetal/ironic/driver.py
@@ -153,12 +153,13 @@ class IronicDriver(base_driver.BaseEngineDriver):
153 # Add the required fields to deploy a node. 153 # Add the required fields to deploy a node.
154 patch.append({'path': '/instance_info/image_source', 'op': 'add', 154 patch.append({'path': '/instance_info/image_source', 'op': 'add',
155 'value': server.image_uuid}) 155 'value': server.image_uuid})
156
157 root_gb = node.properties.get('local_gb', 0)
158
156 if preserve_ephemeral is not None: 159 if preserve_ephemeral is not None:
157 patch.append({'path': '/instance_info/preserve_ephemeral', 160 patch.append({'path': '/instance_info/preserve_ephemeral',
158 'op': 'add', 'value': str(preserve_ephemeral)}) 161 'op': 'add', 'value': str(preserve_ephemeral)})
159 if partitions: 162 if partitions:
160 patch.append({'path': '/instance_info/root_gb', 'op': 'add',
161 'value': str(partitions.get('root_gb', 0))})
162 patch.append({'path': '/instance_info/ephemeral_gb', 'op': 'add', 163 patch.append({'path': '/instance_info/ephemeral_gb', 'op': 'add',
163 'value': str(partitions.get('ephemeral_gb', 0))}) 164 'value': str(partitions.get('ephemeral_gb', 0))})
164 patch.append({'path': '/instance_info/swap_mb', 'op': 'add', 165 patch.append({'path': '/instance_info/swap_mb', 'op': 'add',
@@ -168,6 +169,13 @@ class IronicDriver(base_driver.BaseEngineDriver):
168 patch.append({'path': '/instance_info/capabilities', 169 patch.append({'path': '/instance_info/capabilities',
169 'op': 'add', 'value': '{"boot_option": "local"}'}) 170 'op': 'add', 'value': '{"boot_option": "local"}'})
170 171
172 # If partitions is not None, use the root_gb in partitions instead
173 root_gb = partitions.get('root_gb', root_gb)
174
175 # root_gb is required not optional
176 patch.append({'path': '/instance_info/root_gb', 'op': 'add',
177 'value': str(root_gb)})
178
171 try: 179 try:
172 # FIXME(lucasagomes): The "retry_on_conflict" parameter was added 180 # FIXME(lucasagomes): The "retry_on_conflict" parameter was added
173 # to basically causes the deployment to fail faster in case the 181 # to basically causes the deployment to fail faster in case the