gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r19352 - gnunet-planetlab/planetlab-api


From: gnunet
Subject: [GNUnet-SVN] r19352 - gnunet-planetlab/planetlab-api
Date: Tue, 24 Jan 2012 18:56:26 +0100

Author: wachs
Date: 2012-01-24 18:56:26 +0100 (Tue, 24 Jan 2012)
New Revision: 19352

Added:
   gnunet-planetlab/planetlab-api/addnodes.py
Modified:
   gnunet-planetlab/planetlab-api/getnodes.py
Log:
script to add all booted nodes to the slice


Added: gnunet-planetlab/planetlab-api/addnodes.py
===================================================================
--- gnunet-planetlab/planetlab-api/addnodes.py                          (rev 0)
+++ gnunet-planetlab/planetlab-api/addnodes.py  2012-01-24 17:56:26 UTC (rev 
19352)
@@ -0,0 +1,67 @@
+
+
+'''
+Created on Jan 24, 2012
+Good information:
+http://www.planet-lab.org/doc/plc_api
+http://www.planet-lab.org/doc/plcapitut
address@hidden: mwachs
+'''
+
+#!/usr/bin/python
+import sys, os, urllib, xmlrpclib, socket
+
+user = ''
+password = ''
+slice = ''
+
+arg = sys.argv
+size = len(arg)
+if (len(arg) < 6):
+    print 'usage: -u <username> -p <password> -s <slice>'
+    exit()
+
+if (arg[1] == '-u'):
+    user = arg[2]
+if (arg[3] == '-p'):
+    password = arg[4]
+if (arg[5] == '-s'):
+    slice = arg[6]
+
+# 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()
+
+node_str = []
+
+# 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')
+
+for node in nodes:
+    node_str.append(node.get('hostname'))
+    
+res =server.AddSliceToNodes(auth,slice,node_str)
+
+if (res == 1):
+    print 'Added ' +str(nnodes)+ ' to slice ' + slice      
+sys.stdout.flush()
+

Modified: gnunet-planetlab/planetlab-api/getnodes.py
===================================================================
--- gnunet-planetlab/planetlab-api/getnodes.py  2012-01-24 17:39:44 UTC (rev 
19351)
+++ gnunet-planetlab/planetlab-api/getnodes.py  2012-01-24 17:56:26 UTC (rev 
19352)
@@ -1,6 +1,8 @@
 '''
 Created on Jan 24, 2012
-
+Good information:
+http://www.planet-lab.org/doc/plc_api
+http://www.planet-lab.org/doc/plcapitut
 @author: mwachs
 '''
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]