support GENI v2 API 'options' argument for all Aggregate API methods
[sfa.git] / sfa / managers / aggregate_manager_eucalyptus.py
index 4d73ab1..ff2428c 100644 (file)
@@ -15,20 +15,19 @@ from xmlbuilder import XMLBuilder
 from lxml import etree as ET
 from sqlobject import *
 
-from sfa.util.faults import InvalidRSpec, 
+from sfa.util.faults import InvalidRSpec 
 from sfa.util.xrn import urn_to_hrn, Xrn
 from sfa.util.plxrn import hrn_to_pl_slicename, slicename_to_hrn
 from sfa.util.callids import Callids
 #comes with its own logging
 #from sfa.util.sfalogging import logger
 from sfa.util.version import version_core
-
 from sfa.trust.credential import Credential
-
 from sfa.server.sfaapi import SfaApi
-
 from sfa.plc.aggregate import Aggregate
 from sfa.plc.slices import Slice, Slices
+from sfa.rspecs.version_manager import VersionManager
+from sfa.rspecs.rspec import RSpec
 # not sure what this used to be nor where it is now defined
 #from sfa.rspecs.sfa_rspec import sfa_rspec_version
 
@@ -445,7 +444,8 @@ class AggregateManagerEucalyptus:
                                 port=eucaPort,
                                 path=srvPath)
     
-    def ListResources(api, creds, options, call_id): 
+    def ListResources(api, creds, options={}):
+        call_id = options.get('call_id') 
         if Callids().already_handled(call_id): return ""
         # get slice's hrn from options
         xrn = options.get('geni_slice_urn', '')
@@ -541,7 +541,8 @@ class AggregateManagerEucalyptus:
     """
     Hook called via 'sfi.py create'
     """
-    def CreateSliver(api, slice_xrn, creds, xml, users, call_id):
+    def CreateSliver(api, slice_xrn, creds, xml, users, options={}):
+        call_id = options.get('call_id') 
         if Callids().already_handled(call_id): return ""
     
         logger = logging.getLogger('EucaAggregate')
@@ -678,16 +679,23 @@ class AggregateManagerEucalyptus:
             f.write("%s %s %s\n" % (instId, ipaddr, hrn))
         f.close()
     
-    def GetVersion(api):
+    def GetVersion(api, options={}):
+
+        version_manager = VersionManager()
+        ad_rspec_versions = []
+        request_rspec_versions = []
+        for rspec_version in version_manager.versions:
+            if rspec_version.content_type in ['*', 'ad']:
+                ad_rspec_versions.append(rspec_version.to_dict())
+            if rspec_version.content_type in ['*', 'request']:
+                request_rspec_versions.append(rspec_version.to_dict())
+        default_rspec_version = version_manager.get_version("sfa 1").to_dict()
         xrn=Xrn(api.hrn)
-        request_rspec_versions = [dict(sfa_rspec_version)]
-        ad_rspec_versions = [dict(sfa_rspec_version)]
         version_more = {'interface':'aggregate',
                         'testbed':'myplc',
                         'hrn':xrn.get_hrn(),
                         'request_rspec_versions': request_rspec_versions,
                         'ad_rspec_versions': ad_rspec_versions,
-                        'default_ad_rspec': dict(sfa_rspec_version)
+                        'default_ad_rspec': default_rspec_version
                         }
         return version_core(version_more)
-