From 9ea3caa50c8d3e5137619b2147bf959cc8780e06 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Thu, 6 May 2010 19:25:58 +0000 Subject: [PATCH] expose leases to nodes --- PLC/Methods/GetSlivers.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/PLC/Methods/GetSlivers.py b/PLC/Methods/GetSlivers.py index 98fd4256..25cdbcac 100644 --- a/PLC/Methods/GetSlivers.py +++ b/PLC/Methods/GetSlivers.py @@ -18,6 +18,8 @@ from PLC.Roles import Roles from PLC.Keys import Key, Keys from PLC.SliceTags import SliceTag, SliceTags from PLC.InitScripts import InitScript, InitScripts +from PLC.Leases import Lease, Leases +from PLC.Timestamp import Duration from PLC.Methods.GetSliceFamily import GetSliceFamily from PLC.Accessors.Accessors_standard import * @@ -173,6 +175,10 @@ class GetSlivers(Method): 'user':Parameter(str,"username for the XMPP server"), 'password':Parameter(str,"username for the XMPP server"), }, + 'leases': [ { 'slice_id' : Lease.fields['slice_id'], + 't_from' : Lease.fields['t_from'], + 't_until' : Lease.fields['t_until'], + }], } def call(self, auth, node_id_or_hostname = None): @@ -298,6 +304,15 @@ class GetSlivers(Method): node.update_last_contact() + # expose leases + lease_exposed_fields = [ 'slice_id', 't_from', 't_until', ] + leases=None + if node['node_type'] == 'reservable': + # expose the leases for the next 12 hours + leases = [ dict ( [ (k,l[k]) for k in lease_exposed_fields ] ) + for l in Leases (self.api, {'node_id':node['node_id'], + 'clip': (timestamp, timestamp+12*Duration.HOUR)}) ] + return { 'timestamp': timestamp, 'node_id': node['node_id'], @@ -310,4 +325,5 @@ class GetSlivers(Method): 'accounts': accounts, 'xmpp':xmpp, 'hrn':hrn, + 'leases':leases, } -- 2.47.0