From b3136dfd5c09b0b7e411df27458d731f726bea44 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Wed, 9 Jun 2010 17:57:53 +0000 Subject: [PATCH 1/1] for reservable nodes - granularity still hardwired in PLC/Leases --- PLC/Leases.py | 4 ++-- PLC/Methods/GetLeaseGranularity.py | 25 +++++++++++++++++++++++++ PLC/Methods/GetSlivers.py | 2 ++ PLC/Methods/__init__.py | 1 + 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 PLC/Methods/GetLeaseGranularity.py diff --git a/PLC/Leases.py b/PLC/Leases.py index ebe2752..2f7d493 100644 --- a/PLC/Leases.py +++ b/PLC/Leases.py @@ -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 index 0000000..383ee8c --- /dev/null +++ b/PLC/Methods/GetLeaseGranularity.py @@ -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 diff --git a/PLC/Methods/GetSlivers.py b/PLC/Methods/GetSlivers.py index ec1e83e..9f86615 100644 --- a/PLC/Methods/GetSlivers.py +++ b/PLC/Methods/GetSlivers.py @@ -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, } diff --git a/PLC/Methods/__init__.py b/PLC/Methods/__init__.py index 3f95fce..f2c24ea 100644 --- a/PLC/Methods/__init__.py +++ b/PLC/Methods/__init__.py @@ -103,6 +103,7 @@ GetInterfaceTags GetInterfaces GetKeyTypes GetKeys +GetLeaseGranularity GetLeases GetMessages GetNetworkMethods -- 2.43.0