Skip to content

Commit

Permalink
basic env var and result check
Browse files Browse the repository at this point in the history
  • Loading branch information
dbeltman committed May 31, 2024
1 parent e803ac2 commit 3455eb0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def main():
# Check BMC method and perform action for esphome
if node.bmc_method == "esphome":
logger.info(f"Turning on the {node.node_name} using esphome system.")
asyncio.run(power_on_esphome_system(node.node_name))
label_pod_with_custom_autoscaler_trigger(pending_pod.podname, pending_pod.podnamespace)
if asyncio.run(power_on_esphome_system(node.node_name)) != False:
label_pod_with_custom_autoscaler_trigger(pending_pod.podname, pending_pod.podnamespace)
else:
logger.warning(f"No mechanism for BMC method '{node.bmc_method}' yet!")

Expand Down
5 changes: 5 additions & 0 deletions src/bmc_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ async def power_on_esphome_system(nodename):
# Args:
# nodename (str): The name of the node whose power switch should be turned on.
# Set up connection to ESPHome API client
address=os.getenv(f"{nodename}_bmc_hostname")
if not address:
logger.error(f"A hostname for {nodename} was not found in an ENV variable")
return False
api = APIClient(
address=os.getenv(f"{nodename}_bmc_hostname"),
port=os.getenv(f"{nodename}_bmc_port", 6053),
Expand All @@ -37,5 +41,6 @@ async def power_on_esphome_system(nodename):
logger.info(f"Power switch found for node {nodename}! Turning on switch")
# Create a command to turn the switch on
command = api.switch_command(key=entity.key, state=True)
return True


0 comments on commit 3455eb0

Please sign in to comment.