def next_free (self):
for i in self.pool:
- if i.status in ['busy','mine','starting' ]: continue
- i.status='mine'
- return (i.hostname,i.userdata)
+ if i.status == 'free':
+ i.status='mine'
+ return (i.hostname,i.userdata)
raise Exception,"No IP address available in pool %s"%self.message
-# OS-dependent ping option (support for macos, for convenience)
+ # OS-dependent ping option (support for macos, for convenience)
ping_timeout_option = None
-# checks whether a given hostname/ip responds to ping
+ # checks whether a given hostname/ip responds to ping
def check_ping (self,hostname):
if not Pool.ping_timeout_option:
(status,osname) = commands.getstatusoutput("uname -s")
return status == 0
# the place were other test instances tell about their not-yet-started
- # instances
+ # instances, that go undetected through sensing
starting='/root/starting'
def add_starting (self, name):
try: items=[line.strip() for line in file(Pool.starting).readlines()]
except: items=[]
for item in items:
for i in self.pool:
- if i.hostname==item: i.status='starting'
+ if i.hostname==item and i.status==None: i.status='starting'
- def release_my_fakes (self):
+ def release_my_starting (self):
for i in self.pool:
- print 'releasing-scanning','hostname',i.hostname,'status',i.status
if i.status=='mine':
self.del_starting(i.hostname)
i.status=None
if item != name: f.write(item+'\n')
f.close()
-
-
####################
class Box:
def __init__ (self,hostname):
# print self.margin_outline(self.vplcname(longname)),"%(vserver_line)s [=%(longname)s]"%locals()
# scan timestamps
+ running_ctx_ids = [ i.ctxid for i in self.plc_instances ]
command= ['grep','.']
- command += ['/vservers/%s/timestamp'%b for b in ctx_dict.values()]
+ command += ['/vservers/%s/timestamp'%b for b in running_ctx_ids]
command += ['/dev/null']
ts_lines=self.backquote_ssh(command,trash_err=True).split('\n')
for ts_line in ts_lines:
q=self.plc_instance_by_vservername(vservername)
if not q:
print 'WARNING unattached plc instance',ts_line
+ print 'was expeting to find',vservername,'in',[i.vservername for i in self.plc_instances]
continue
q.set_timestamp(timestamp)
except: print 'WARNING, could not parse ts line',ts_line
self.vplc_pool = Pool (self.vplc_ips(),"for vplcs")
self.vnode_pool = Pool (self.vnode_ips(),"for vnodes")
- self.vnode_pool.list()
-
-
# def build_box_names (self):
# return [ h for h in self.build_boxes_spec() ]
# def plc_boxes (self):
if options.ips_vplc:
vplc_hostname=options.ips_vplc.pop()
else:
- self.vplc_pool.load_starting()
self.vplc_pool.sense()
+ self.vplc_pool.load_starting()
(vplc_hostname,unused)=self.vplc_pool.next_free()
vplc_ip = self.vplc_pool.get_ip(vplc_hostname)
self.vplc_pool.add_starting(vplc_hostname)
#### apply in the plc_spec
# # informative
# label=options.personality.replace("linux","")
- mapper = {'plc': [ ('*' , {'hostname':plc_box.hostname,
+ mapper = {'plc': [ ('*' , {'host_box':plc_box.hostname,
# 'name':'%s-'+label,
'name': plc_name,
'vservername':vservername,
if options.ips_vnode:
vnode_hostname=options.ips_vnode.pop()
mac=self.vnode_pool.retrieve_userdata(vnode_hostname)
- print 'case 1 hostname',vnode_hostname,'mac',mac
else:
- self.vnode_pool.load_starting()
self.vnode_pool.sense()
+ self.vnode_pool.load_starting()
(vnode_hostname,mac)=self.vnode_pool.next_free()
- print 'case 2 hostname',vnode_hostname,'mac',mac
ip=self.vnode_pool.get_ip (vnode_hostname)
self.vnode_pool.add_starting(vnode_hostname)
#################### release:
def release (self,options):
- self.vplc_pool.release_my_fakes()
- self.vnode_pool.release_my_fakes()
+ self.vplc_pool.release_my_starting()
+ self.vnode_pool.release_my_starting()
pass
#################### show results for interactive mode