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
"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:
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']:
# 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,
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=[]
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) :
'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),