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
58 changes: 29 additions & 29 deletions osism/commands/baremetal.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ def take_action(self, parsed_args):

if not all_nodes and not name:
logger.error("Please specify a node name or use --all")
return
return 1

if all_nodes and rebuild and not yes_i_really_really_mean_it:
logger.error(
"Please confirm that you wish to rebuild all nodes by specifying '--yes-i-really-really-mean-it'"
)
return
return 1

import openstack
from osism.tasks.openstack import get_cloud_helpers
Expand All @@ -192,7 +192,7 @@ def take_action(self, parsed_args):
node = conn.baremetal.find_node(name, ignore_missing=True, details=True)
if not node:
logger.warning(f"Could not find node {name}")
return
return 1
deploy_nodes = [node]

for node in deploy_nodes:
Expand Down Expand Up @@ -451,7 +451,7 @@ def take_action(self, parsed_args):

if not node:
logger.error(f"Could not find node {name} in Ironic")
return
return 1

# Get default vars from NetBox local_context_data if available
default_vars = {}
Expand Down Expand Up @@ -570,7 +570,7 @@ def take_action(self, parsed_args):
# Check if NetBox connection is available
if not utils.nb:
logger.error("NetBox connection not available")
return
return 1

try:
# Try to find device by name first
Expand All @@ -585,7 +585,7 @@ def take_action(self, parsed_args):
# If device not found, error out
if not device:
logger.error(f"Could not find device {name} in NetBox")
return
return 1

# Get default vars from NetBox local_context_data if available.
# Remove frr_parameters and netplan_parameters as they are
Expand Down Expand Up @@ -714,13 +714,13 @@ def take_action(self, parsed_args):

if not all_nodes and not name:
logger.error("Please specify a node name or use --all")
return
return 1

if all_nodes and not yes_i_really_really_mean_it:
logger.error(
"Please confirm that you wish to undeploy all nodes by specifying '--yes-i-really-really-mean-it'"
)
return
return 1

from osism.tasks.openstack import get_cloud_helpers

Expand All @@ -743,7 +743,7 @@ def take_action(self, parsed_args):
)
if not node:
logger.warning(f"Could not find node {name}")
return
return 1
deploy_nodes = [node]

for node in deploy_nodes:
Expand Down Expand Up @@ -865,14 +865,14 @@ def take_action(self, parsed_args):

if not utils.nb:
logger.error("NetBox connection not available")
return
return 1

try:
if name:
devices = [utils.nb.dcim.devices.get(name=name)]
if not devices[0]:
logger.error(f"Device {name} not found in NetBox")
return
return 1
else:
# Use the NETBOX_FILTER_CONDUCTOR_IRONIC setting to get devices
devices = set()
Expand Down Expand Up @@ -958,7 +958,7 @@ def take_action(self, parsed_args):

except Exception as e:
logger.error(f"Error during ping operation: {e}")
return
return 1


class BaremetalBurnIn(Command):
Expand Down Expand Up @@ -1023,7 +1023,7 @@ def take_action(self, parsed_args):

if not all_nodes and not name:
logger.error("Please specify a node name or use --all")
return
return 1

clean_steps = []
for step, activated in stressor.items():
Expand All @@ -1033,7 +1033,7 @@ def take_action(self, parsed_args):
logger.error(
f"Please specify at least one of {', '.join(stressor.keys())} for burn-in"
)
return
return 1

from osism.tasks.openstack import get_cloud_helpers

Expand All @@ -1054,7 +1054,7 @@ def take_action(self, parsed_args):
node = conn.baremetal.find_node(name, ignore_missing=True, details=True)
if not node:
logger.warning(f"Could not find node {name}")
return
return 1
burn_in_nodes = [node]

for node in burn_in_nodes:
Expand Down Expand Up @@ -1182,13 +1182,13 @@ def take_action(self, parsed_args):

if not all_nodes and not name:
logger.error("Please specify a node name or use --all")
return
return 1

if all_nodes and not yes_i_really_really_mean_it:
logger.error(
"Please confirm that you wish to clean all nodes by specifying '--yes-i-really-really-mean-it'"
)
return
return 1

clean_steps = [{"interface": "deploy", "step": "erase_devices"}]

Expand All @@ -1211,7 +1211,7 @@ def take_action(self, parsed_args):
node = conn.baremetal.find_node(name, ignore_missing=True, details=True)
if not node:
logger.warning(f"Could not find node {name}")
return
return 1
clean_nodes = [node]

for node in clean_nodes:
Expand Down Expand Up @@ -1314,7 +1314,7 @@ def take_action(self, parsed_args):

if not all_nodes and not name:
logger.error("Please specify a node name or use --all")
return
return 1

from osism.tasks.openstack import get_cloud_helpers

Expand All @@ -1335,7 +1335,7 @@ def take_action(self, parsed_args):
node = conn.baremetal.find_node(name, ignore_missing=True, details=True)
if not node:
logger.warning(f"Could not find node {name}")
return
return 1
provide_nodes = [node]

for node in provide_nodes:
Expand Down Expand Up @@ -1405,7 +1405,7 @@ def take_action(self, parsed_args):
node = conn.baremetal.find_node(name, ignore_missing=True, details=True)
if not node:
logger.warning(f"Could not find node {name}")
return
return 1
try:
conn.baremetal.set_node_maintenance(node, reason=reason)
except Exception as exc:
Expand Down Expand Up @@ -1453,7 +1453,7 @@ def take_action(self, parsed_args):
node = conn.baremetal.find_node(name, ignore_missing=True, details=True)
if not node:
logger.warning(f"Could not find node {name}")
return
return 1
try:
conn.baremetal.unset_node_maintenance(node)
except Exception as exc:
Expand Down Expand Up @@ -1488,7 +1488,7 @@ def take_action(self, parsed_args):

if not name:
logger.error("Please specify a node name")
return
return 1

from osism.tasks.openstack import get_cloud_helpers

Expand All @@ -1505,7 +1505,7 @@ def take_action(self, parsed_args):
node = conn.baremetal.find_node(name, ignore_missing=True, details=True)
if not node:
logger.warning(f"Could not find node {name}")
return
return 1

try:
conn.baremetal.set_node_power_state(node.id, "power on")
Expand Down Expand Up @@ -1547,7 +1547,7 @@ def take_action(self, parsed_args):

if not name:
logger.error("Please specify a node name")
return
return 1

from osism.tasks.openstack import get_cloud_helpers

Expand All @@ -1564,7 +1564,7 @@ def take_action(self, parsed_args):
node = conn.baremetal.find_node(name, ignore_missing=True, details=True)
if not node:
logger.warning(f"Could not find node {name}")
return
return 1

target = "soft power off" if soft else "power off"

Expand Down Expand Up @@ -1616,13 +1616,13 @@ def take_action(self, parsed_args):

if not all_nodes and not name:
logger.error("Please specify a node name or use --all")
return
return 1

if all_nodes and not yes_i_really_really_mean_it:
logger.error(
"Please confirm that you wish to delete all nodes by specifying '--yes-i-really-really-mean-it'"
)
return
return 1

from osism.tasks.openstack import get_cloud_helpers

Expand All @@ -1645,7 +1645,7 @@ def take_action(self, parsed_args):
)
if not node:
logger.warning(f"Could not find node {name}")
return
return 1
delete_nodes = [node]

for node in delete_nodes:
Expand Down
16 changes: 8 additions & 8 deletions osism/commands/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def take_action(self, parsed_args):
"has been restarted, allowing these records to move to `completed` "
"before retrying this request."
)
return
return 1

logger.info(f"Enabling nova-compute binary @ {host} ({service.id})")
conn.compute.enable_service(
Expand Down Expand Up @@ -663,7 +663,7 @@ def take_action(self, parsed_args):
logger.error(
"changes-since needs to be less or equal to changes-before"
)
return
return 1

import openstack
from osism.tasks.openstack import get_cloud_helpers
Expand All @@ -689,14 +689,14 @@ def take_action(self, parsed_args):
user_query = dict(domain_id=u_d.id)
else:
logger.error(f"No domain found for {user_domain}")
return
return 1

u = conn.identity.find_user(user, ignore_missing=True, **user_query)
if u and "id" in u:
user_id = u.id
else:
logger.error(f"No user found for {user}")
return
return 1

project_id = None
if project:
Expand All @@ -708,7 +708,7 @@ def take_action(self, parsed_args):
project_query = dict(domain_id=p_d.id)
else:
logger.error(f"No domain found for {project_domain}")
return
return 1

p = conn.identity.find_project(
project, ignore_missing=True, **project_query
Expand All @@ -717,7 +717,7 @@ def take_action(self, parsed_args):
project_id = p.id
else:
logger.error(f"No project found for {project}")
return
return 1

instance_uuid = None
if server:
Expand All @@ -731,10 +731,10 @@ def take_action(self, parsed_args):
raise openstack.exceptions.NotFoundException
except openstack.exceptions.DuplicateResource:
logger.error(f"Multiple servers where found for {server}")
return
return 1
except openstack.exceptions.NotFoundException:
logger.error(f"No server found for {server}")
return
return 1

query = {}
if host:
Expand Down
8 changes: 5 additions & 3 deletions osism/commands/netbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def take_action(self, parsed_args):
logger.error(
f"Timeout while waiting for further output of task {task.task_id} (sync ironic)"
)
return 1
else:
if node_name:
logger.info(
Expand Down Expand Up @@ -376,6 +377,7 @@ def take_action(self, parsed_args):
logger.error(
f"Timeout while waiting for further output of task {task.task_id} (sync netbox)"
)
return 1
else:
if node_name:
logger.info(
Expand Down Expand Up @@ -536,7 +538,7 @@ def take_action(self, parsed_args):

if not token or not url:
logger.error("NetBox integration not configured.")
return
return 1

subprocess.call(
["/usr/local/bin/nbcli", "init"],
Expand Down Expand Up @@ -585,7 +587,7 @@ def take_action(self, parsed_args):
# Check if NetBox connection is available
if not utils.nb:
logger.error("NetBox integration not configured.")
return
return 1

device = None

Expand Down Expand Up @@ -631,7 +633,7 @@ def take_action(self, parsed_args):

if not device:
logger.error(f"Device '{host}' not found in NetBox.")
return
return 1

# Prepare table data for display
table = []
Expand Down
1 change: 1 addition & 0 deletions osism/commands/reconciler.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def take_action(self, parsed_args):
logger.error(
f"Timeout while waiting for further output of task {t.task_id} (sync inventory)"
)
return 1
else:
logger.info(
f"Task {t.task_id} (sync inventory) is running in background. No more output."
Expand Down
Loading