####################
-########## make sync TESTMASTER=hostname BUILDNAME=vservername
-ifdef TESTMASTER
-ifdef BUILDNAME
-PLCSSH:=root@$(TESTMASTER):$(BUILDNAME)
-endif
+TESTMASTER ?= testmaster.onelab.eu
+
+########## make sync TESTMASTER=hostname BUILD=vservername
+ifdef BUILD
+PLCSSH:=root@$(TESTMASTER):$(BUILD)
endif
LOCAL_RSYNC_EXCLUDES := --exclude '*.pyc' --exclude 'arg*'
sync:
ifeq (,$(PLCSSH))
- echo "sync: You must define TESTMASTER and BUILDNAME on the command line"
- echo " e.g. make sync TESTMASTER=testmaster.onelab.eu BUILDNAME=2009.07.10--1l-f8-32" ; exit 1
+ echo "sync: You must define TESTMASTER and BUILD on the command line"
+ echo " e.g. make sync TESTMASTER=testmaster.onelab.eu BUILD=2009.07.10--1l-f8-32" ; exit 1
else
+$(RSYNC) ./ $(PLCSSH)
endif
self.message=message
# let's be flexible
- def locate_entry (self, hostname_or_ip, busy=True):
+ def match (self,triple,hostname_or_ip):
+ (h,i,u)=triple
+ return h.find(hostname_or_ip)>=0 or (i and i.find(hostname_or_ip)>=0)
+
+ def locate_entry (self, hostname_or_ip):
for (h,i,u) in self.pool:
- if h.find(hostname_or_ip)>=0 or (i and i.find(hostname_or_ip)>=0) :
- if busy:
- self.busy.append(h)
+ if self.match ( (h,i,u,), hostname_or_ip):
+ self.busy.append(h)
return (h,i,u)
- print '* TestPool.locate_entry: Could not locate entry for',hostname_or_ip
- print '* in pool:'
- for (h,i,u) in self.pool:
- print "* \t",i,"\t",h
+ utils.header('TestPool.locate_entry: Could not locate entry for %r in pool:'%hostname_or_ip)
return None
- def next_free (self):
+ # the hostnames provided (from a tracker) are considered last
+ def next_free (self, tracker_hostnames):
if self.options.quiet:
print 'TestPool is looking for a %s'%self.message,
- for (hostname,ip,user_data) in self.pool:
+ # create 2 lists of (h,i,u) entries, the ones not in the tracker, and the ones in the tracker
+ in_track_pool=[]
+ out_track_pool=[]
+ for (h,i,u) in self.pool:
+ in_tracker=False
+ for hostname in tracker_hostnames:
+ if self.match ( (h,i,u,) , hostname) : in_tracker = True
+ if in_tracker: in_track_pool.append ( (h,i,u,) )
+ else: out_track_pool.append ( (h,i,u,) )
+ # consider outsiders first
+ for (hostname,ip,user_data) in out_track_pool + in_track_pool:
+ utils.header ('* candidate %s' % hostname)
+ for (hostname,ip,user_data) in out_track_pool + in_track_pool:
if hostname in self.busy:
continue
if not self.options.quiet:
plcs = self.localize_qemus(plcs,options)
except Exception, e:
print '* Could not localize qemus','--',e,'--','exiting'
+ import traceback
+ traceback.print_exc()
sys.exit(1)
try:
plcs = self.localize_nodes(plcs,options)
ip_or_hostname=options.ips_qemu.pop()
(hostname,ip,unused)=qemu_pool.locate_entry(ip_or_hostname)
else:
- (hostname,ip,unused) = qemu_pool.next_free()
+ tracker=TrackerQemu(options,instances=self.max_qemus()-1)
+ (hostname,ip,unused) = qemu_pool.next_free(tracker.hostnames())
node_map += [ ('node%d'%index, {'host_box':hostname},) ]
print 'debug','in',ip_or_hostname,'out',ip_pool.locate_entry(ip_or_hostname)
(hostname,ip,mac)=ip_pool.locate_entry(ip_or_hostname)
else:
- (hostname,ip,mac) = ip_pool.next_free()
+ tracker=TrackerQemu(options,instances=self.max_qemus()-1)
+ (hostname,ip,mac) = ip_pool.next_free(tracker.nodenames())
utils.header('Attaching node %s to %s (%s)'%(nodename,hostname,ip))
node_dict= {'node_fields:hostname':hostname,
'interface_fields:ip':ip,
utils.header("Using user-provided %s %s for plc %s"%(
hostname,ip_or_hostname,plc['name']))
else:
- (hostname,ip,mac)=ip_pool.next_free()
+ tracker = TrackerPlc(options,instances=self.max_plcs())
+ (hostname,ip,mac)=ip_pool.next_free(tracker.plcnames())
if options.verbose:
utils.header("Using auto-allocated %s %s for plc %s"%(
hostname,ip,plc['name']))
(hostname,vservername) = track.split('@')
return TestSsh(hostname).actual_command("vserver --silent %s stop"%vservername)
+ def plcnames (self):
+ return [ self.plcname(track) for track in self.tracks ]
+
+ def plcname (self, track):
+ (hostname,vservername) = track.split('@')
+ return vservername.rsplit('-',1)[1]
class TrackerQemu (Tracker):
def stop_command (self, track):
(hostname,buildname,nodename) = track.split('@')
return TestSsh(hostname).actual_command("%s/qemu-%s/qemu-kill-node this"%(buildname,nodename))
+
+ def hostnames (self):
+ return [ self.hostname(track) for track in self.tracks ]
+
+ def hostname (self, track):
+ (hostname,buildname,nodename) = track.split('@')
+ return hostname
+
+ def nodenames (self):
+ return [ self.nodename(track) for track in self.tracks ]
+
+ def nodename (self, track):
+ (hostname,buildname,nodename) = track.split('@')
+ return nodename
+