Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions osism/commands/baremetal.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ def take_action(self, parsed_args):
return 1
deploy_nodes = [node]

failed = False
for node in deploy_nodes:
if not node:
continue
Expand Down Expand Up @@ -238,6 +239,7 @@ def take_action(self, parsed_args):
logger.warning(
f"Node {node.name} ({node.id}) could not be validated"
)
failed = True
continue
# NOTE: Prepare osism config drive
try:
Expand Down Expand Up @@ -352,6 +354,7 @@ def take_action(self, parsed_args):
logger.warning(
f"Failed to build config drive for {node.name} ({node.id}): {exc}"
)
failed = True
continue
node_vendor = node.properties.get("vendor", "").strip().lower()
if node_vendor == "supermicro":
Expand Down Expand Up @@ -399,7 +402,11 @@ def take_action(self, parsed_args):
logger.warning(
f"Node {node.name} ({node.id}) could not be moved to active state: {exc}"
)
failed = True
continue

if failed:
return 1
finally:
cleanup_cloud_environment(temp_files, original_cwd)

Expand Down Expand Up @@ -563,6 +570,7 @@ def take_action(self, parsed_args):
)
except Exception as exc:
logger.error(f"Failed to generate playbook for {name}: {exc}")
return 1
finally:
cleanup_cloud_environment(temp_files, original_cwd)
else:
Expand Down Expand Up @@ -676,6 +684,7 @@ def take_action(self, parsed_args):
)
except Exception as exc:
logger.error(f"Failed to generate playbook for {name}: {exc}")
return 1


class BaremetalUndeploy(Command):
Expand Down Expand Up @@ -748,6 +757,7 @@ def take_action(self, parsed_args):
return 1
deploy_nodes = [node]

failed = False
for node in deploy_nodes:
if not node:
continue
Expand Down Expand Up @@ -784,11 +794,15 @@ def take_action(self, parsed_args):
logger.warning(
f"Node {node.name} ({node.id}) could not be moved to available state: {exc}"
)
failed = True
continue
else:
logger.warning(
f"Node {node.name} ({node.id}) not in supported provision state"
)

if failed:
return 1
finally:
cleanup_cloud_environment(temp_files, original_cwd)

Expand Down Expand Up @@ -1059,6 +1073,7 @@ def take_action(self, parsed_args):
return 1
burn_in_nodes = [node]

failed = False
for node in burn_in_nodes:
if not node:
continue
Expand All @@ -1076,6 +1091,7 @@ def take_action(self, parsed_args):
logger.warning(
f"Node {node.name} ({node.id}) could not be moved to manageable state: {exc}"
)
failed = True
continue

if node.provision_state in ["manageable"]:
Expand Down Expand Up @@ -1110,6 +1126,7 @@ def take_action(self, parsed_args):
logger.warning(
f"Burn-In of node {node.name} ({node.id}) failed: {exc}"
)
failed = True
continue
elif node.provision_state in ["active"]:
# NOTE: Use service step to run burn-in
Expand All @@ -1135,13 +1152,17 @@ def take_action(self, parsed_args):
logger.warning(
f"Burn-In of node {node.name} ({node.id}) failed: {exc}"
)
failed = True
continue

else:
logger.warning(
f"Node {node.name} ({node.id}) not in supported state! Provision state: {node.provision_state}, maintenance mode: {node['maintenance']}"
)
continue

if failed:
return 1
finally:
cleanup_cloud_environment(temp_files, original_cwd)

Expand Down Expand Up @@ -1216,6 +1237,7 @@ def take_action(self, parsed_args):
return 1
clean_nodes = [node]

failed = False
for node in clean_nodes:
if not node:
continue
Expand All @@ -1239,6 +1261,7 @@ def take_action(self, parsed_args):
logger.warning(
f"Node {node.name} ({node.id}) could not be moved to manageable state: {exc}"
)
failed = True
continue

if node.provision_state in ["manageable"]:
Expand Down Expand Up @@ -1276,11 +1299,15 @@ def take_action(self, parsed_args):
logger.warning(
f"Clean of node {node.name} ({node.id}) failed: {exc}"
)
failed = True
continue
else:
logger.warning(
f"Node {node.name} ({node.id}) not in supported state! Provision state: {node.provision_state}, maintenance mode: {node['maintenance']}"
)

if failed:
return 1
finally:
cleanup_cloud_environment(temp_files, original_cwd)

Expand Down Expand Up @@ -1340,6 +1367,7 @@ def take_action(self, parsed_args):
return 1
provide_nodes = [node]

failed = False
for node in provide_nodes:
if not node:
continue
Expand All @@ -1354,11 +1382,15 @@ def take_action(self, parsed_args):
logger.warning(
f"Node {node.name} ({node.id}) could not be moved to available state: {exc}"
)
failed = True
continue
else:
logger.warning(
f"Node {node.name} ({node.id}) not in supported state! Provision state: {node.provision_state}, maintenance mode: {node['maintenance']}"
)

if failed:
return 1
finally:
cleanup_cloud_environment(temp_files, original_cwd)

Expand Down Expand Up @@ -1414,6 +1446,7 @@ def take_action(self, parsed_args):
logger.error(
f"Setting maintenance mode on node {node.name} ({node.id}) failed: {exc}"
)
return 1
finally:
cleanup_cloud_environment(temp_files, original_cwd)

Expand Down Expand Up @@ -1462,6 +1495,7 @@ def take_action(self, parsed_args):
logger.error(
f"Unsetting maintenance mode on node {node.name} ({node.id}) failed: {exc}"
)
return 1
finally:
cleanup_cloud_environment(temp_files, original_cwd)

Expand Down Expand Up @@ -1514,6 +1548,7 @@ def take_action(self, parsed_args):
logger.info(f"Successfully powered on node {node.name} ({node.id})")
except Exception as exc:
logger.error(f"Failed to power on node {node.name} ({node.id}): {exc}")
return 1
finally:
cleanup_cloud_environment(temp_files, original_cwd)

Expand Down Expand Up @@ -1576,6 +1611,7 @@ def take_action(self, parsed_args):
logger.info(f"Successfully {action} node {node.name} ({node.id})")
except Exception as exc:
logger.error(f"Failed to power off node {node.name} ({node.id}): {exc}")
return 1
finally:
cleanup_cloud_environment(temp_files, original_cwd)

Expand Down Expand Up @@ -1650,6 +1686,7 @@ def take_action(self, parsed_args):
return 1
delete_nodes = [node]

failed = False
for node in delete_nodes:
if not node:
continue
Expand Down Expand Up @@ -1726,6 +1763,10 @@ def take_action(self, parsed_args):
logger.error(
f"Failed to delete node {node.name} ({node.id}): {exc}"
)
failed = True
continue

if failed:
return 1
finally:
cleanup_cloud_environment(temp_files, original_cwd)
5 changes: 4 additions & 1 deletion osism/commands/redfish.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,12 @@ def take_action(self, parsed_args):
# Get column mappings for the resource type
column_mappings = self._get_column_mappings(resourcetype)
if column_mappings:
_, data_keys = self._get_filtered_columns(
headers, data_keys = self._get_filtered_columns(
column_mappings, columns
)
if not headers:
print("No valid columns specified")
return
filtered_result = self._filter_json_data(result, data_keys)
print(json.dumps(filtered_result, indent=2))
else:
Expand Down
Loading