-
Notifications
You must be signed in to change notification settings - Fork 39
new_module proxmox_firewall #183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 21 commits
d00c335
5185516
bcf4446
7e97435
32fc55f
f5f231c
7d0b401
36aa623
47d52ca
43d18f5
6327901
4b14774
a7cb2df
1adb2ca
11a3a19
ac5d44b
a5419bd
0741d0c
bfd5e5c
74b3d44
0b01684
6f37333
508e616
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,3 +99,47 @@ def get_zones(self, zone_type: str = None) -> List[Dict]: | |
self.module.fail_json( | ||
msg=f'Failed to retrieve zone information from cluster: {e}' | ||
) | ||
|
||
def get_aliases(self, firewall_obj): | ||
"""Get aliases for IP/CIDR at given firewall endpoint level | ||
|
||
:param firewall_obj: Firewall endpoint as a ProxmoxResource e.g. self.proxmox_api.cluster().firewall | ||
If it is None it'll return empty list | ||
JanaHoch marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
:return: List of aliases and corresponding IP/CIDR | ||
""" | ||
if firewall_obj is None: | ||
return list() | ||
try: | ||
return firewall_obj().aliases().get() | ||
except Exception as e: | ||
self.module.fail_json( | ||
msg='Failed to retrieve aliases' | ||
) | ||
|
||
def get_fw_rules(self, rules_obj, pos=None): | ||
"""Get firewall rules at given rules endpoint level | ||
|
||
:param rules_obj: Firewall Rules endpoint as a ProxmoxResource e.g. self.proxmox_api.cluster().firewall().rules | ||
:param pos: Rule position if it is None it'll return all rules | ||
:return: Firewall rules as a list of dict | ||
""" | ||
if pos is not None: | ||
rules_obj = getattr(rules_obj(), str(pos)) | ||
try: | ||
return rules_obj.get() | ||
except Exception as e: | ||
self.module.fail_json( | ||
msg=f'Failed to retrieve firewall rules: {e}' | ||
) | ||
JanaHoch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def get_groups(self): | ||
"""Get firewall security groups | ||
|
||
:return: list of groups | ||
""" | ||
Comment on lines
103
to
139
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think type hints could be nice here. But just close it if you dont think so. Totally optional. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. umm actually I tried bu for some reason If I import |
||
try: | ||
return [x['group'] for x in self.proxmox_api.cluster().firewall().groups().get()] | ||
except Exception as e: | ||
self.module.fail_json( | ||
msg=f'Failed to retrieve firewall security groups: {e}' | ||
) |
Uh oh!
There was an error while loading. Please reload this page.