Skip to content

Commit

Permalink
chore: utilize more shared code in workflows
Browse files Browse the repository at this point in the history
Drop another function local to the obm function and use the shared copy.
  • Loading branch information
cardoe committed Aug 5, 2024
1 parent 9b043fb commit 3bbc124
Showing 1 changed file with 3 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ironicclient.common.apiclient.exceptions
from ironicclient.common.utils import args_array_to_patch

from understack_workflows.helpers import credential
from understack_workflows.helpers import setup_logger
from understack_workflows.ironic.client import IronicClient
from understack_workflows.ironic.secrets import read_secret
Expand All @@ -12,21 +13,6 @@
logger = setup_logger(__name__)


def credential_secrets():
"""Reads Kubernetes Secret files with username/password credentials."""
username = None
password = None
with open("/etc/obm/username") as f:
# strip leading and trailing whitespace
username = f.read().strip()

with open("/etc/obm/password") as f:
# strip leading and trailing whitespace
password = f.read().strip()

return [username, password]


def main():
if len(sys.argv) < 1:
raise ValueError(
Expand Down Expand Up @@ -64,7 +50,8 @@ def main():
sys.exit(0)

# Update OBM credentials
expected_username, expected_password = credential_secrets()
expected_username = credential("obm", "username")
expected_password = credential("obm", "password")

updates = [
f"driver_info/redfish_username={expected_username}",
Expand Down

0 comments on commit 3bbc124

Please sign in to comment.