pvcglue 0.1.21 → 0.1.22

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e429dc7a4b50158ce2a1929e7b652e07030993a0
4
- data.tar.gz: f24bc8d081da32c682c3d0b60715aebc24425fd8
3
+ metadata.gz: 6c0c298368758b219ada1c59b9295cb38e27c787
4
+ data.tar.gz: 379a85589243740d2c758fe7494746095376023a
5
5
  SHA512:
6
- metadata.gz: e8b4ecd0470e63aefd7299b8d7c6d37804a0b8503c8a7800e83a73ef21add4b49816e58266935774af4668bc1471c0a1d2ea66a0ae8ed54c4245dcfc0f303380
7
- data.tar.gz: aad57eb0dfc27b89ee3e71b47d91363e570780f079c4566326e3108d3d242e1e5352a748fca39e50b4fdf194a6a2db6751d265f2cd37667b6b5613c6c2a6664e
6
+ metadata.gz: 2c6cd78e75c63ef6068100e38b358ab4c292ba79db7a5e53ac5ffe4fd39ac470e643801d6b7484b945c86b88188a8b7e98786c0fc58336670ca13af5bbe7504e
7
+ data.tar.gz: f936147aec4e862349af6cedd195e234ca451ef4a7c60b430b634ead48905614a3fbe75afecf1c5964bbe9894eff85453a338436d36743d8553a31d90516120a
@@ -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
 
@@ -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" => {"example" => "127.0.0.1"},
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
- Pvcglue.cloud.data = data
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
- data = `vagrant ssh-config`
226
- puts data
227
- out = {}
228
- data.scan(/Host (.*?)$.*?Port (.*?)$/m) do |host_name, port|
229
- out[host_name] = port
230
- end
231
- FileUtils.mkdir_p(File.dirname(ssh_config_cache_file_name)) # the 'tmp' directory may not always exist
232
- File.write(ssh_config_cache_file_name, out.to_json)
233
- puts out.inspect
234
- out
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.ssh_config
238
- JSON.parse(File.read(ssh_config_cache_file_name))
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.ssh_config_cache_file_name
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
@@ -1,3 +1,3 @@
1
1
  module Pvcglue
2
- VERSION = "0.1.21"
2
+ VERSION = "0.1.22"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pvcglue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.21
4
+ version: 0.1.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Lyric