added the -c --current command line argument for ListResources which allows clients...
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Fri, 16 Dec 2011 18:49:10 +0000 (13:49 -0500)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Fri, 16 Dec 2011 18:49:16 +0000 (13:49 -0500)
sfa/client/sfi.py
sfa/managers/slice_manager.py

index 73d0099..83cd9bf 100644 (file)
@@ -255,8 +255,6 @@ class Sfi:
         # user specifies remote aggregate/sm/component                          
         if command in ("resources", "slices", "create", "delete", "start", "stop", 
                        "restart", "shutdown",  "get_ticket", "renew", "status"):
-            parser.add_option("-c", "--component", dest="component", default=None,
-                             help="component hrn")
             parser.add_option("-d", "--delegate", dest="delegate", default=None, 
                              action="store_true",
                              help="Include a credential delegated to the user's root"+\
@@ -268,10 +266,15 @@ class Sfi:
                             help="type filter ([all]|user|slice|authority|node|aggregate)",
                             choices=("all", "user", "slice", "authority", "node", "aggregate"),
                             default="all")
-        # display formats
         if command in ("resources"):
+            # rspec version
             parser.add_option("-r", "--rspec-version", dest="rspec_version", default="SFA 1",
                               help="schema type and version of resulting RSpec")
+            # disable/enable cached rspecs
+            parser.add_option("-c", "--current", dest="current", default=False,
+                              action="store_true",  
+                              help="Request the current rspec bypassing the cache. Cached rspecs are returned by default")
+            # display formats
             parser.add_option("-f", "--format", dest="format", type="choice",
                              help="display format ([xml]|dns|ip)", default="xml",
                              choices=("xml", "dns", "ip"))
@@ -828,6 +831,11 @@ or with an slice hrn, shows currently provisioned resources
             api_options['geni_slice_urn'] = hrn_to_urn(hrn, 'slice')
         if options.info:
             api_options['info'] = options.info
+        if options.current:
+            if options.current == True:
+                api_options['cached'] = False
+            else:
+                api_options['cached'] = True
         if options.rspec_version:
             version_manager = VersionManager()
             server_version = self.get_cached_server_version(server)
index be6cc7e..e22ec50 100644 (file)
@@ -131,7 +131,8 @@ class SliceManager:
         version_string = "rspec_%s" % (rspec_version)
     
         # look in cache first
-        if self.cache and not xrn:
+        cached_requested = options.get('cached', True)
+        if not xrn and self.cache and cached_request:
             rspec =  self.cache.get(version_string)
             if rspec:
                 api.logger.debug("SliceManager.ListResources returns cached advertisement")