use lease granularity as defined on the plc side
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 23 Jul 2010 12:46:38 +0000 (14:46 +0200)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 23 Jul 2010 12:46:38 +0000 (14:46 +0200)
system/TestPlc.py
system/config_default.py

index 1246fa1..546ba5d 100644 (file)
@@ -665,8 +665,8 @@ class TestPlc:
 
     YEAR = 365*24*3600
     @staticmethod
-    def translate_timestamp (start,timestamp):
-        if timestamp < TestPlc.YEAR:    return start+timestamp
+    def translate_timestamp (start,grain,timestamp):
+        if timestamp < TestPlc.YEAR:    return start+timestamp*grain
         else:                           return timestamp
 
     @staticmethod
@@ -677,8 +677,9 @@ class TestPlc:
         "create leases (on reservable nodes only, use e.g. run -c default -c resa)"
         now=int(time.time())
         grain=self.apiserver.GetLeaseGranularity(self.auth_root())
-        round_time=(now/grain)*grain
-        start=round_time+grain
+        print 'API answered grain=',grain
+        start=(now/grain)*grain
+        start += grain
         # find out all nodes that are reservable
         nodes=self.all_reservable_nodenames()
         if not nodes: 
@@ -690,8 +691,8 @@ class TestPlc:
         for lease_spec in self.plc_spec['leases']:
             # skip the ones that come with a null slice id
             if not lease_spec['slice']: continue
-            lease_spec['t_from']=TestPlc.translate_timestamp(start,lease_spec['t_from'])
-            lease_spec['t_until']=TestPlc.translate_timestamp(start,lease_spec['t_until'])
+            lease_spec['t_from']=TestPlc.translate_timestamp(start,grain,lease_spec['t_from'])
+            lease_spec['t_until']=TestPlc.translate_timestamp(start,grain,lease_spec['t_until'])
             lease_addition=self.apiserver.AddLeases(self.auth_root(),nodes,
                                                     lease_spec['slice'],lease_spec['t_from'],lease_spec['t_until'])
             if lease_addition['errors']:
index c776991..cc642dc 100644 (file)
@@ -7,8 +7,6 @@
 
 # values like 'hostname', 'ip' and the like are rewritten later with a TestPool object
 
-reservation_granularity=180
-
 def nodes(options,index):
     return [{'name':'node%d'%index,
              'node_fields': {'hostname': 'deferred-nodename%d'%index,
@@ -206,7 +204,7 @@ def tcp_tests (options,index):
         return []
 
 # the semantic for 't_from' and 't_until' here is:
-# if they are smaller than one year, they are relative to the current time
+# if they are smaller than one year, they are relative to the current time, expressed in grains
 # otherwise they are absolute
 def leases (options, index):
     leases=[]
@@ -215,8 +213,8 @@ def leases (options, index):
     slice_sequence = slices[:1] + slices + [None,]
     for iterator in range(12):
         for slice in slice_sequence:
-            leases.append ( {'slice' : slice, 't_from':counter,'t_until':counter+reservation_granularity} )
-            counter += reservation_granularity
+            leases.append ( {'slice' : slice, 't_from':counter,'t_until':counter+1} )
+            counter += 1
     return leases
 
 def plc (options,index) :
@@ -241,7 +239,7 @@ def plc (options,index) :
         'PLC_BOOT_HOST' : 'deferred-myplc-hostname',
         'PLC_NET_DNS1' : 'deferred-dns-1',
         'PLC_NET_DNS2' : 'deferred-dns-2',
-        'PLC_RESERVATION_GRANULARITY':reservation_granularity,
+        'PLC_RESERVATION_GRANULARITY':1800,
         'PLC_OMF_ENABLED' : 'false',
         'sites' : sites(options,index),
         'keys' : keys(options,index),