Skip to content

Commit e6a65ad

Browse files
authored
Add target option for GAIA resource modules (#132)
* ansible-lint bug fixes * ansible-lint bug fixes * R82 Resource Modules - part 1 * Delete plugins/modules/cp_mgmt_gaia_api.py * Delete .idea/CheckPointAnsibleMgmtCollection.iml * Add target option for running gaia resource modules
1 parent 9627203 commit e6a65ad

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

plugins/httpapi/checkpoint.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@
3333
- The Cloud Management ID
3434
vars:
3535
- name: ansible_cloud_mgmt_id
36+
target:
37+
type: str
38+
description:
39+
- target gateway
40+
vars:
41+
- name: ansible_checkpoint_target
3642
"""
3743

3844
import json
@@ -89,10 +95,14 @@ def get_session_uid(self):
8995
return self.connection._session_uid
9096

9197
def send_request(self, path, body_params):
92-
data = json.dumps(body_params) if body_params else "{}"
9398
cp_cloud_mgmt_id = self.get_option("cloud_mgmt_id")
9499
if cp_cloud_mgmt_id:
95100
path = "/" + cp_cloud_mgmt_id + path
101+
# we only replace gaia_ip/ with web_api/gaia-api/ if target is set and path contains gaia_ip/
102+
if 'gaia_api/' in path and self.get_option("target"):
103+
path = path.replace("gaia_api/", "web_api/gaia-api/")
104+
body_params['target'] = self.get_option("target")
105+
data = json.dumps(body_params) if body_params else '{}'
96106
try:
97107
self._display_request()
98108
response, response_data = self.connection.send(

0 commit comments

Comments
 (0)