Skip to content

Commit

Permalink
Added prism.Config.get_protection_rules
Browse files Browse the repository at this point in the history
  • Loading branch information
grdavies-ntnx committed Mar 31, 2021
1 parent 7b21d9e commit 8349aca
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ A log of changes by version and date.
:header: "Version", "Date", "Notes"
:widths: 10, 10, 60

"1.1.29", "3/31/2021", "Added prism.Config.get_protection_rules."
"1.1.28", "3/31/2021", "Resolved issue where ProtectionRules were being returned as categories on each VM/Host assigned to the protection rule."
"1.1.27", "3/31/2021", "Resolved issue with if statements within prism.Config.get_projects and prism.Config.get_project_usage."
"1.1.26", "3/31/2021", "Resolved issue with identifying a PC instance within prism.Cluster.get_all_uuids."
Expand Down
2 changes: 1 addition & 1 deletion ntnx_api/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# 2) we can import it in setup.py for the same reason
# 3) we can import it into your module module

__version_info__ = ('1', '1', '28')
__version_info__ = ('1', '1', '29')
__version__ = '.'.join(__version_info__)
21 changes: 21 additions & 0 deletions ntnx_api/prism.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def __init__(self, api_client):
self.ntp_servers = {}
self.dns_servers = {}
self.proxy = {}
self.protection_rules = {}

def get_ui_config(self, clusteruuid=None):
"""Get the configuration data for a clusters Prism Element user interface
Expand Down Expand Up @@ -2243,6 +2244,26 @@ def change_ui_admin_password(self, admin_password, ssh_user='nutanix', ssh_passw
stdin, stdout, stderr = ssh.exec_command(command)
logger.debug(stdout.readlines())

def get_protection_rules(self):
"""Retrieve data for all protection rules.
.. note:: Will only return data when `connection_type=='pc'`
"""
logger = logging.getLogger('ntnx_api.prism.Config.get_protection_rules')
params = {}

if self.api_client.connection_type == "pc":
self.protection_rules = {}
uri = '/protection_rules/list'
payload = {
"kind": "protection_rule",
"offset": 0,
"length": 2147483647
}
self.protection_rules = self.api_client.request(uri=uri, payload=payload, params=params).get('entities')

return self.protection_rules


class Cluster(object):
"""A class to represent a Nutanix Cluster
Expand Down

0 comments on commit 8349aca

Please sign in to comment.