Skip to content

Commit 8768834

Browse files
committed
update according to sanity test
1 parent cf94f31 commit 8768834

15 files changed

+137
-74
lines changed

plugins/httpapi/checkpoint.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(self, connection):
5050
super(HttpApi, self).__init__(connection)
5151
self.connection = connection
5252
self.mgmt_proxy_enabled = False
53-
53+
5454
loader = DataLoader()
5555
# Initialize InventoryManager
5656
inventory = InventoryManager(loader=loader, sources=['/etc/ansible/hosts'])
@@ -59,20 +59,19 @@ def __init__(self, connection):
5959
# Get variable
6060
try:
6161
proxy_enabled = host.vars['enabled']
62-
if proxy_enabled == True:
62+
if proxy_enabled is True:
6363
self.mgmt_proxy_enabled = True
6464
except Exception as e:
6565
pass
6666

67-
6867
def login(self, username, password):
6968
payload = {}
7069
url = '/gaia_api/login'
7170
if username and password:
7271
payload = {'user': username, 'password': password}
7372
else:
7473
raise AnsibleConnectionFailure('Username and password are required for login')
75-
if self.mgmt_proxy_enabled == True:
74+
if self.mgmt_proxy_enabled is True:
7675
url = '/web_api/login'
7776
response, response_data = self.send_request(url, payload)
7877

@@ -84,7 +83,7 @@ def login(self, username, password):
8483

8584
def logout(self):
8685
url = '/gaia_api/logout'
87-
if self.mgmt_proxy_enabled == True:
86+
if self.mgmt_proxy_enabled is True:
8887
url = '/web_api/logout'
8988
response, dummy = self.send_request(url, None)
9089

@@ -94,9 +93,9 @@ def get_session_uid(self):
9493
def send_request(self, path, body_params):
9594
# we only replace gaia_ip/ with web_api/gaia-api/ if target is set and path contains for gaia_ip/
9695
cp_api_target = self.get_option('cptarget')
97-
if 'gaia_api/' in path: # Avoid login/logut requests in case of web_api
98-
if self.mgmt_proxy_enabled == True:
99-
if cp_api_target != None:
96+
if 'gaia_api/' in path: # Avoid login/logut requests in case of web_api
97+
if self.mgmt_proxy_enabled is True:
98+
if cp_api_target is not None:
10099
body_params['target'] = cp_api_target
101100
path = path.replace("gaia_api/", "web_api/gaia-api/")
102101
data = json.dumps(body_params) if body_params else '{}'

plugins/modules/cp_gaia_alias_interface.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ def main():
8989
add_params = {}
9090
parent_and_id = module.params["name"].split(":")
9191
if len(parent_and_id) == 2:
92-
add_params = {"parent": parent_and_id[0] }
92+
add_params = {"parent": parent_and_id[0]}
9393

9494
res = chkp_api_call(module, api_call_object, True, ignore=ignore, show_params=show_params, add_params=add_params)
9595
module.exit_json(**res)
9696

9797

9898
if __name__ == "__main__":
99-
main()
99+
main()

plugins/modules/cp_gaia_alias_interface_facts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,4 @@ def main():
9999

100100

101101
if __name__ == "__main__":
102-
main()
102+
main()

plugins/modules/cp_gaia_snmp.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,16 @@
103103
type: bool
104104
vs_access:
105105
description:
106-
- SNMP vs-access type direct/indirect queries on Virtual-Devices direct- SNMP direct queries on Virtual-Devices, indirect- SNMP direct queries via VS0
106+
- SNMP vs-access type direct/indirect queries on Virtual-Devices
107+
direct- SNMP direct queries on Virtual-Devices
108+
indirect- SNMP direct queries via VS0
107109
type: str
108110
choices: [direct, indirect]
109111
sysname:
110112
description:
111-
- This command is relevant only for VSX with SNMP VS mode, Where False = the sysname OID for all Virtual Devices will return the same result VS0 hostname True = VS0 sysname OID returns the VSX hostname and Virtual Device sysname OID returns the Check Point object name of the Virtual Device
113+
- This command is relevant only for VSX with SNMP VS mode, Where
114+
False = the sysname OID for all Virtual Devices will return the same result VS0 hostname
115+
True = VS0 sysname OID returns the VSX hostname and Virtual Device sysname OID returns the Check Point object name of the Virtual Device
112116
type: bool
113117
"""
114118

@@ -145,18 +149,24 @@ def main():
145149
read_write_community=dict(type="str", required=False),
146150
interfaces=dict(type="str", required=False),
147151
pre_defined_traps_settings=dict(
148-
polling_frequency=dict(type="int")
152+
type="dict",
153+
options=dict(polling_frequency=dict(type="int"))
149154
),
150155
custom_traps_settings=dict(
151-
clear_trap_interval=dict(type="int"),
152-
clear_trap_amount=dict(type="int")
156+
type="dict",
157+
options=dict(
158+
clear_trap_interval=dict(type="int"),
159+
clear_trap_amount=dict(type="int")
160+
)
153161
),
154162
vsx_settings=dict(
155-
enabled=dict(type="bool"),
156-
vs_access=dict(type="str", choices=["direct", "indirect"]),
157-
sysname=dict(type="bool")
163+
type="dict",
164+
options=dict(
165+
enabled=dict(type="bool"),
166+
vs_access=dict(type="str", choices=["direct", "indirect"]),
167+
sysname=dict(type="bool")
168+
)
158169
)
159-
160170
)
161171
fields.update(checkpoint_argument_spec_for_all)
162172
module = AnsibleModule(argument_spec=fields, supports_check_mode=True)

plugins/modules/cp_gaia_snmp_pre_defined_traps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def main():
252252
vrrpv3ProtoError=dict(type="dict", options=dict(enabled=dict(type="bool"))),
253253
coldStart=dict(type="dict", options=dict(enabled=dict(type="bool"), threshold=dict(type="int"), reboot_only=dict(type="bool"))),
254254
lowDiskSpaceAllPartitions=dict(type="dict", options=dict(enabled=dict(type="bool")))
255-
255+
256256
)
257257
fields.update(checkpoint_argument_spec_for_all)
258258
module = AnsibleModule(argument_spec=fields, supports_check_mode=True)

plugins/modules/cp_gaia_snmp_trap_receiver.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
choices: [v1, v2, v3]
5353
community_string:
5454
description:
55-
- Receiver community - Required only in case of v1/v2 versions, Trap Community String used by the trap receiver to determine which traps are accepted from a device.
55+
- Receiver community - Required only in case of v1/v2 versions
56+
Trap Community String used by the trap receiver to determine which traps are accepted from a device.
5657
type: str
5758
"""
5859

plugins/modules/cp_gaia_snmp_user.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@
6666
choices: [MD5, SHA1, SHA256, SHA512]
6767
password:
6868
description:
69-
- Authentication Password - (8 or more printable characters, Limited by 128 characters) Each SNMPv3 USM user must have an authentication pass phrase.
69+
- Authentication Password - (8 or more printable characters, Limited by 128 characters)
70+
Each SNMPv3 USM user must have an authentication pass phrase.
7071
type: str
7172
password_hash:
7273
description:
73-
- Authentication Hashed Password - (8 or more printable characters, Limited by 128 characters) Each SNMPv3 USM user must have an authentication pass phrase.
74+
- Authentication Hashed Password - (8 or more printable characters, Limited by 128 characters)
75+
Each SNMPv3 USM user must have an authentication pass phrase.
7476
type: str
7577
privacy:
7678
description:
@@ -84,11 +86,13 @@
8486
choices: [AES, DES, AES256]
8587
password:
8688
description:
87-
- Privacy Password - (8 or more printable characters, Limited by 128 characters) An SNMPv3 USM user with a privacy security level must have a privacy pass phrase.
89+
- Privacy Password - (8 or more printable characters, Limited by 128 characters)
90+
An SNMPv3 USM user with a privacy security level must have a privacy pass phrase.
8891
type: str
8992
password_hash:
9093
description:
91-
- Privacy Hashed Password - (8 or more printable characters, Limited by 128 characters) An SNMPv3 USM user with a privacy security level must have a privacy pass phrase.
94+
- Privacy Hashed Password - (8 or more printable characters, Limited by 128 characters)
95+
An SNMPv3 USM user with a privacy security level must have a privacy pass phrase.
9296
type: str
9397
"""
9498

@@ -119,15 +123,21 @@ def main():
119123
permission=dict(type='str', required=False, choices=['read-only', 'read-write']),
120124
allowed_virtual_systems=dict(type='str', required=False),
121125
authentication=dict(
122-
protocol=dict(type='str', required=False, choices=['MD5', 'SHA1', 'SHA256', 'SHA512']),
123-
password=dict(type='str', required=False, no_log=True),
124-
password_hash=dict(type='str', required=False, no_log=True)
125-
),
126+
type="dict",
127+
options=dict(
128+
protocol=dict(type="str", required=False, choices=['MD5', 'SHA1', 'SHA256', 'SHA512']),
129+
password=dict(type="str", required=False, no_log=True),
130+
password_hash=dict(type="str", required=False, no_log=True)
131+
)
132+
),
126133
privacy=dict(
127-
protocol=dict(type='str', required=False, choices=['AES', 'DES', 'AES256']),
128-
password=dict(type='str', required=False, no_log=True),
129-
password_hash=dict(type='str', required=False, no_log=True)
130-
)
134+
type="dict",
135+
options=dict(
136+
protocol=dict(type="str", required=False, choices=['AES', 'DES', 'AES256']),
137+
password=dict(type="str", required=False, no_log=True),
138+
password_hash=dict(type="str", required=False, no_log=True)
139+
)
140+
)
131141
)
132142
fields.update(checkpoint_argument_spec_for_all)
133143
module = AnsibleModule(argument_spec=fields, supports_check_mode=True)

plugins/modules/cp_gaia_system_group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,4 @@ def main():
9393

9494

9595
if __name__ == "__main__":
96-
main()
96+
main()

plugins/modules/cp_gaia_system_group_facts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,4 @@ def main():
9797

9898

9999
if __name__ == "__main__":
100-
main()
100+
main()

plugins/modules/cp_gaia_virtual_gateway.py

Lines changed: 55 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,23 @@
5050
- Collection of interfaces to be set, identified by the name. Replaces existing interfaces.
5151
type: list
5252
resources:
53-
description:
53+
description:
5454
- Virtual gateway resources configuration.
55-
type: dict
56-
suboptions:
57-
firewall_ipv4_instances:
58-
description:
55+
type: dict
56+
suboptions:
57+
firewall_ipv4_instances:
58+
description:
5959
- The number of IPv4 CoreXL instances to be assigned to the virtual gateway identified by name or ID.
60-
type: int
61-
firewall_ipv6_instances:
62-
description:
60+
type: int
61+
firewall_ipv6_instances:
62+
description:
6363
- The number of IPv6 CoreXL instances to be assigned to the virtual gateway identified by name or ID.
64-
type: int
64+
type: int
6565
virtual_switches:
66-
description:
66+
description:
6767
- Connect virtual gateway identified by name or ID to pre-existing virtual switches identified by their IDs.
6868
- Collection of virtual switches to be set, identified by their IDs. Replaces existing interfaces.
69-
type: list
69+
type: list
7070
mgmt_connection:
7171
description:
7272
- Management connection configuration.
@@ -126,18 +126,18 @@
126126
- name: eth1-02.2
127127
- name: eth1-02.3
128128
virtual_switches:
129-
- id: 1
130-
- id: 500
129+
- id: 1
130+
- id: 500
131131
resources:
132132
firewall_ipv4_instances: 2
133133
firewall_ipv6_instances: 0
134134
mgmt_connection:
135-
mgmt_connection_identifier: 500
136-
mgmt_connection_type: virtual-switch-id
137-
mgmt_ipv4_configuration:
138-
ipv4_address: 172.72.72.1
139-
ipv4_mask: 24
140-
ipv4_default_gateway: 172.72.72.4
135+
mgmt_connection_identifier: 500
136+
mgmt_connection_type: virtual-switch-id
137+
mgmt_ipv4_configuration:
138+
ipv4_address: 172.72.72.1
139+
ipv4_mask: 24
140+
ipv4_default_gateway: 172.72.72.4
141141
"""
142142
RETURN = """
143143
cp_gaia_virtual_system:
@@ -148,6 +148,7 @@
148148
from ansible.module_utils.basic import AnsibleModule
149149
from ansible_collections.check_point.gaia.plugins.module_utils.checkpoint import chkp_api_call, checkpoint_argument_spec_for_all
150150

151+
151152
def run_module():
152153
# arguments for the module:
153154
fields = dict(
@@ -156,19 +157,37 @@ def run_module():
156157
one_time_password=dict(type='str'),
157158
interfaces=dict(type='list'),
158159
virtual_switches=dict(type='list'),
159-
resources=dict(type='dict',
160-
firewall_ipv4_instances=dict(type='int'),
161-
firewall_ipv6_instances=dict(type='int')),
162-
mgmt_connection=dict(type='dict', mgmt_connection_identifier=dict(type='str', required=True),
163-
mgmt_connection_type=dict(type='str', required=True, choices=['interface', 'virtual-switch-id', 'virtual-switch-name']),
164-
mgmt_ipv4_configuration=dict(type='dict', required=False, ipv4_address=dict(type='str', required=True),
165-
ipv4_mask=dict(type='int', required=True),
166-
ipv4_default_gateway=dict(type='str', required=False)),
167-
mgmt_ipv6_configuration=dict(type='dict', required=False, ipv6_address=dict(type='str', required=True),
168-
ipv6_mask=dict(type='int', required=True),
169-
ipv6_default_gateway=dict(type='str', required=False))
170-
)
171-
)
160+
resources=dict(
161+
type='dict',
162+
firewall_ipv4_instances=dict(type='int'),
163+
firewall_ipv6_instances=dict(type='int')
164+
),
165+
mgmt_connection=dict(
166+
type='dict',
167+
options=dict(
168+
mgmt_connection_identifier=dict(type='str', required=True),
169+
mgmt_connection_type=dict(type='str', required=True, choices=['interface', 'virtual-switch-id', 'virtual-switch-name']),
170+
mgmt_ipv4_configuration=dict(
171+
type='dict',
172+
required=False,
173+
options=dict(
174+
ipv4_address=dict(type='str', required=True),
175+
ipv4_mask=dict(type='int', required=True),
176+
ipv4_default_gateway=dict(type='str', required=False)
177+
)
178+
),
179+
mgmt_ipv6_configuration=dict(
180+
type='dict',
181+
required=False,
182+
options=dict(
183+
ipv6_address=dict(type='str', required=True),
184+
ipv6_mask=dict(type='int', required=True),
185+
ipv6_default_gateway=dict(type='str', required=False)
186+
)
187+
)
188+
)
189+
)
190+
)
172191
fields.update(checkpoint_argument_spec_for_all)
173192
module = AnsibleModule(argument_spec=fields, supports_check_mode=True)
174193
ignore = ['status']
@@ -177,8 +196,11 @@ def run_module():
177196
api_call_object = "virtual-gateway"
178197
res = chkp_api_call(module, api_call_object, True, ignore=ignore, show_params=show_params, add_params=add_params)
179198
module.exit_json(**res)
199+
200+
180201
def main():
181202
run_module()
203+
204+
182205
if __name__ == '__main__':
183206
main()
184-

0 commit comments

Comments
 (0)