git://git.onelab.eu
/
monitor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Tagging module Monitor - Monitor-3.0-16
[monitor.git]
/
getsshkeys.py
diff --git
a/getsshkeys.py
b/getsshkeys.py
index
0819abe
..
7932ab3
100755
(executable)
--- a/
getsshkeys.py
+++ b/
getsshkeys.py
@@
-5,17
+5,30
@@
import sys
import string
import time
import xml, xmlrpclib
import string
import time
import xml, xmlrpclib
+try:
+ from monitor import config
+ auth = {'Username' : config.API_AUTH_USER,
+ 'AuthMethod' : "password",
+ 'AuthString' : config.API_AUTH_PASSWORD}
+except:
+ import traceback
+ print traceback.print_exc()
+ auth = {'AuthMethod' : "anonymous"}
args = {}
args['known_hosts'] = os.environ['HOME'] + os.sep + ".ssh" + os.sep + "known_hosts"
args = {}
args['known_hosts'] = os.environ['HOME'] + os.sep + ".ssh" + os.sep + "known_hosts"
-args['XMLRPC_SERVER'] = 'https://www.planet-lab.org/PLCAPI/'
+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):
self.args = args
self.read_knownhosts()
class SSHKnownHosts:
def __init__(self, args = args):
self.args = args
self.read_knownhosts()
- self.auth = {}
- self.auth['AuthMethod'] = "anonymous"
+ self.auth = auth
self.api = xmlrpclib.Server(args['XMLRPC_SERVER'], verbose=False, allow_none=True)
self.nodenetworks = {}
self.api = xmlrpclib.Server(args['XMLRPC_SERVER'], verbose=False, allow_none=True)
self.nodenetworks = {}
@@
-122,27
+135,27
@@
class SSHKnownHosts:
if type(host) == type(""): host = [host]
# get the node(s) info
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 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)
nodenetworks.append(net)
- plcnodenetworks = self.api.Get
NodeNetworks(self.auth,nodenetworks,["nodenetwork
_id","ip"])
+ plcnodenetworks = self.api.Get
Interfaces(self.auth,nodenetworks,["interface
_id","ip"])
for n in plcnodenetworks:
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']
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)
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)
# 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)