- tocheck = self.all_hostnames()
- utils.header("checking nodes %r"%tocheck)
- # create a dict hostname -> status
- status = dict ( [ (hostname,'undef') for hostname in tocheck ] )
- while tocheck:
- # get their status
- tocheck_status=self.apiserver.GetNodes(self.auth_root(), tocheck, ['hostname','boot_state' ] )
- # update status
- for array in tocheck_status:
- hostname=array['hostname']
- boot_state=array['boot_state']
- if boot_state == target_boot_state:
- utils.header ("%s has reached the %s state"%(hostname,target_boot_state))
- else:
- # if it's a real node, never mind
- (site_spec,node_spec)=self.locate_hostname(hostname)
- if TestNode.is_real_model(node_spec['node_fields']['model']):
- utils.header("WARNING - Real node %s in %s - ignored"%(hostname,boot_state))
- # let's cheat
- boot_state = target_boot_state
- elif datetime.datetime.now() > graceout:
- utils.header ("%s still in '%s' state"%(hostname,boot_state))
- graceout=datetime.datetime.now()+datetime.timedelta(1)
- status[hostname] = boot_state
- # refresh tocheck
- tocheck = [ hostname for (hostname,boot_state) in status.iteritems() if boot_state != target_boot_state ]
- if not tocheck:
- return True
- if datetime.datetime.now() > timeout:
- for hostname in tocheck:
- utils.header("FAILURE due to %s in '%s' state"%(hostname,status[hostname]))
- return False
- # otherwise, sleep for a while
- time.sleep(period)
- # only useful in empty plcs
- return True
+ utils.header("checking nodes boot state (expected %s)"%target_boot_state)
+ tasks = [ CompleterTaskBootState (self,hostname) \
+ for (hostname,_) in self.all_node_infos() ]
+ return Completer (tasks).run (timeout, graceout, period)