adding support for geni_speaking_for option
[sfa.git] / sfa / managers / aggregate_manager.py
index c23ee95..36126c2 100644 (file)
@@ -1,6 +1,8 @@
 import socket
+import datetime
 from sfa.util.version import version_core
-from sfa.util.xrn import Xrn
+from sfa.util.xrn import Xrni
+from sfa.util.sfatime import utcpase, adjust_datetime
 from sfa.util.callids import Callids
 from sfa.server.api_versions import ApiVersions
 
@@ -11,7 +13,7 @@ class AggregateManager:
     # essentially a union of the core version, the generic version (this code) and
     # whatever the driver needs to expose
     def GetVersion(self, api, options):
-        xrn=Xrn(api.hrn, type='authority+am')
+        xrn=Xrn(api.hrn, type='authority+am')
         version = version_core()
         geni_api_versions = ApiVersions().get_versions()
         geni_api_versions['2'] = 'http://%s:%s' % (api.config.SFA_AGGREGATE_HOST, api.config.SFA_AGGREGATE_PORT)
@@ -22,6 +24,7 @@ class AggregateManager:
             'geni_api_versions': geni_api_versions, 
             'hrn':xrn.get_hrn(),
             'urn':xrn.get_urn(),
+            'geni_handles_speaksfor': True,     # supports 'speaks for' credentials  
             }
         version.update(version_generic)
         testbed_version = self.driver.aggregate_version()
@@ -87,6 +90,14 @@ class AggregateManager:
         xrn = Xrn(xrn, 'slice')
         slice_urn=xrn.get_urn()
         slice_hrn=xrn.get_hrn()
+
+        if options.get('geni_extend_alap'):
+            now = datetime.datetime.now()
+            requested = utcparse(expiration_time)
+            max = adjust_datetime(now, days=30)
+            if requested > max:
+                expiration_time = max
+     
         return self.driver.renew_sliver (slice_urn, slice_hrn, creds, expiration_time, options)
     
     ### these methods could use an options extension for at least call_id