- print "WARNING: free_tracker: Could not parse %s - skipped"%TestPlc.TRACKER_FILE
- return False
- stop_command = "vserver --silent %s stop"%vserver_to_stop
- utils.system(self.test_ssh.actual_command(stop_command))
- x=TestPlc.TRACKER_FILE
- flush_command = "tail --lines=+2 %s > %s.tmp ; mv %s.tmp %s"%(x,x,x,x)
- utils.system(self.test_ssh.actual_command(flush_command))
+ print 'dry_run: free_tracker - skipping tracker update'
+ return True
+ how_many = len(lines) - keep_vservers
+ # nothing todo until we have more than keep_vservers in the tracker
+ if how_many <= 0:
+ print 'free_tracker : limit %d not reached'%keep_vservers
+ return True
+ to_stop = lines[:how_many]
+ to_keep = lines[how_many:]
+ for line in to_stop:
+ print '>%s<'%line
+ [vname,hostname]=line.split()
+ command=TestSsh(hostname).actual_command("vserver --silent %s stop"%vname)
+ utils.system(command)
+ if self.options.dry_run:
+ print 'dry_run: free_tracker would stop %d vservers'%len(to_stop)
+ for line in to_stop: print line,
+ print 'dry_run: free_tracker would keep %d vservers'%len(to_keep)
+ for line in to_keep: print line,
+ return True
+ print "Storing %d remaining vservers in %s"%(len(to_keep),TestPlc.TRACKER_FILE)
+ tracker=open(TestPlc.TRACKER_FILE,"w")
+ for line in to_keep:
+ tracker.write(line)
+ tracker.close()