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 sfa deployment at openlab
25 registry_url="http://sfa1.pl.sophia.inria.fr:12345/"
26 aggregate_url="http://sfa1.pl.sophia.inria.fr:12347/"
27 # this is where the private key sits - would be ~/.ssh/id_rsa in most cases
28 # but in this context, create this local file
29 # the tests key pair can be found in
30 # http://git.onelab.eu/?p=tests.git;a=blob;f=system/config_default.py
31 # search for public_key / private_key
32 private_key="miniclient-private-key"
34 hrn="pla.inri.fake-pi1"
36 from sfa.client.sfaclientlib import SfaClientBootstrap
38 bootstrap = SfaClientBootstrap (hrn, registry_url, dir=dir, logger=logger)
39 # install the private key in the client directory from 'private_key'
40 bootstrap.init_private_key_if_missing(private_key)
41 bootstrap.bootstrap_gid()
43 ### issue a GetVersion call
44 ### this assumes we've already somehow initialized the certificate
45 def get_version (url):
47 server_proxy = bootstrap.server_proxy(url)
48 retcod = server_proxy.GetVersion()
49 print "GetVersion at %s returned following keys: %s"%(url,retcod.keys())
52 # version_dict = {'type': 'SFA', 'version': '1', }
54 version_dict = {'type':'ProtoGENI', 'version':'2'}
56 # ditto with list resources
57 def list_resources ():
58 options = { 'geni_rspec_version' : version_dict}
59 credential = bootstrap.get_credential_string()
60 credentials = [ credential ]
61 retcod = bootstrap.server_proxy (aggregate_url).ListResources(credentials,options)
62 print "ListResources at %s returned : %20s..."%(aggregate_url,retcod)
65 get_version(registry_url)
66 get_version(aggregate_url)