kytoon 1.2.4 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
* Mon Nov 26 2012 Dan Prince <dprince@redhat.com> - 1.2.5
|
2
|
+
- Libvirt: ping test instances to ensure they have IPs before
|
3
|
+
trying to configure hosts, etc.
|
4
|
+
- Generate server group IDs with using Time.now.to_f
|
5
|
+
which gives us millisecond accuracy. This should avoid ID
|
6
|
+
collisions which could occur if two groups were spun up
|
7
|
+
in the same second (thus causing image name collisions, etc)
|
8
|
+
- XenServer: Add 'cleanup_before_create' option to run instance
|
9
|
+
cleanup before creating a new group.
|
10
|
+
|
1
11
|
* Thu Oct 8 2012 Dan Prince <dprince@redhat.com> - 1.2.4
|
2
12
|
- XenServer: Delete VDI's that aren't in use during cleanup.
|
3
13
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.5
|
@@ -2,6 +2,7 @@ require 'json'
|
|
2
2
|
require 'kytoon/util'
|
3
3
|
require 'rexml/document'
|
4
4
|
require 'rexml/xpath'
|
5
|
+
require 'timeout'
|
5
6
|
|
6
7
|
module Kytoon
|
7
8
|
|
@@ -36,7 +37,7 @@ class ServerGroup
|
|
36
37
|
attr_accessor :use_sudo
|
37
38
|
|
38
39
|
def initialize(options={})
|
39
|
-
@id = options[:id] || Time.now.
|
40
|
+
@id = options[:id] || Time.now.to_f
|
40
41
|
@name = options[:name]
|
41
42
|
@use_sudo = options[:use_sudo]
|
42
43
|
@servers=[]
|
@@ -159,6 +160,7 @@ class ServerGroup
|
|
159
160
|
puts "Copying hosts files..."
|
160
161
|
#now that we have IP info copy hosts files into the servers
|
161
162
|
sg.servers.each do |server|
|
163
|
+
ping_test(server['ip_address'])
|
162
164
|
Kytoon::Util.remote_exec(%{
|
163
165
|
cat > /etc/hosts <<-EOF_CAT
|
164
166
|
#{hosts_file_data}
|
@@ -178,6 +180,31 @@ fi
|
|
178
180
|
sg
|
179
181
|
end
|
180
182
|
|
183
|
+
def self.default_ip_type()
|
184
|
+
ip_type = Util.load_configs['libvirt_ip_type'] || 4
|
185
|
+
ip_type.to_i
|
186
|
+
end
|
187
|
+
|
188
|
+
def self.ping_test(ip_addr)
|
189
|
+
|
190
|
+
ping_timeout = (Util.load_configs['libvirt_ping_timeout'] || 60).to_i
|
191
|
+
|
192
|
+
begin
|
193
|
+
ping = self.default_ip_type == 6 ? 'ping6' : 'ping'
|
194
|
+
ping_command = "#{ping} -c 1 #{ip_addr} > /dev/null 2>&1"
|
195
|
+
Timeout::timeout(ping_timeout) do
|
196
|
+
while(1) do
|
197
|
+
return true if system(ping_command)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
rescue Timeout::Error => te
|
201
|
+
raise KytoonException, "Timeout pinging server: #{ping_command}"
|
202
|
+
end
|
203
|
+
|
204
|
+
return false
|
205
|
+
|
206
|
+
end
|
207
|
+
|
181
208
|
def self.get(options={})
|
182
209
|
id = options[:id]
|
183
210
|
if id.nil? then
|
@@ -48,9 +48,10 @@ class ServerGroup
|
|
48
48
|
attr_accessor :bridge
|
49
49
|
attr_accessor :public_ip_bridge
|
50
50
|
attr_accessor :dns_nameserver
|
51
|
+
attr_accessor :cleanup_before_create
|
51
52
|
|
52
53
|
def initialize(options={})
|
53
|
-
@id = options[:id] || Time.now.
|
54
|
+
@id = options[:id] || Time.now.to_f
|
54
55
|
@name = options[:name]
|
55
56
|
@netmask = options[:netmask]
|
56
57
|
@gateway = options[:gateway]
|
@@ -59,6 +60,7 @@ class ServerGroup
|
|
59
60
|
@bridge = options[:bridge]
|
60
61
|
@public_ip_bridge = options[:public_ip_bridge]
|
61
62
|
@dns_nameserver = options[:dns_nameserver]
|
63
|
+
@cleanup_before_create = options[:cleanup_before_create]
|
62
64
|
@gateway_ip = options[:gateway_ip]
|
63
65
|
@gateway_ip = ENV['GATEWAY_IP'] if @gateway_ip.nil?
|
64
66
|
raise ConfigException, "Please specify a GATEWAY_IP" if @gateway_ip.nil?
|
@@ -93,6 +95,7 @@ class ServerGroup
|
|
93
95
|
:dns_nameserver => json_hash['dns_nameserver'],
|
94
96
|
:network_type => json_hash['network_type'],
|
95
97
|
:public_ip_bridge => json_hash['public_ip_bridge'],
|
98
|
+
:cleanup_before_create => json_hash['cleanup_before_create'],
|
96
99
|
:bridge => json_hash['bridge']
|
97
100
|
)
|
98
101
|
json_hash["servers"].each do |server_hash|
|
@@ -145,6 +148,7 @@ class ServerGroup
|
|
145
148
|
'gateway_ip' => @gateway_ip,
|
146
149
|
'broadcast' => @broadcast,
|
147
150
|
'dns_nameserver' => @dns_nameserver,
|
151
|
+
'cleanup_before_create' => @cleanup_before_create,
|
148
152
|
'network_type' => @network_type,
|
149
153
|
'public_ip_bridge' => @public_ip_bridge,
|
150
154
|
'bridge' => @bridge,
|
@@ -168,6 +172,7 @@ class ServerGroup
|
|
168
172
|
end
|
169
173
|
|
170
174
|
def self.create(sg)
|
175
|
+
ServerGroup.cleanup_instances(sg.gateway_ip) if sg.cleanup_before_create
|
171
176
|
sg.cache_to_disk
|
172
177
|
init_host(sg)
|
173
178
|
status, host_ssh_public_key = Kytoon::Util.remote_exec(%{
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kytoon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rdoc
|
@@ -289,7 +289,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
289
289
|
version: '0'
|
290
290
|
segments:
|
291
291
|
- 0
|
292
|
-
hash:
|
292
|
+
hash: 1238263257557128483
|
293
293
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
294
294
|
none: false
|
295
295
|
requirements:
|