tools/cpee in cpee-2.1.7 vs tools/cpee in cpee-2.1.8
- old
+ new
@@ -160,10 +160,11 @@
end
else
names << File.basename(p2)
end
names.each do |name|
+ print "Working on: " + name.to_s + "\r"
res = Typhoeus.get(File.join(base,name.to_s,'/'))
if res.success?
if res.headers['Content-Type'] =~ /^(text|application)\/xml/
XML::Smart.string(res.response_body) do |doc|
if doc.root.qname.to_s == "instances"
@@ -191,10 +192,11 @@
end
end
end
end
end
+ puts
elsif command == 'abandon'
p1 = File.join(p1,'*') if p1 =~ /([a-zA-Z]|\/)$/
base = File.dirname(p1)
names = []
if File.basename(p1) =~ /(\d+)-(\d+)/
@@ -213,17 +215,19 @@
end
else
names << File.basename(p1)
end
names.each do |name|
+ print "Working on: " + name.to_s + "\r"
res1 = Typhoeus.get(File.join(base,name.to_s,'properties','state','/'))
if res1.success?
if res1.response_body == 'ready' || res1.response_body == 'stopped'
Typhoeus.put(File.join(base,name.to_s,'properties','state','/'), headers: {'Content-Type' => 'application/x-www-form-urlencoded'}, body: "value=abandoned")
end
end
end
+ puts
elsif command == 'start'
p1 = File.join(p1,'*') if p1 =~ /([a-zA-Z]|\/)$/
base = File.dirname(p1)
names = []
if File.basename(p1) =~ /(\d+)-(\d+)/
@@ -254,10 +258,34 @@
end
end
end
end
elsif command == 'delete!'
- Typhoeus.delete(File.join(p1,'/'))
+ p1 = File.join(p1,'*') if p1 =~ /([a-zA-Z]|\/)$/
+ base = File.dirname(p1)
+ names = []
+ if File.basename(p1) =~ /(\d+)-(\d+)/
+ names = ($1.to_i..$2.to_i).to_a
+ elsif File.basename(p1) == '*'
+ res = Typhoeus.get(File.join(base,'/'))
+ if res.success?
+ XML::Smart.string(res.response_body) do |doc|
+ doc.find('//instance/@id').each do |ele|
+ names << ele.value
+ end
+ end
+ names.reverse!
+ else
+ exit
+ end
+ else
+ names << File.basename(p1)
+ end
+ names.each do |name|
+ print "Working on: " + name.to_s + "\r"
+ Typhoeus.delete(File.join(base,name.to_s,'/'))
+ end
+ puts
elsif command == 'new'
if !File.exists?(p1)
FileUtils.cp_r("#{curpath}/server/",p1)
FileUtils.mkdir("#{p1}/archive") rescue nil
FileUtils.mkdir("#{p1}/instances") rescue nil