fix pg rspec versions
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Fri, 20 May 2011 14:12:48 +0000 (10:12 -0400)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Fri, 20 May 2011 14:12:48 +0000 (10:12 -0400)
sfa/managers/aggregate_manager_pl.py
sfa/managers/slice_manager_pl.py
sfa/rspecs/pg_rspec.py

index 557e325..c916c51 100644 (file)
@@ -26,20 +26,20 @@ from sfa.plc.slices import *
 from sfa.util.version import version_core
 from sfa.rspecs.rspec_version import RSpecVersion
 from sfa.rspecs.sfa_rspec import sfa_rspec_version
-from sfa.rspecs.pg_rspec import pg_rspec_version
+from sfa.rspecs.pg_rspec import pg_rspec_ad_version, pg_rspec_request_version
 from sfa.rspecs.rspec_parser import parse_rspec 
 from sfa.util.sfatime import utcparse
 from sfa.util.callids import Callids
 
 def GetVersion(api):
     xrn=Xrn(api.hrn)
-
-    supported_rspecs = [dict(pg_rspec_version), dict(sfa_rspec_version)]
+    request_rspec_versions = [dict(pg_rspec_request_version), dict(sfa_rspec_version)]
+    ad_rspec_versions = [dict(pg_rspec_ad_version), dict(sfa_rspec_version)]
     version_more = {'interface':'aggregate',
                     'testbed':'myplc',
                     'hrn':xrn.get_hrn(),
-                    'request_rspec_versions': supported_rspecs,
-                    'ad_rspec_versions': supported_rspecs,
+                    'request_rspec_versions': request_rspec_versions,
+                    'ad_rspec_versions': ad_rspec_versions,
                     'default_ad_rspec': dict(sfa_rspec_version)
                     }
     return version_core(version_more)
@@ -210,7 +210,7 @@ def CreateSliver(api, slice_xrn, creds, rspec_string, users, call_id):
             api.plshell.BindObjectToPeer(api.plauth, 'slice', slice.id, peer, 
                                          slice.peer_id)
 
-    return aggregate.get_rspec(slice_xrn=slice_xrn, version=rspec.version)
+    return aggregate.get_rspec(slice_xrn=slice_xrn, version=rspec.version, type='advertisement')
 
 
 def RenewSliver(api, xrn, creds, expiration_time, call_id):
@@ -283,8 +283,8 @@ def DeleteSliver(api, xrn, creds, call_id):
     return 1
 
 # xxx Thierry : caching at the aggregate level sounds wrong...
-caching=True
-#caching=False
+#caching=True
+caching=False
 def ListSlices(api, creds, call_id):
     if Callids().already_handled(call_id): return []
     # look in cache first
@@ -313,6 +313,12 @@ def ListResources(api, creds, options,call_id):
     # get the rspec's return format from options
     rspec_version = RSpecVersion(options.get('rspec_version'))
     version_string = "rspec_%s" % (rspec_version.get_version_name())
+
+    #panos adding the info option to the caching key (can be improved)
+    if options.get('info'):
+       version_string = version_string + "_"+options.get('info')
+
+    print "[aggregate] version string = ",version_string
     
     # look in cache first
     if caching and api.cache and not xrn:
@@ -321,9 +327,12 @@ def ListResources(api, creds, options,call_id):
             api.logger.info("aggregate.ListResources: returning cached value for hrn %s"%hrn)
             return rspec 
 
-    aggregate = Aggregate(api)
+    #aggregate = Aggregate(api)
+    #panos: passing user-defined options
+    #print "manager options = ",options
+    aggregate = Aggregate(api, options)
 
-    rspec =  aggregate.get_rspec(slice_xrn=xrn, version=rspec_version, type='advertisement')
+    rspec =  aggregate.get_rspec(slice_xrn=xrn, version=rspec_version)
 
     # cache the result
     if caching and api.cache and not xrn:
index 13124d7..c1a8c31 100644 (file)
@@ -21,7 +21,7 @@ from sfa.rspecs.rspec_converter import RSpecConverter
 from sfa.rspecs.rspec_parser import parse_rspec    
 from sfa.rspecs.rspec_version import RSpecVersion
 from sfa.rspecs.sfa_rspec import sfa_rspec_version
-from sfa.rspecs.pg_rspec import pg_rspec_version    
+from sfa.rspecs.pg_rspec import pg_rspec_ad_version, pg_rspec_request_version   
 from sfa.util.policy import Policy
 from sfa.util.prefixTree import prefixTree
 from sfa.util.sfaticket import *
@@ -46,13 +46,14 @@ def GetVersion(api):
     peers =dict ([ (peername,get_serverproxy_url(v)) for (peername,v) in api.aggregates.iteritems() 
                    if peername != api.hrn])
     xrn=Xrn (api.hrn)
-    supported_rspecs = [dict(pg_rspec_version), dict(sfa_rspec_version)]
+    request_rspec_versions = [dict(pg_rspec_request_version), dict(sfa_rspec_version)]
+    ad_rspec_versions = [dict(pg_rspec_ad_version), dict(sfa_rspec_version)]
     version_more = {'interface':'slicemgr',
                     'hrn' : xrn.get_hrn(),
                     'urn' : xrn.get_urn(),
                     'peers': peers,
-                    'request_rspec_versions': supported_rspecs,
-                    'ad_rspec_versions': supported_rspecs,
+                    'request_rspec_versions': request_rspec_versions,
+                    'ad_rspec_versions': ad_rspec_versions,
                     'default_ad_rspec': dict(sfa_rspec_version)
                     }
     sm_version=version_core(version_more)
index b60041a..c95c07b 100755 (executable)
@@ -33,18 +33,21 @@ class PGRSpec(RSpec):
     xml = None
     header = '<?xml version="1.0"?>\n'
     template = """<rspec xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.protogeni.net/resources/rspec/2" xsi:schemaLocation="http://www.protogeni.net/resources/rspec/2 http://www.protogeni.net/resources/rspec/2/%(rspec_type)s.xsd"></rspec>"""
-    version = pg_rspec_version
-    namespaces = {'rspecv2': version['namespace']}
 
     def __init__(self, rspec="", namespaces={}, type=None):
         self.type = type
         if not type or type == 'advertisement':
-            version = pg_rspec_ad_version
+            self.version = pg_rspec_ad_version
         else:
-            version = pg_rspec_request_version  
-       
+            self.version = pg_rspec_request_version  
+
+        if not namespaces:
+            self.namespaces = {'rspecv2': self.version['namespace']}
+        else:
+            self.namespaces = namespaces 
+
         if rspec:
-            self.parse_rspec(rspec, namespaces)
+            self.parse_rspec(rspec, self.namespaces)
         else: 
             self.create()