Skip to content

Commit

Permalink
some more linting
Browse files Browse the repository at this point in the history
  • Loading branch information
BerndKue committed Oct 10, 2024
1 parent 8feedd9 commit 7a92660
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
34 changes: 21 additions & 13 deletions handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@

# pylint: disable=no-member

def get_ip_address(target):
"""
Get the IP address of the target.
"""

try:
return socket.gethostbyname(target)
except socket.gaierror as err:
raise HandlerException(f"DNS lookup failed for Remote Board {target}: {err}") from err

class WelcomePage:
"""
Create the Welcome page for the API.
Expand Down Expand Up @@ -103,6 +113,10 @@ def on_get(self, req, resp):
f"<p>Successfully pulled the inventory of target {target}."
f" Duration: {duration}s.</p>"
)
else:
resp.status = falcon.HTTP_500
resp.content_type = 'text/html'
resp.body = f"<p>Failed to pull the inventory of target {target}.</p>"

def check_server_inventory(self, server):
"""
Expand All @@ -119,18 +133,10 @@ def check_server_inventory(self, server):

node, pod, suffix = matches.groups()

device_name = node + "-" + pod
target = node + "r-" + pod + suffix

try:
ip_address = socket.gethostbyname(target)
except socket.gaierror as err:
raise HandlerException(
f" Server {server}: DNS lookup failed for Remote Board {target}: {err}"
) from err
bmc = node + "r-" + pod + suffix

updater = NetboxInventoryUpdater(
device_name = device_name,
device_name = node + "-" + pod,
netbox_connection = self.netbox_connection
)

Expand All @@ -143,12 +149,12 @@ def check_server_inventory(self, server):
logging.info("==> Server %s: Collecting inventory", server)

inventory = {}
logging.info(" Target %s: Collecting using RedFish ...", target)
logging.info(" Target %s: Collecting using RedFish ...", bmc)

server_collector = RedfishIventoryCollector(
timeout = int(os.getenv('CONNECTION_TIMEOUT', self.config['connection_timeout'])),
target = target,
ip_address = ip_address,
target = bmc,
ip_address = get_ip_address(bmc),
usr = self.usr,
pwd = self.pwd
)
Expand Down Expand Up @@ -179,4 +185,6 @@ def check_server_inventory(self, server):
del server_collector

return 0

return 1

3 changes: 1 addition & 2 deletions redfish_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,7 @@ def _get_storage_info(self, fields):
# Some Cisco and SuperMicro servers have the storage info in SimpleStorage
simple_storage = self.connect_server(self._urls['SimpleStorage'])
if simple_storage:
for controller in storage_collection['Members']:
pass
pass
# Get the storage details in case the Storage url has no proper infos (Supermicro)
# Need to write a function similar to _get_storage_details for this case.

Expand Down

0 comments on commit 7a92660

Please sign in to comment.