Merge branch 'master' of ssh://git.onelab.eu/git/sfa
[sfa.git] / sfa / client / sfi.py
index b937feb..ae4d97a 100755 (executable)
@@ -4,6 +4,7 @@
 
 import sys
 sys.path.append('.')
+
 import os, os.path
 import tempfile
 import socket
@@ -13,21 +14,26 @@ import pickle
 from lxml import etree
 from StringIO import StringIO
 from optparse import OptionParser
-from sfa.client.client_helper import pg_users_arg, sfa_users_arg
-from sfa.util.sfalogging import sfi_logger
+
 from sfa.trust.certificate import Keypair, Certificate
 from sfa.trust.gid import GID
 from sfa.trust.credential import Credential
 from sfa.trust.sfaticket import SfaTicket
-from sfa.util.record import SfaRecord, UserRecord, SliceRecord, NodeRecord, AuthorityRecord
-from sfa.rspecs.rspec import RSpec
-from sfa.rspecs.rspec_converter import RSpecConverter
+
+from sfa.util.sfalogging import sfi_logger
 from sfa.util.xrn import get_leaf, get_authority, hrn_to_urn
-import sfa.client.xmlrpcprotocol as xmlrpcprotocol
 from sfa.util.config import Config
 from sfa.util.version import version_core
 from sfa.util.cache import Cache
+from sfa.util.record import SfaRecord, UserRecord, SliceRecord, NodeRecord, AuthorityRecord
+
+from sfa.rspecs.rspec import RSpec
+from sfa.rspecs.rspec_converter import RSpecConverter
 from sfa.rspecs.version_manager import VersionManager
+from sfa.client.return_value import ReturnValue
+
+import sfa.client.xmlrpcprotocol as xmlrpcprotocol
+from sfa.client.client_helper import pg_users_arg, sfa_users_arg
 
 AGGREGATE_PORT=12346
 CM_PORT=12346
@@ -419,13 +425,13 @@ class Sfi:
             version = cache.get(cache_key)
             
         if not version: 
-            version = server.GetVersion()
+            result = server.GetVersion()
+            version= ReturnValue.get_value(result)
             # cache version for 24 hours
             cache.add(cache_key, version, ttl= 60*60*24)
             self.logger.info("Updating cache file %s" % cache_file)
             cache.save_to_file(cache_file)
 
-
         return version   
         
 
@@ -912,7 +918,8 @@ class Sfi:
                 server=self.registry
             else:
                 server = self.server_proxy_from_opts(opts)
-            version=server.GetVersion()
+            result = server.GetVersion()
+            version = ReturnValue.get_value(result)
         for (k,v) in version.iteritems():
             print "%-20s: %s"%(k,v)
         if opts.file:
@@ -933,8 +940,9 @@ class Sfi:
         if self.server_supports_options_arg(server):
             options = {'call_id': unique_call_id()}
             call_args.append(options)
-        results = server.ListSlices(*call_args)
-        display_list(results)
+        result = server.ListSlices(*call_args)
+        value = ReturnValue.get_value(result)
+        display_list(value)
         return
     
     # show rspec for named slice
@@ -942,14 +950,18 @@ class Sfi:
         user_cred = self.get_user_cred().save_to_string(save_parents=True)
         server = self.slicemgr
         server = self.server_proxy_from_opts(opts)
+   
+        options = {'call_id': unique_call_id()}
+        #panos add info options
+        if opts.info:
+            options['info'] = opts.info
         
         if args:
             cred = self.get_slice_cred(args[0]).save_to_string(save_parents=True)
             hrn = args[0]
-           options = {'geni_slice_urn': hrn_to_urn(hrn, 'slice')}
+            options['geni_slice_urn'] = hrn_to_urn(hrn, 'slice')
         else:
             cred = user_cred
-            hrn = None
      
         creds = [cred]
         if opts.delegate:
@@ -965,19 +977,14 @@ class Sfi:
                 # this must be a protogeni aggregate. We should request a v2 ad rspec
                 # regardless of what the client user requested 
                 options['rspec_version'] = version_manager.get_version('ProtoGENI 2').to_dict()     
-        #panos add info options
-        if opts.info:
-            options['info'] = opts.info 
 
-        call_args = [creds]
-        if self.server_supports_options_arg(server):
-            options = {'call_id': unique_call_id()}
-            call_args.append(options)
+        call_args = [creds, options]
         result = server.ListResources(*call_args)
+        value = ReturnValue.get_value(result)
         if opts.file is None:
-            display_rspec(result, opts.format)
+            display_rspec(value, opts.format)
         else:
-            save_rspec_to_file(result, opts.file)
+            save_rspec_to_file(value, opts.file)
         return
 
     # created named slice with given rspec
@@ -1029,11 +1036,12 @@ class Sfi:
             options = {'call_id': unique_call_id()}
             call_args.append(options)
         result = server.CreateSliver(*call_args)
+        value = ReturnValue.get_value(result)
         if opts.file is None:
-            print result
+            print value
         else:
-            save_rspec_to_file (result, opts.file)
-        return result
+            save_rspec_to_file (value, opts.file)
+        return value
 
     # get a ticket for the specified slice
     def get_ticket(self, opts, args):
@@ -1155,7 +1163,9 @@ class Sfi:
         if self.server_supports_options_arg(server):
             options = {'call_id': unique_call_id()}
             call_args.append(options)
-        return server.RenewSliver(*call_args)
+        result =  server.RenewSliver(*call_args)
+        value = ReturnValue.get_value(result)
+        return value
 
 
     def status(self, opts, args):
@@ -1172,9 +1182,10 @@ class Sfi:
             options = {'call_id': unique_call_id()}
             call_args.append(options)
         result = server.SliverStatus(*call_args)
-        print result
+        value = ReturnValue.get_value(result)
+        print value
         if opts.file:
-            save_variable_to_file(result, opts.file, opts.fileformat)
+            save_variable_to_file(value, opts.file, opts.fileformat)
 
 
     def shutdown(self, opts, args):