added 'type' attribute to the pg rspec element
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Thu, 19 May 2011 15:27:53 +0000 (11:27 -0400)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Thu, 19 May 2011 15:27:53 +0000 (11:27 -0400)
sfa/managers/aggregate_manager_pl.py
sfa/plc/aggregate.py
sfa/rspecs/rspec.py

index 081695d..557e325 100644 (file)
@@ -323,7 +323,7 @@ def ListResources(api, creds, options,call_id):
 
     aggregate = Aggregate(api)
 
-    rspec =  aggregate.get_rspec(slice_xrn=xrn, version=rspec_version)
+    rspec =  aggregate.get_rspec(slice_xrn=xrn, version=rspec_version, type='advertisement')
 
     # cache the result
     if caching and api.cache and not xrn:
index afc20d4..505155f 100644 (file)
@@ -65,12 +65,12 @@ class Aggregate:
 
         self.prepared = True  
 
-    def get_rspec(self, slice_xrn=None, version = None):
+    def get_rspec(self, slice_xrn=None, version = None, type=None):
         self.prepare()
         rspec = None
         rspec_version = RSpecVersion(version)
         if rspec_version['type'].lower() == 'protogeni':
-            rspec = PGRSpec()
+            rspec = PGRSpec(type=type)
         elif rspec_version['type'].lower() == 'sfa':
             rspec = SfaRSpec()
         else:
index de7e250..2a331c1 100755 (executable)
@@ -16,13 +16,14 @@ class RSpec:
     version = None
     namespaces = None    
   
-    def __init__(self, rspec="", namespaces={}):
+    def __init__(self, rspec="", namespaces={}, type=None):
+        self.type = type
         if rspec:
             self.parse_rspec(rspec, namespaces)
         else:
             self.create()
 
-    def create(self, type="advertisement"):
+    def create(self):
         """
         Create root element
         """
@@ -34,6 +35,8 @@ class RSpec:
         self.parse_rspec(self.template, self.namespaces)
         self.xml.set('valid_until', expires_ts)
         self.xml.set('generated', generated_ts)
+        if self.type:
+            self.xml.set('type', self.type)
     
     def parse_rspec(self, rspec, namespaces={}):
         """