Skip to content

Commit 9f156ef

Browse files
Storagebox subaccount (#163)
* bit more helpfull err msg in `robot.py` * add `storagebox_subaccount` * module manages a single subaccount * reach 100% coverage * idempotence input value * rm outdated doc * add `password_mode` input * more tests * add `no_log=True` to `password_mode` to silence warning * wip: fix PR review comments * always return subaccount data * fix review comments 2 * rework confusing condition * fix review comments 3 * fix review comments 4 * Update plugins/modules/storagebox_subaccount.py Co-authored-by: Felix Fontein <[email protected]> * Update plugins/modules/storagebox_subaccount.py Co-authored-by: Felix Fontein <[email protected]> * Update plugins/modules/storagebox_subaccount.py Co-authored-by: Felix Fontein <[email protected]> * fix review comments 5 --------- Co-authored-by: Felix Fontein <[email protected]>
1 parent 215f5c3 commit 9f156ef

File tree

6 files changed

+1459
-8
lines changed

6 files changed

+1459
-8
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ If you use the Ansible package and do not update collections independently, use
7171
- `community.hrobot.storagebox_snapshot_info` module
7272
- `community.hrobot.storagebox_snapshot_plan` module
7373
- `community.hrobot.storagebox_snapshot_plan_info` module
74+
- `community.hrobot.storagebox_subaccount` module
7475
- `community.hrobot.storagebox_subaccount_info` module
7576
- `community.hrobot.v_switch` module
7677
- `community.hrobot.robot` inventory plugin

meta/runtime.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ action_groups:
2525
- storagebox_snapshot_info
2626
- storagebox_snapshot_plan
2727
- storagebox_snapshot_plan_info
28+
- storagebox_subaccount
2829
- storagebox_subaccount_info
2930
- v_switch

plugins/module_utils/robot.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@ def raw_plugin_open_url_json(plugin, url, method='GET', timeout=10, data=None, h
100100
)
101101
status = response.code
102102
content = response.read()
103+
reason = response.reason
103104
except HTTPError as e:
104105
status = e.code
106+
reason = e.reason
105107
try:
106108
content = e.read()
107109
except AttributeError:
@@ -112,7 +114,11 @@ def raw_plugin_open_url_json(plugin, url, method='GET', timeout=10, data=None, h
112114
if not content:
113115
if allow_empty_result and status in allowed_empty_result_status_codes:
114116
return None, None
115-
raise PluginException('Cannot retrieve content from {0}, HTTP status code {1}'.format(url, status))
117+
raise PluginException(
118+
"Cannot retrieve content from {0} {1}, HTTP status code {2} ({3})".format(
119+
method, url, status, reason
120+
)
121+
)
116122

117123
try:
118124
result = json.loads(content.decode('utf-8'))
@@ -150,7 +156,11 @@ def raw_fetch_url_json(module, url, method='GET', timeout=10, data=None, headers
150156
if not content:
151157
if allow_empty_result and info.get('status') in allowed_empty_result_status_codes:
152158
return None, None
153-
module.fail_json(msg='Cannot retrieve content from {0}, HTTP status code {1}'.format(url, info.get('status')))
159+
module.fail_json(
160+
msg='Cannot retrieve content from {0} {1}, HTTP status code {2} ({3})'.format(
161+
method, url, info.get('status'), info.get('msg')
162+
)
163+
)
154164

155165
try:
156166
result = module.from_json(content.decode('utf8'))

0 commit comments

Comments
 (0)