for reservable nodes - granularity still hardwired in PLC/Leases
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Wed, 9 Jun 2010 17:57:53 +0000 (17:57 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Wed, 9 Jun 2010 17:57:53 +0000 (17:57 +0000)
PLC/Leases.py
PLC/Methods/GetLeaseGranularity.py [new file with mode: 0644]
PLC/Methods/GetSlivers.py
PLC/Methods/__init__.py

index ebe2752..2f7d493 100644 (file)
@@ -48,8 +48,8 @@ class Lease(Row):
 
     # leases do not have arbitrary boundaries
     # f_from and t_until are rounded to this period of time
-    # initial model is one hour
-    granularity = 60*60
+    # initial model is 15 minutes
+#    granularity = 15*60    granularity = 5*60
 
     def validate_time (self, timestamp, round_up):
         # convert to long
diff --git a/PLC/Methods/GetLeaseGranularity.py b/PLC/Methods/GetLeaseGranularity.py
new file mode 100644 (file)
index 0000000..383ee8c
--- /dev/null
@@ -0,0 +1,25 @@
+# $Id$
+# $URL$
+from PLC.Method import Method
+from PLC.Auth import Auth
+from PLC.Faults import *
+from PLC.Parameter import Parameter
+from PLC.Leases import Lease
+
+class GetLeaseGranularity(Method):
+    """
+    Returns the granularity in seconds for the reservation system
+    """
+
+    roles = ['admin', 'pi', 'user', 'tech', 'node', 'anonymous']
+
+    accepts = [
+        Auth(),
+        ]
+
+    # for now only return /etc/myplc-release verbatim
+    returns = Parameter (int, "the granularity in seconds for the reservation system")
+
+    def call(self, auth):
+
+        return Lease.granularity
index ec1e83e..9f86615 100644 (file)
@@ -324,6 +324,7 @@ class GetSlivers(Method):
                                                    'clip': (timestamp, timestamp+24*Duration.HOUR),
                                                    '-SORT': 't_from',
                                                    }) ]
+        granularity=Lease.granularity
 
         return {
             'timestamp': timestamp,
@@ -339,4 +340,5 @@ class GetSlivers(Method):
             'hrn':hrn,
             'reservation_policy': reservation_policy,
             'leases':leases,
+            'lease_granularity': granularity,
             }
index 3f95fce..f2c24ea 100644 (file)
@@ -103,6 +103,7 @@ GetInterfaceTags
 GetInterfaces
 GetKeyTypes
 GetKeys
+GetLeaseGranularity
 GetLeases
 GetMessages
 GetNetworkMethods