abiquo-etk 0.4.15 → 0.4.16
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/abiquo-etk.gemspec +3 -2
- data/lib/abicli/commands/instant-deploy.rb +176 -0
- metadata +5 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.16
|
data/abiquo-etk.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{abiquo-etk}
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.16"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Sergio Rubio"]
|
12
|
-
s.date = %q{2010-10-
|
12
|
+
s.date = %q{2010-10-21}
|
13
13
|
s.description = %q{Tools to troubleshoot your Abiquo installation}
|
14
14
|
s.email = %q{srubio@abiquo.com}
|
15
15
|
s.executables = ["abiquo-check-16-install", "aetk-setup-rs", "aetk-setup-v2v", "abicli", "aetk-setup-server"]
|
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
"bin/aetk-setup-rs",
|
34
34
|
"bin/aetk-setup-server",
|
35
35
|
"bin/aetk-setup-v2v",
|
36
|
+
"lib/abicli/commands/instant-deploy.rb",
|
36
37
|
"lib/abicli/commands/remote-services-settings.rb",
|
37
38
|
"lib/abicli/commands/server-settings.rb",
|
38
39
|
"lib/abicli/commands/set.rb",
|
@@ -0,0 +1,176 @@
|
|
1
|
+
# requirements:
|
2
|
+
# Check kvm installed
|
3
|
+
# check kvm fullvirt available
|
4
|
+
# check if qemu-img is installed
|
5
|
+
# check distribution supported
|
6
|
+
#
|
7
|
+
if ARGV[0] == 'instant-deploy'
|
8
|
+
ARGV.shift
|
9
|
+
|
10
|
+
#
|
11
|
+
# HTTPDownloader code based on code from http://www.vagrantup.com
|
12
|
+
#
|
13
|
+
require 'net/http'
|
14
|
+
require 'net/https'
|
15
|
+
require 'open-uri'
|
16
|
+
require 'uri'
|
17
|
+
require 'fileutils'
|
18
|
+
|
19
|
+
class HTTPDownloader
|
20
|
+
def self.match?(uri)
|
21
|
+
# URI.parse barfs on '<drive letter>:\\files \on\ windows'
|
22
|
+
extracted = URI.extract(uri).first
|
23
|
+
extracted && extracted.include?(uri)
|
24
|
+
end
|
25
|
+
|
26
|
+
def report_progress(progress, total, show_parts=true)
|
27
|
+
line_reset = "\r\e[0K"
|
28
|
+
percent = (progress.to_f / total.to_f) * 100
|
29
|
+
line = "Progress: #{percent.to_i}%"
|
30
|
+
line << " (#{progress} / #{total})" if show_parts
|
31
|
+
line = "#{line_reset}#{line}"
|
32
|
+
$stdout.sync = true
|
33
|
+
$stdout.print line
|
34
|
+
end
|
35
|
+
|
36
|
+
def download!(source_url, destination_file)
|
37
|
+
proxy_uri = URI.parse(ENV["http_proxy"] || "")
|
38
|
+
uri = URI.parse(source_url)
|
39
|
+
http = Net::HTTP.new(uri.host, uri.port, proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password)
|
40
|
+
|
41
|
+
if uri.scheme == "https"
|
42
|
+
http.use_ssl = true
|
43
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
44
|
+
end
|
45
|
+
|
46
|
+
http.start do |h|
|
47
|
+
h.request_get(uri.request_uri) do |response|
|
48
|
+
total = response.content_length
|
49
|
+
progress = 0
|
50
|
+
segment_count = 0
|
51
|
+
|
52
|
+
response.read_body do |segment|
|
53
|
+
# Report the progress out
|
54
|
+
progress += segment.length
|
55
|
+
segment_count += 1
|
56
|
+
|
57
|
+
# Progress reporting is limited to every 25 segments just so
|
58
|
+
# we're not constantly updating
|
59
|
+
if segment_count % 25 == 0
|
60
|
+
report_progress(progress, total)
|
61
|
+
segment_count = 0
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
# Store the segment
|
66
|
+
destination_file.write(segment)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
rescue SocketError
|
71
|
+
raise Errors::DownloaderHTTPSocketError.new
|
72
|
+
end
|
73
|
+
end
|
74
|
+
class InstantDeployCLI
|
75
|
+
include Mixlib::CLI
|
76
|
+
|
77
|
+
option :iso_url,
|
78
|
+
:long => '--iso-url URL',
|
79
|
+
:description => 'Abiquo ISO URL'
|
80
|
+
|
81
|
+
option :help,
|
82
|
+
:short => "-h",
|
83
|
+
:long => "--help",
|
84
|
+
:description => ".\n\n",
|
85
|
+
:on => :tail,
|
86
|
+
:boolean => true,
|
87
|
+
:show_options => true,
|
88
|
+
:exit => 0
|
89
|
+
end
|
90
|
+
|
91
|
+
def preflight_check
|
92
|
+
#
|
93
|
+
# Check if this is Ubuntu
|
94
|
+
#
|
95
|
+
if not File.exists? '/etc/lsb-release'
|
96
|
+
$stderr.puts "\nYou are not running Ubuntu. Other distributions are not supported.\n\n"
|
97
|
+
exit
|
98
|
+
end
|
99
|
+
if not (File.read('/etc/lsb-release') =~ /DISTRIB_ID=Ubuntu/)
|
100
|
+
$stderr.puts "\nYou are not running Ubuntu. Other distributions are not supported\n\n"
|
101
|
+
exit
|
102
|
+
end
|
103
|
+
|
104
|
+
#
|
105
|
+
# Check if KVM installed
|
106
|
+
#
|
107
|
+
if `which /usr/bin/kvm`.strip.chomp.empty?
|
108
|
+
$stderr.puts "\nKVM not found. Install it first:\n\n"
|
109
|
+
$stderr.puts "sudo apt-get install kvm\n\n"
|
110
|
+
exit
|
111
|
+
end
|
112
|
+
|
113
|
+
#
|
114
|
+
# Check if qemu-img installed
|
115
|
+
#
|
116
|
+
if `which /usr/bin/qemu-img`.strip.chomp.empty?
|
117
|
+
$stderr.puts "\nqemu-img not found. Install it first:\n\n"
|
118
|
+
$stderr.puts "sudo apt-get install kvm\n\n"
|
119
|
+
exit
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def install_iso(params = {})
|
124
|
+
target_dir = params[:target_dir] || "abiquo-instant-deploy-#{Time.now.strftime "%s"}"
|
125
|
+
disk_file = params[:disk_file] || "#{target_dir}/abiquo.qcow2"
|
126
|
+
iso_url = params[:iso_url]
|
127
|
+
# Create target directory
|
128
|
+
begin
|
129
|
+
FileUtils.mkdir(target_dir)
|
130
|
+
rescue Exception
|
131
|
+
$stderr.puts "\nError creating directory #{target_dir}. Aborting.\n\n"
|
132
|
+
exit 1
|
133
|
+
end
|
134
|
+
|
135
|
+
# Create qemu img
|
136
|
+
if File.exist? disk_file
|
137
|
+
raise Exception.new("Image #{disk_file} already exists")
|
138
|
+
end
|
139
|
+
`/usr/bin/qemu-img create -f qcow2 #{disk_file} 20GB`
|
140
|
+
|
141
|
+
# Download the iso
|
142
|
+
downloader = HTTPDownloader.new
|
143
|
+
puts "Downloading Abiquo ISO..."
|
144
|
+
begin
|
145
|
+
downloader.download! iso_url, File.new(target_dir + '/instant-deploy.iso', 'w')
|
146
|
+
rescue Exception
|
147
|
+
$stderr.puts "Error downloading Abiquo ISO. Aborting."
|
148
|
+
exit
|
149
|
+
end
|
150
|
+
|
151
|
+
puts "Booting the Installer..."
|
152
|
+
# Boot
|
153
|
+
`kvm -m 1024 -drive file=#{disk_file},if=scsi,boot=on -net user -net nic -cdrom #{target_dir}/instant-deploy.iso -boot once=d`
|
154
|
+
end
|
155
|
+
|
156
|
+
target_dir = "abiquo-instant-deploy-#{Time.now.strftime "%s"}"
|
157
|
+
|
158
|
+
trap("INT") { puts "\n\nCleaning Environment..."; exit }
|
159
|
+
|
160
|
+
preflight_check
|
161
|
+
|
162
|
+
cli = InstantDeployCLI.new
|
163
|
+
cli.parse_options
|
164
|
+
url = cli.config[:iso_url]
|
165
|
+
if url.nil?
|
166
|
+
$stderr.puts "\n--iso-url argument is mandatory.\n\n"
|
167
|
+
puts cli.opt_parser.help
|
168
|
+
exit
|
169
|
+
end
|
170
|
+
puts "\n"
|
171
|
+
print "Abiquo Instant Deploy: ".bold
|
172
|
+
puts "One Command Cloud Builder\n\n"
|
173
|
+
puts "Building the cloud into #{target_dir.bold} directory..."
|
174
|
+
install_iso(:target_dir => target_dir, :iso_url => url)
|
175
|
+
|
176
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abiquo-etk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 47
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 16
|
10
|
+
version: 0.4.16
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sergio Rubio
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-21 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- bin/aetk-setup-rs
|
93
93
|
- bin/aetk-setup-server
|
94
94
|
- bin/aetk-setup-v2v
|
95
|
+
- lib/abicli/commands/instant-deploy.rb
|
95
96
|
- lib/abicli/commands/remote-services-settings.rb
|
96
97
|
- lib/abicli/commands/server-settings.rb
|
97
98
|
- lib/abicli/commands/set.rb
|