pvcglue 0.1.21 → 0.1.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pvcglue/cloud.rb +4 -3
- data/lib/pvcglue/local.rb +42 -18
- data/lib/pvcglue/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c0c298368758b219ada1c59b9295cb38e27c787
|
4
|
+
data.tar.gz: 379a85589243740d2c758fe7494746095376023a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c6cd78e75c63ef6068100e38b358ab4c292ba79db7a5e53ac5ffe4fd39ac470e643801d6b7484b945c86b88188a8b7e98786c0fc58336670ca13af5bbe7504e
|
7
|
+
data.tar.gz: f936147aec4e862349af6cedd195e234ca451ef4a7c60b430b634ead48905614a3fbe75afecf1c5964bbe9894eff85453a338436d36743d8553a31d90516120a
|
data/lib/pvcglue/cloud.rb
CHANGED
@@ -162,9 +162,6 @@ module Pvcglue
|
|
162
162
|
ports = []
|
163
163
|
from_all = data[app_name][:ssh_allowed_from_all_port].to_i
|
164
164
|
ports << from_all if from_all > 0
|
165
|
-
if stage_name == 'local'
|
166
|
-
Pvcglue::Local.ssh_config.each { |_, port| ports << port } # Yes, this is a hack, and should be refactored. :)
|
167
|
-
end
|
168
165
|
ports
|
169
166
|
end
|
170
167
|
|
@@ -191,6 +188,10 @@ module Pvcglue
|
|
191
188
|
addresses = dev_ip_addresses
|
192
189
|
addresses.concat(stage_internal_addresses)
|
193
190
|
# puts addresses.inspect
|
191
|
+
if stage_name == 'local'
|
192
|
+
addresses << Pvcglue::Local.vagrant_config # Yes, this is a hack, and should be refactored. :)
|
193
|
+
end
|
194
|
+
# puts addresses.inspect
|
194
195
|
addresses
|
195
196
|
end
|
196
197
|
|
data/lib/pvcglue/local.rb
CHANGED
@@ -19,7 +19,7 @@ module Pvcglue
|
|
19
19
|
|
20
20
|
if vagrant("up #{machines_in_stage}")
|
21
21
|
update_local_config(get_info_for_machines)
|
22
|
-
get_ssh_config
|
22
|
+
# get_ssh_config
|
23
23
|
else
|
24
24
|
remove_cache_info_for_machines
|
25
25
|
raise(Thor::Error, "Error starting virtual machines. :(")
|
@@ -36,6 +36,15 @@ module Pvcglue
|
|
36
36
|
update_local_config(machines)
|
37
37
|
end
|
38
38
|
|
39
|
+
def self.get_user_ip_address
|
40
|
+
result = `ip route get 8.8.8.8 2>&1 | awk '{print $NF; exit}'`.strip # Ubuntu
|
41
|
+
result = `ipconfig getifaddr en0 2>&1` unless result =~ /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/ # OSX
|
42
|
+
raise "IP Address not found" unless result =~ /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/
|
43
|
+
puts "*"*80
|
44
|
+
puts "Machine IP address #{result}"
|
45
|
+
result
|
46
|
+
end
|
47
|
+
|
39
48
|
def self.update_local_config(machines)
|
40
49
|
machines = machines.with_indifferent_access
|
41
50
|
Pvcglue::Manager.set_local_mode
|
@@ -64,7 +73,7 @@ module Pvcglue
|
|
64
73
|
"swapfile_size" => 128,
|
65
74
|
"time_zone" => "America/Los_Angeles",
|
66
75
|
"authorized_keys" => {"example" => File.read(File.expand_path('~/.ssh/id_rsa.pub'))}, # TODO: error checking
|
67
|
-
"dev_ip_addresses" => {"
|
76
|
+
"dev_ip_addresses" => {"local" => "127.0.0.1", "user" => get_user_ip_address},
|
68
77
|
"gems" => {"delayed_job" => false, "whenever" => false},
|
69
78
|
"stages" =>
|
70
79
|
{"local" =>
|
@@ -131,12 +140,17 @@ module Pvcglue
|
|
131
140
|
data[app_name][:stages][stage_name][:roles][:lb][:lb][:private_ip] = machines[:lb][:private_ip]
|
132
141
|
data[app_name][:stages][stage_name][:roles][:web][:web_1][:public_ip] = machines[:web][:public_ip]
|
133
142
|
data[app_name][:stages][stage_name][:roles][:web][:web_1][:private_ip] = machines[:web][:private_ip]
|
143
|
+
|
144
|
+
data[app_name][:dev_ip_addresses] = {"local" => "127.0.0.1", "user" => get_user_ip_address}
|
145
|
+
data[app_name][:stages][stage_name][:domains] = [machines[:lb][:public_ip]]
|
146
|
+
|
134
147
|
# data[app_name][:stages][:local][:roles][:web][:web_2][:public_ip] = machines[:web_2][:public_ip]
|
135
148
|
# data[app_name][:stages][:local][:roles][:web][:web_2][:private_ip] = machines[:web_2][:private_ip]
|
136
149
|
|
137
|
-
|
150
|
+
Pvcglue.cloud.data = data
|
138
151
|
File.write(::Pvcglue.cloud.local_file_name, TOML.dump(Pvcglue.cloud.data))
|
139
152
|
File.write(Pvcglue.configuration.cloud_cache_file_name, TOML::PvcDumper.new(Pvcglue.cloud.data).toml_str)
|
153
|
+
puts TOML::PvcDumper.new(Pvcglue.cloud.data).toml_str
|
140
154
|
end
|
141
155
|
|
142
156
|
def self.stop
|
@@ -202,6 +216,7 @@ module Pvcglue
|
|
202
216
|
|
203
217
|
def self.get_info_for_machines
|
204
218
|
machines = {}
|
219
|
+
vagrant_ips = []
|
205
220
|
MACHINES.each do |machine|
|
206
221
|
machines[machine] = {}
|
207
222
|
machine_name = machine == 'manager' ? machine : "#{Pvcglue.cloud.stage_name}-#{machine}"
|
@@ -212,30 +227,39 @@ module Pvcglue
|
|
212
227
|
type = eth == 'eth2' ? :private_ip : :public_ip
|
213
228
|
machines[machine][type] = ip
|
214
229
|
end
|
230
|
+
data.scan(/inet (.*)\/.*global (eth0)/) do |ip, eth|
|
231
|
+
vagrant_ips << ip
|
232
|
+
end
|
215
233
|
puts "Adding you public key to the root user for #{machine_name}..."
|
216
234
|
# cat ~/.ssh/id_rsa.pub | vagrant ssh manager -c 'sudo tee /root/.ssh/authorized_keys'
|
217
235
|
raise $? unless system %Q(cat ~/.ssh/id_rsa.pub | vagrant ssh #{machine_name} -c 'sudo tee /root/.ssh/authorized_keys')
|
218
236
|
end
|
219
237
|
FileUtils.mkdir_p(File.dirname(machine_cache_file_name)) # the 'tmp' directory may not always exist
|
220
238
|
File.write(machine_cache_file_name, machines.to_json)
|
239
|
+
FileUtils.mkdir_p(File.dirname(vagrant_config_cache_file_name)) # the 'tmp' directory may not always exist
|
240
|
+
File.write(vagrant_config_cache_file_name, vagrant_ips.to_json)
|
221
241
|
machines
|
222
242
|
end
|
223
243
|
|
224
|
-
def self.get_ssh_config
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
end
|
244
|
+
# def self.get_ssh_config
|
245
|
+
# data = `vagrant ssh-config`
|
246
|
+
# puts data
|
247
|
+
# out = {}
|
248
|
+
# data.scan(/Host (.*?)$.*?Port (.*?)$/m) do |host_name, port|
|
249
|
+
# out[host_name] = port
|
250
|
+
# end
|
251
|
+
# FileUtils.mkdir_p(File.dirname(ssh_config_cache_file_name)) # the 'tmp' directory may not always exist
|
252
|
+
# File.write(ssh_config_cache_file_name, out.to_json)
|
253
|
+
# puts out.inspect
|
254
|
+
# out
|
255
|
+
# end
|
236
256
|
|
237
|
-
def self.
|
238
|
-
JSON.parse(File.read(
|
257
|
+
def self.vagrant_config
|
258
|
+
ips = JSON.parse(File.read(vagrant_config_cache_file_name))
|
259
|
+
# puts ips.inspect
|
260
|
+
ip = ips.first
|
261
|
+
parts = ip.split('.')
|
262
|
+
parts[0..2].join('.') + '.0/24'
|
239
263
|
end
|
240
264
|
|
241
265
|
def self.local_cache_dir
|
@@ -247,7 +271,7 @@ module Pvcglue
|
|
247
271
|
File.join(local_cache_dir, 'pvcglue-machines.json')
|
248
272
|
end
|
249
273
|
|
250
|
-
def self.
|
274
|
+
def self.vagrant_config_cache_file_name
|
251
275
|
# TODO: Remove caching, maybe?
|
252
276
|
File.join(local_cache_dir, 'pvcglue-ssh-config.json')
|
253
277
|
end
|
data/lib/pvcglue/version.rb
CHANGED