Skip to content

Commit

Permalink
Move rest_send.py to module_utils/common
Browse files Browse the repository at this point in the history
RestSend will be used by both dcnm_image_upgrade and dcnm_image_policy in the future, so moving it into module_utils/common for sharing between these modules.
  • Loading branch information
allenrobel committed Feb 26, 2024
1 parent d51a721 commit 3557f54
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,20 @@ class RestSend:
Usage (where ansible_module is an instance of AnsibleModule):
send_rest = RestSend(ansible_module)
send_rest.path = "/rest/top-down/fabrics"
send_rest.verb = "GET"
send_rest.commit()
response = send_rest.response
result = send_rest.result
rest_send = RestSend(ansible_module)
rest_send.path = "/rest/top-down/fabrics"
rest_send.verb = "GET"
rest_send.payload = my_payload # Optional
rest_send.commit()
# list of responses from the controller for this session
response = rest_send.response
# dict with current controller response
response_current = rest_send.response_current
# list of results from the controller for this session
result = rest_send.result
# dict with current controller result
result_current = rest_send.result_current
"""

def __init__(self, ansible_module):
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/image_upgrade/image_stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
ApiEndpoints
from ansible_collections.cisco.dcnm.plugins.module_utils.image_upgrade.image_upgrade_common import \
ImageUpgradeCommon
from ansible_collections.cisco.dcnm.plugins.module_utils.image_upgrade.rest_send import \
from ansible_collections.cisco.dcnm.plugins.module_utils.common.rest_send import \
RestSend
from ansible_collections.cisco.dcnm.plugins.module_utils.image_upgrade.switch_issu_details import \
SwitchIssuDetailsBySerialNumber
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/image_upgrade/image_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
ImageUpgradeCommon
from ansible_collections.cisco.dcnm.plugins.module_utils.image_upgrade.install_options import \
ImageInstallOptions
from ansible_collections.cisco.dcnm.plugins.module_utils.image_upgrade.rest_send import \
from ansible_collections.cisco.dcnm.plugins.module_utils.common.rest_send import \
RestSend
from ansible_collections.cisco.dcnm.plugins.module_utils.image_upgrade.switch_issu_details import \
SwitchIssuDetailsByIpAddress
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/image_upgrade/image_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
ApiEndpoints
from ansible_collections.cisco.dcnm.plugins.module_utils.image_upgrade.image_upgrade_common import \
ImageUpgradeCommon
from ansible_collections.cisco.dcnm.plugins.module_utils.image_upgrade.rest_send import \
from ansible_collections.cisco.dcnm.plugins.module_utils.common.rest_send import \
RestSend
from ansible_collections.cisco.dcnm.plugins.module_utils.image_upgrade.switch_issu_details import \
SwitchIssuDetailsBySerialNumber
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/image_upgrade/switch_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
ApiEndpoints
from ansible_collections.cisco.dcnm.plugins.module_utils.image_upgrade.image_upgrade_common import \
ImageUpgradeCommon
from ansible_collections.cisco.dcnm.plugins.module_utils.image_upgrade.rest_send import \
from ansible_collections.cisco.dcnm.plugins.module_utils.common.rest_send import \
RestSend


Expand Down

0 comments on commit 3557f54

Please sign in to comment.