X-Git-Url: http://git.onelab.eu/?p=monitor.git;a=blobdiff_plain;f=monitor%2Fwrapper%2Fplc.py;h=15153966ed2e567d78c35f9f77fac0d59be9bf93;hp=2f0f19daa63efd4fee8a116aaee9d96738f387f0;hb=ce9101bfa7720c131a982220f2905e4439b324fc;hpb=c9d06f3b274ecbc092a0b3eb1f5ceb6c0f734aad diff --git a/monitor/wrapper/plc.py b/monitor/wrapper/plc.py index 2f0f19d..1515396 100644 --- a/monitor/wrapper/plc.py +++ b/monitor/wrapper/plc.py @@ -71,7 +71,7 @@ class PLC: try: return lambda *params : method(self.auth, *params) - except ProtocolError: + except xmlrpclib.ProtocolError: traceback.print_exc() global_error_count += 1 if global_error_count >= 10: @@ -84,7 +84,6 @@ class PLC: def __repr__(self): return self.api.__repr__() -api = PLC(auth.auth, auth.server) class CachedPLC(PLC): @@ -132,6 +131,9 @@ class CachedPLC(PLC): return run_or_returncached +api = PLC(auth.auth, auth.server) +cacheapi = CachedPLC(auth.auth, auth.server) + def getAPI(url): return xmlrpclib.Server(url, verbose=False, allow_none=True) @@ -146,6 +148,13 @@ def getAuthAPI(): def getCachedAuthAPI(): return CachedPLC(auth.auth, auth.server) +def getSessionAPI(session, server): + nodeauth = Auth(session=session) + return PLC(nodeauth.auth, server) +def getUserAPI(username, password, server): + auth = Auth(username,password) + return PLC(auth.auth, server) + def getTechEmails(loginbase): """ For the given site, return all user email addresses that have the 'tech' role. @@ -301,14 +310,14 @@ def getSiteNodes2(loginbase): def getNodeNetworks(filter=None): api = xmlrpclib.Server(auth.server, verbose=False, allow_none=True) - nodenetworks = api.GetNodeNetworks(auth.auth, filter, None) + nodenetworks = api.GetInterfaces(auth.auth, filter, None) return nodenetworks def getNodes(filter=None, fields=None): api = xmlrpclib.Server(auth.server, verbose=False, allow_none=True) nodes = api.GetNodes(auth.auth, filter, fields) #['boot_state', 'hostname', - #'site_id', 'date_created', 'node_id', 'version', 'nodenetwork_ids', + #'site_id', 'date_created', 'node_id', 'version', 'interface_ids', #'last_updated', 'peer_node_id', 'ssh_rsa_key' ]) return nodes