Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added workaround for the conflict in --hostname #139

Merged
merged 2 commits into from
Apr 18, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
.bash*
.config
.python-version
.idea
dist
build
parts
Expand Down
35 changes: 35 additions & 0 deletions cray/modules/hsm/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def setup(hsm_cli):
""" Sets up all HSM overrides """
setup_groups_partitions_create(hsm_cli, 'groups')
setup_groups_partitions_create(hsm_cli, 'partitions')
setup_redfish_endpoints_update(hsm_cli)
setup_redfish_endpoints_create(hsm_cli)


# Groups and Partitions #
Expand Down Expand Up @@ -93,6 +95,39 @@ def setup_groups_partitions_create(hsm_cli, command):
hsm_cli.commands[command].commands['create'] = create_command


# redfishEndpoints update #
def setup_redfish_endpoints_update(hsm_cli):
""" Added a fix for the hostname being set to the cray global hostname """
update_command = hsm_cli.commands["inventory"].commands["redfishEndpoints"].commands['update']
update_command.callback = create_re_create_and_update_shim(update_command.callback)


# redfishEndpoints create #
def setup_redfish_endpoints_create(hsm_cli):
""" Added a fix for the hostname being set to the cray global hostname """
create_command = hsm_cli.commands["inventory"].commands["redfishEndpoints"].commands['create']
create_command.callback = create_re_create_and_update_shim(create_command.callback)


def create_re_create_and_update_shim(func):
""" This causes the call to ignore any hostname value that starts with http: or https:
The top level cray command has a --hostname option which is stored in the config file
and its value gets passed through here when the user doesn't specify the hsm flavor
of the --hostname option """

def _decorator(**kwargs):
hostname = kwargs.get("hostname")
if hostname:
value = hostname.get("value")
if value and (value.lower().startswith("https:") or value.lower().startswith("http:")):
hostname["value"] = None
kwargs["hostname"] = hostname

return func(**kwargs)

return _decorator


# Keeping for future API versions
# if HSM_API_VERSION == 'v1':
# cli = generate(__file__, filename='swagger3_v1.json', swagger_opts=SWAGGER_OPTS)
Expand Down
Loading
Loading