Merge "Split the action logic from the run method"
This commit is contained in:
commit
26bd0efd26
@ -118,6 +118,9 @@ class ConfigureBootAction(base.TripleOAction):
|
|||||||
def run(self, context):
|
def run(self, context):
|
||||||
baremetal_client = self.get_baremetal_client(context)
|
baremetal_client = self.get_baremetal_client(context)
|
||||||
image_client = self.get_image_client(context)
|
image_client = self.get_image_client(context)
|
||||||
|
return self.configure_boot(baremetal_client, image_client)
|
||||||
|
|
||||||
|
def configure_boot(self, baremetal_client, image_client):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
image_ids = {'kernel': None, 'ramdisk': None}
|
image_ids = {'kernel': None, 'ramdisk': None}
|
||||||
@ -192,16 +195,22 @@ class ConfigureRootDeviceAction(base.TripleOAction):
|
|||||||
return
|
return
|
||||||
|
|
||||||
baremetal_client = self.get_baremetal_client(context)
|
baremetal_client = self.get_baremetal_client(context)
|
||||||
|
inspector_client = self.get_baremetal_introspection_client(context)
|
||||||
|
|
||||||
|
return self.configure_root_device(baremetal_client, inspector_client)
|
||||||
|
|
||||||
|
def configure_root_device(self, baremetal_client, inspector_client):
|
||||||
node = baremetal_client.node.get(self.node_uuid)
|
node = baremetal_client.node.get(self.node_uuid)
|
||||||
self._apply_root_device_strategy(
|
self._apply_root_device_strategy(
|
||||||
node,
|
node,
|
||||||
self.root_device,
|
self.root_device,
|
||||||
self.minimum_size,
|
self.minimum_size,
|
||||||
self.overwrite,
|
self.overwrite,
|
||||||
context=context)
|
baremetal_client, inspector_client)
|
||||||
|
|
||||||
def _apply_root_device_strategy(self, node, strategy, minimum_size,
|
def _apply_root_device_strategy(self, node, strategy, minimum_size,
|
||||||
overwrite=False, context=None):
|
overwrite=False, baremetal_client=None,
|
||||||
|
inspector_client=None):
|
||||||
if node.properties.get('root_device') and not overwrite:
|
if node.properties.get('root_device') and not overwrite:
|
||||||
# This is a correct situation, we still want to allow people to
|
# This is a correct situation, we still want to allow people to
|
||||||
# fine-tune the root device setting for a subset of nodes.
|
# fine-tune the root device setting for a subset of nodes.
|
||||||
@ -215,7 +224,6 @@ class ConfigureRootDeviceAction(base.TripleOAction):
|
|||||||
node.uuid)
|
node.uuid)
|
||||||
return
|
return
|
||||||
|
|
||||||
inspector_client = self.get_baremetal_introspection_client(context)
|
|
||||||
try:
|
try:
|
||||||
data = inspector_client.get_data(node.uuid)
|
data = inspector_client.get_data(node.uuid)
|
||||||
except ironic_inspector_client.ClientError:
|
except ironic_inspector_client.ClientError:
|
||||||
@ -281,8 +289,7 @@ class ConfigureRootDeviceAction(base.TripleOAction):
|
|||||||
# This -1 is what we always do to account for partitioning
|
# This -1 is what we always do to account for partitioning
|
||||||
new_size -= 1
|
new_size -= 1
|
||||||
|
|
||||||
bm_client = self.get_baremetal_client(context)
|
baremetal_client.node.update(
|
||||||
bm_client.node.update(
|
|
||||||
node.uuid,
|
node.uuid,
|
||||||
[{'op': 'add', 'path': '/properties/root_device', 'value': hint},
|
[{'op': 'add', 'path': '/properties/root_device', 'value': hint},
|
||||||
{'op': 'add', 'path': '/properties/local_gb', 'value': new_size}])
|
{'op': 'add', 'path': '/properties/local_gb', 'value': new_size}])
|
||||||
|
Loading…
Reference in New Issue
Block a user