RSpecVersion.todict() needs to turn values() into a list()
[sfa.git] / sfa / examples / miniclient.py
index 616d613..535b446 100755 (executable)
@@ -3,6 +3,8 @@
 # this is designed to use a totally empty new directory
 # so we demonstrate how to bootstrap the whole thing
 
+from __future__ import print_function
+
 # init logging on console
 import logging
 console = logging.StreamHandler()
@@ -17,7 +19,7 @@ def unique_call_id(): return uuid.uuid4().urn
 import sys
 args=sys.argv[1:]
 if len(args)!=1:
-    print "Usage: %s directory"%sys.argv[0]
+    print("Usage: %s directory"%sys.argv[0])
     sys.exit(1)
 dir=args[0]
 logger.debug('sfaclientsample: Using directory %s'%dir)
@@ -54,9 +56,6 @@ def truncate(content, length=20, suffix='...'):
     else:
         return content[:length+1]+ ' '+suffix
 
-def has_call_id (server_version):
-    return server_version.has_key('call_id_support')
-
 
 ### issue a GetVersion call
 ### this assumes we've already somehow initialized the certificate
@@ -65,9 +64,8 @@ def get_version (url):
     bootstrap.self_signed_cert()
     server_proxy = bootstrap.server_proxy_simple(url)
     server_version = server_proxy.GetVersion()
-    print "miniclient: GetVersion at %s returned:"%(url)
-    for (k,v) in server_version.iteritems(): print "miniclient: \tversion[%s]=%s"%(k,truncate(v))
-    print "has-call-id=",has_call_id(server_version)
+    print("miniclient: GetVersion at %s returned:"%(url))
+    for (k,v) in server_version.iteritems(): print("miniclient: \tversion[%s]=%s"%(k,truncate(v)))
 
 # version_dict = {'type': 'SFA', 'version': '1', }
 
@@ -81,9 +79,9 @@ def list_resources ():
     credentials = [ credential ]
     options = {}
     options [ 'geni_rspec_version' ] = version_dict
-#    options [ 'call_id' ] = unique_call_id()
+    options [ 'call_id' ] = unique_call_id()
     list_resources = bootstrap.server_proxy (aggregate_url).ListResources(credentials,options)
-    print "miniclient: ListResources at %s returned : %s"%(aggregate_url,truncate(list_resources))
+    print("miniclient: ListResources at %s returned : %s"%(aggregate_url,truncate(list_resources)))
 
 def list_slice_resources ():
     bootstrap.bootstrap_my_gid()
@@ -92,17 +90,16 @@ def list_slice_resources ():
     options = { }
     options [ 'geni_rspec_version' ] = version_dict
     options [ 'geni_slice_urn' ] = slice_urn
-#    options [ 'call_id' ] = unique_call_id()
+    options [ 'call_id' ] = unique_call_id()
     list_resources = bootstrap.server_proxy (aggregate_url).ListResources(credentials,options)
-    print "miniclient: ListResources at %s for slice %s returned : %s"%(aggregate_url,slice_urn,truncate(list_resources))
-    
+    print("miniclient: ListResources at %s for slice %s returned : %s"%(aggregate_url,slice_urn,truncate(list_resources)))
     
     
 
 def main ():
     get_version(registry_url)
     get_version(aggregate_url)
-#    list_resources()
-#    list_slice_resources()
+    list_resources()
+    list_slice_resources()
 
 main()