From b7c02124c6ccdf46e94f14412ce4524d59748711 Mon Sep 17 00:00:00 2001 From: Jonas Jacobsson <30898404+jonjacs@users.noreply.github.com> Date: Mon, 9 May 2022 15:09:31 +0200 Subject: [PATCH] Support for fetching failover-state object attribute --- pypureomapi.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pypureomapi.py b/pypureomapi.py index def4299..e031ff9 100644 --- a/pypureomapi.py +++ b/pypureomapi.py @@ -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