3 # this is designed to use a totally empty new directory
4 # so we demonstrate how to bootstrap the whole thing
6 # init logging on console
8 console = logging.StreamHandler()
9 logger=logging.getLogger('')
10 logger.addHandler(console)
11 logger.setLevel(logging.DEBUG)
13 # use sys.argv to point to a completely fresh directory
17 print "Usage: %s directory"%sys.argv[0]
20 logger.debug('sfaclientsample: Using directory %s'%dir)
24 # this uses a test vplc from the onelab test infrastructure
25 registry_url="http://vplc08.pl.sophia.inria.fr:12345/"
26 aggregate_url="http://vplc08.pl.sophia.inria.fr:12347/"
27 # this is where the private key sits - would be ~/.ssh/id_rsa in most cases
29 private_key="test_private_key"
31 hrn="pla.inri.fake-pi1"
33 from sfa.client.sfaclientlib import SfaClientBootstrap
35 bootstrap = SfaClientBootstrap (hrn, registry_url, dir=dir, logger=logger)
36 # install the private key in the client directory from 'private_key'
37 bootstrap.init_private_key_if_missing(private_key)
38 bootstrap.bootstrap_gid()
40 ### issue a GetVersion call
41 ### this assumes we've already somehow initialized the certificate
42 def get_version (url):
44 server_proxy = bootstrap.server_proxy(url)
45 retcod = server_proxy.GetVersion()
46 print "GetVersion at %s returned following keys: %s"%(url,retcod.keys())
49 # version_dict = {'type': 'SFA', 'version': '1', }
51 version_dict = {'type':'ProtoGENI', 'version':'2'}
53 # ditto with list resources
54 def list_resources ():
55 options = { 'geni_rspec_version' : version_dict}
56 credential = bootstrap.get_credential_string()
57 credentials = [ credential ]
58 retcod = bootstrap.server_proxy (aggregate_url).ListResources(credentials,options)
59 print "ListResources at %s returned : %20s..."%(aggregate_url,retcod)
62 get_version(registry_url)
63 get_version(aggregate_url)