Loading docs/changelog.rst +1 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ A log of changes by version and date. :header: "Version", "Date", "Notes" :widths: 10, 10, 60 "1.1.30", "4/1/2021", "Added prism.Vms.get_protection_rules." "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." Loading ntnx_api/_version.py +1 −1 Original line number Diff line number Diff line Loading @@ -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', '29') __version_info__ = ('1', '1', '30') __version__ = '.'.join(__version_info__) ntnx_api/prism.py +31 −2 Original line number Diff line number Diff line Loading @@ -2615,7 +2615,6 @@ class Hosts(object): self.get_metadata(refresh=refresh) metadata = self.metadata.get(uuid) if metadata: logger.info('host "{0}" metadata "{1}"'.format(uuid, metadata)) if 'categories' in metadata: for key, value in metadata.get('categories').items(): # Skip keys that do not relate to categories Loading @@ -2623,6 +2622,7 @@ class Hosts(object): 'ProtectionRule', ] if not any(value in key for value in items_to_exclude): logger.info('host "{0}" category "{1}:{2}"'.format(uuid, key, value)) categories[key] = value return categories Loading Loading @@ -2800,7 +2800,6 @@ class Vms(object): self.get_metadata(refresh=refresh) metadata = self.metadata.get(uuid) if metadata: logger.info('vm "{0}" metadata "{1}"'.format(uuid, metadata)) if 'categories' in metadata: for key, value in metadata.get('categories').items(): Loading @@ -2809,9 +2808,39 @@ class Vms(object): 'ProtectionRule', ] if not any(value in key for value in items_to_exclude): logger.info('vm "{0}" category "{1}:{2}"'.format(uuid, key, value)) categories[key] = value return categories def get_protection_rules(self, uuid, refresh=False): """Retrieve the protection rules assigned to the specified VM if connected to a prism central :param uuid: The UUID of a VM. :type uuid: str :param refresh: Whether to refresh the class VM Metadata dataset (default=False). :type refresh: bool, optional :returns: A dictionary with all . :rtype: ResponseDict """ logger = logging.getLogger('ntnx_api.prism.Vms.get_protection_rules') protection_rules = {} if self.api_client.connection_type == "pc": self.get_metadata(refresh=refresh) metadata = self.metadata.get(uuid) if metadata: if 'categories' in metadata: for key, value in metadata.get('categories').items(): # Skip keys that do not relate to categories items_to_include = [ 'ProtectionRule', ] if any(value in key for value in items_to_include): logger.info('vm "{0}" protection rule "{1}:{2}"'.format(uuid, key, value)) protection_rules[key] = value return protection_rules class Images(object): """A class to represent a Nutanix Clusters Images Loading Loading
docs/changelog.rst +1 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ A log of changes by version and date. :header: "Version", "Date", "Notes" :widths: 10, 10, 60 "1.1.30", "4/1/2021", "Added prism.Vms.get_protection_rules." "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." Loading
ntnx_api/_version.py +1 −1 Original line number Diff line number Diff line Loading @@ -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', '29') __version_info__ = ('1', '1', '30') __version__ = '.'.join(__version_info__)
ntnx_api/prism.py +31 −2 Original line number Diff line number Diff line Loading @@ -2615,7 +2615,6 @@ class Hosts(object): self.get_metadata(refresh=refresh) metadata = self.metadata.get(uuid) if metadata: logger.info('host "{0}" metadata "{1}"'.format(uuid, metadata)) if 'categories' in metadata: for key, value in metadata.get('categories').items(): # Skip keys that do not relate to categories Loading @@ -2623,6 +2622,7 @@ class Hosts(object): 'ProtectionRule', ] if not any(value in key for value in items_to_exclude): logger.info('host "{0}" category "{1}:{2}"'.format(uuid, key, value)) categories[key] = value return categories Loading Loading @@ -2800,7 +2800,6 @@ class Vms(object): self.get_metadata(refresh=refresh) metadata = self.metadata.get(uuid) if metadata: logger.info('vm "{0}" metadata "{1}"'.format(uuid, metadata)) if 'categories' in metadata: for key, value in metadata.get('categories').items(): Loading @@ -2809,9 +2808,39 @@ class Vms(object): 'ProtectionRule', ] if not any(value in key for value in items_to_exclude): logger.info('vm "{0}" category "{1}:{2}"'.format(uuid, key, value)) categories[key] = value return categories def get_protection_rules(self, uuid, refresh=False): """Retrieve the protection rules assigned to the specified VM if connected to a prism central :param uuid: The UUID of a VM. :type uuid: str :param refresh: Whether to refresh the class VM Metadata dataset (default=False). :type refresh: bool, optional :returns: A dictionary with all . :rtype: ResponseDict """ logger = logging.getLogger('ntnx_api.prism.Vms.get_protection_rules') protection_rules = {} if self.api_client.connection_type == "pc": self.get_metadata(refresh=refresh) metadata = self.metadata.get(uuid) if metadata: if 'categories' in metadata: for key, value in metadata.get('categories').items(): # Skip keys that do not relate to categories items_to_include = [ 'ProtectionRule', ] if any(value in key for value in items_to_include): logger.info('vm "{0}" protection rule "{1}:{2}"'.format(uuid, key, value)) protection_rules[key] = value return protection_rules class Images(object): """A class to represent a Nutanix Clusters Images Loading