X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=monitor%2Fgetsshkeys.py;h=686252bcb4859a9be9c4579e70ae1240d1525f87;hb=3f4df5945bbfb4592a164d929cf22c31d5fba50e;hp=d362c9422a2fdacf80ca38ed77ae5b6f69f1d893;hpb=334378a14103c3fd02332b6ce3767553f1fe11d2;p=monitor.git diff --git a/monitor/getsshkeys.py b/monitor/getsshkeys.py index d362c94..686252b 100755 --- a/monitor/getsshkeys.py +++ b/monitor/getsshkeys.py @@ -15,17 +15,17 @@ except: print traceback.print_exc() auth = {'AuthMethod' : "anonymous"} -args = {} -args['known_hosts'] = os.environ['HOME'] + os.sep + ".ssh" + os.sep + "known_hosts" -try: - from monitor import config - args['XMLRPC_SERVER'] = config.API_SERVER -except: - args['XMLRPC_SERVER'] = 'https://boot.planet-lab.org/PLCAPI/' - print "Using default API server %s" % args['XMLRPC_SERVER'] class SSHKnownHosts: - def __init__(self, args = args): + def __init__(self, args = None): + if not args: args = {} + args['known_hosts'] = os.environ['HOME'] + os.sep + ".ssh" + os.sep + "known_hosts" + try: + from monitor import config + args['XMLRPC_SERVER'] = config.API_SERVER + except: + args['XMLRPC_SERVER'] = 'https://boot.planet-lab.org/PLCAPI/' + print "Using default API server %s" % args['XMLRPC_SERVER'] self.args = args self.read_knownhosts() self.auth = auth @@ -135,27 +135,27 @@ class SSHKnownHosts: if type(host) == type(""): host = [host] # get the node(s) info - nodes = self.api.GetNodes(self.auth,host,["hostname","ssh_rsa_key","nodenetwork_ids"]) + nodes = self.api.GetNodes(self.auth,host,["hostname","ssh_rsa_key","interface_ids"]) # for each node's node network, update the self.nodenetworks cache nodenetworks = [] for node in nodes: - for net in node["nodenetwork_ids"]: + for net in node["interface_ids"]: nodenetworks.append(net) - plcnodenetworks = self.api.GetNodeNetworks(self.auth,nodenetworks,["nodenetwork_id","ip"]) + plcnodenetworks = self.api.GetInterfaces(self.auth,nodenetworks,["interface_id","ip"]) for n in plcnodenetworks: - self.nodenetworks[n["nodenetwork_id"]]=n + self.nodenetworks[n["interface_id"]]=n return nodes def _record_from_node(self, node, nokey_list=None): host = node['hostname'] key = node['ssh_rsa_key'] - nodenetworks = node['nodenetwork_ids'] + nodenetworks = node['interface_ids'] if len(nodenetworks)==0: return (host, None, None, None) - # the [0] subscript to node['nodenetwork_ids'] means + # the [0] subscript to node['interface_ids'] means # that this function wont work with multihomed nodes l_nw = self.nodenetworks.get(nodenetworks[0],None) if l_nw is None: return (host, None, None, None)