Skip to content

Commit

Permalink
Merge pull request #40 from jonjacs/failover-state-object
Browse files Browse the repository at this point in the history
Support for fetching failover-state object attribute
  • Loading branch information
cygnusb authored May 9, 2022
2 parents a9f3a14 + b7c0212 commit 183fb67
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pypureomapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,26 @@ def lookup_by_host(self, **kwargs):
def lookup_by_lease(self, **kwargs):
return self.__lookup("lease", **kwargs)

def lookup_failoverstate(self, name, attribute):
"""Look up a failover-state object with given peer name and return the associated attribute.
@type name: str
@type attribute: str
@rtype: str or None
@raises ValueError:
@raises OmapiError:
@raises OmapiErrorNotFound: if no failover-state object with the given name could be found
@raises OmapiErrorAttributeNotFound: if failover-state object could be found, but object lacks the attribute
@raises socket.error:
"""
res = self.lookup_by_failoverstate(name=name)
if attribute not in res:
raise OmapiErrorAttributeNotFound()
return res[attribute]

def lookup_by_failoverstate(self, **kwargs):
return self.__lookup("failover-state", **kwargs)

def __lookup(self, ltype, **kwargs):
"""Generic Lookup function
Expand Down

0 comments on commit 183fb67

Please sign in to comment.