[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r19351 - in gnunet-planetlab: . planetlab-api
From: |
gnunet |
Subject: |
[GNUnet-SVN] r19351 - in gnunet-planetlab: . planetlab-api |
Date: |
Tue, 24 Jan 2012 18:39:44 +0100 |
Author: wachs
Date: 2012-01-24 18:39:44 +0100 (Tue, 24 Jan 2012)
New Revision: 19351
Added:
gnunet-planetlab/planetlab-api/
gnunet-planetlab/planetlab-api/getnodes.py
Log:
script to extract get all nodes in booted state and write it to an file
Added: gnunet-planetlab/planetlab-api/getnodes.py
===================================================================
--- gnunet-planetlab/planetlab-api/getnodes.py (rev 0)
+++ gnunet-planetlab/planetlab-api/getnodes.py 2012-01-24 17:39:44 UTC (rev
19351)
@@ -0,0 +1,57 @@
+'''
+Created on Jan 24, 2012
+
address@hidden: mwachs
+'''
+
+#!/usr/bin/python
+import sys, os, urllib, xmlrpclib, socket
+
+user = ''
+password = ''
+
+arg = sys.argv
+size = len(arg)
+if (len(arg) < 4):
+ print 'usage: -u <username> -p <password>'
+ exit()
+
+if (arg[1] == '-u'):
+ user = arg[2]
+if (arg[3] == '-p'):
+ password = arg [4]
+
+# the PL Central API
+apiurl = 'https://www.planet-lab.org/PLCAPI/'
+server = xmlrpclib.ServerProxy(apiurl)
+
+# the auth struct
+auth = {}
+auth['Username'] = user
+auth['AuthString'] = password
+auth['AuthMethod'] = "password"
+
+# request all sites on PL
+sys.stdout.write('Retrieving PL sites list... ')
+sys.stdout.flush()
+sites = server.GetSites(auth,{},['site_id','name','latitude','longitude'])
+nsites = len(sites)
+sys.stdout.write('Got ' + str(nsites) + ' sites\n\n')
+sys.stdout.flush()
+
+
+# request all nodes on PL
+sys.stdout.write('Retrieving PL nodes list for sites')
+sys.stdout.flush()
+filter_dict = {"boot_state":"boot"}
+nodes =
server.GetNodes(auth,filter_dict,['site_id','node_id','hostname','boot_state'])
+nnodes = len(nodes)
+sys.stdout.write('Got ' +str(nnodes)+ 'nodes \n\n')
+f = open('nodes_booted', 'w')
+
+for node in nodes:
+ f.write(node.get('hostname') + '\n')
+
+f.close()
+sys.stdout.flush()
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r19351 - in gnunet-planetlab: . planetlab-api,
gnunet <=