15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'bin/mcicp', line 15
def self.go(options)
temp1 = ServerTemplate.find(options[:from])
temp2 = ServerTemplate.find(options[:to])
from_st = ServerTemplateInternal.new(:href => temp1.href)
mci_payload = from_st.multi_cloud_images
to_st = ServerTemplateInternal.new(:href => temp2.href)
to_delete = to_st.multi_cloud_images
mci_payload.each do |mci|
begin
to_st.add_multi_cloud_image(mci['href'])
rescue => e
puts "image already added, skipping"
to_delete.delete(mci)
end
end
ubuntu_i386 = mci_payload.detect {|d| d['name'] =~ /Ubuntu.+i386/}
if ubuntu_i386
to_st.set_default_multi_cloud_image(ubuntu_i386['href'])
else
to_st.set_default_multi_cloud_image(mci_payload.first['href'])
end
unless options[:nice]
to_delete.each do |mci|
to_st.delete_multi_cloud_image(mci['href'])
end
end
puts 'done.'
end
|