Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
mharding-hpe committed Sep 18, 2024
1 parent 4545eab commit 57ef0bd
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
23 changes: 0 additions & 23 deletions cray/modules/bos/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
""" bos """
# pylint: disable=invalid-name
import json
#import sys

from cray.constants import FROM_FILE_TAG
from cray.core import option
Expand All @@ -45,17 +44,11 @@
cli.commands = cli.commands[CURRENT_VERSION].commands


DEBUG_LINES=[]

def dbg(s):
DEBUG_LINES.append(s)

def strip_tenant_header_params(cmd=cli):
"""
Remove tenant header parameters from CLI commands, because those are
handled differently by the CLI
"""
dbg(cmd.name)
if hasattr(cmd, 'params'):
cmd.params = [ p for p in cmd.params if p.payload_name != 'Cray-Tenant-Name' ]
if hasattr(cmd, 'commands'):
Expand Down Expand Up @@ -108,8 +101,6 @@ def create_patch_shim(func):

def _decorator(filter_ids, filter_session, patch, enabled, retry_policy, clear_desired_state,
clear_staged_state, clear_pending_state, **kwargs):
dbg(f"create_patch_shim decorator kwargs={kwargs}")
#sys.stderr.write(f"create_patch_shim decorator kwargs={kwargs}\n")
filter_ids = filter_ids["value"]
filter_session = filter_session["value"]
if not (filter_ids or filter_session):
Expand Down Expand Up @@ -226,12 +217,7 @@ def setup_components_patch():
callback=_opt_callback,
help='Shortcut for --clear-desired-state --clear-staged-state'
)(new_command)
for param in new_command.params:
dbg(f'updatemany-before: {param}')
new_command.params += default_params
for param in new_command.params:
dbg(f'updatemany-after: {param}')
dbg(f'dir updatemany-after:{dir(new_command)}')
new_command.callback = create_patch_shim(new_command.callback)

STAGED_STATE_ARGS=[
Expand All @@ -253,8 +239,6 @@ def create_patch_compnent_shim(func):
""" Callback function to custom create our own payload """

def _decorator(clear_desired_state, clear_staged_state, clear_pending_state, **kwargs):
dbg(f"create_patch_compnent_shim decorator kwargs={kwargs}")
#sys.stderr.write(f"create_patch_component_shim decorator kwargs={kwargs}\n")
if clear_pending_state["value"]:
clear_staged_state["value"] = True
clear_desired_state["value"] = True
Expand Down Expand Up @@ -292,11 +276,7 @@ def modify_component_patch():
callback=_opt_callback,
help='Shortcut for --clear-desired-state --clear-staged-state'
)(source_command)
for param in source_command.params:
dbg(f'update-before: {param}')
source_command.params = source_command.params[-3:] + source_command.params[:-3]
for param in source_command.params:
dbg(f'update-after: {param}')
source_command.callback = create_patch_compnent_shim(source_command.callback)


Expand Down Expand Up @@ -325,6 +305,3 @@ def setup_v2_template_create():
setup_components_patch()

modify_component_patch()

with open("/tmp/boscli.txt", "wt") as f:
f.write('\n'.join(DEBUG_LINES) + '\n')
2 changes: 1 addition & 1 deletion cray/tests/test_modules/test_bos.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def test_cray_bos_v2_components_updatemany_by_session(cli_runner, rest_mock):
result = runner.invoke(
cli,
['bos', 'v2', 'components', 'updatemany', '--filter-session',
'test1', '--clear-pending-state', '--patch', '{ "enabled": True }']
'test1', '--clear-pending-state', '--patch', '{ "enabled": true }']
)
assert result.exit_code == 0
data = json.loads(result.output)
Expand Down

0 comments on commit 57ef0bd

Please sign in to comment.