pvcglue 0.1.20 → 0.1.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b8ffc336dfdd07570db2d254d7aa3e3962bc46e
4
- data.tar.gz: e916de10d914a58ce35a64749afe31bc02a7c023
3
+ metadata.gz: e429dc7a4b50158ce2a1929e7b652e07030993a0
4
+ data.tar.gz: f24bc8d081da32c682c3d0b60715aebc24425fd8
5
5
  SHA512:
6
- metadata.gz: 4edb635b8bc3662bb47670b857cfdeb82920dceb7b181da8393c7f6c8ad4d9322008f2cf5df9f50bca0d5babfb3716ff1e5e6295e626b29b3b111d11da41395b
7
- data.tar.gz: ed7dfcc56e2f5df166259ad84c38d647ff5fd4b29c35a77ea58bfe51af8a78b7115d42ea1492166a15f907459ab706928449d508940f48c40c41d346afa78a74
6
+ metadata.gz: e8b4ecd0470e63aefd7299b8d7c6d37804a0b8503c8a7800e83a73ef21add4b49816e58266935774af4668bc1471c0a1d2ea66a0ae8ed54c4245dcfc0f303380
7
+ data.tar.gz: aad57eb0dfc27b89ee3e71b47d91363e570780f079c4566326e3108d3d242e1e5352a748fca39e50b4fdf194a6a2db6751d265f2cd37667b6b5613c6c2a6664e
@@ -162,6 +162,9 @@ 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
165
168
  ports
166
169
  end
167
170
 
@@ -179,6 +182,7 @@ module Pvcglue
179
182
  from_all = data[app_name][:ssh_allowed_from_all_port].to_i
180
183
  ports << from_all if from_all > 0
181
184
  ports.concat [80, 443] if current_node.values.first[:allow_public_access]
185
+ ports.concat ["2000:3000"] if stage_name == 'local'
182
186
  ports
183
187
  end
184
188
 
@@ -137,12 +137,16 @@ module Pvcglue
137
137
  File.join(application_dir, 'tmp')
138
138
  end
139
139
 
140
+ def pvcglue_tmp_dir
141
+ File.join(tmp_dir, 'pvcglue')
142
+ end
143
+
140
144
  def cloud_cache_file_name
141
145
  # Just in case the Rails project hasn't yet been run, make sure the tmp
142
146
  # dir exists.
143
- Dir.mkdir(tmp_dir) unless Dir.exist?(tmp_dir)
147
+ Dir.mkdir(pvcglue_tmp_dir) unless Dir.exist?(pvcglue_tmp_dir)
144
148
 
145
- File.join(tmp_dir, "pvcglue_#{cloud_manager}_#{cloud_name}_#{application_name}_cache.toml")
149
+ File.join(pvcglue_tmp_dir, "pvcglue_#{cloud_manager}_#{cloud_name}_#{application_name}_cache.toml")
146
150
  end
147
151
 
148
152
  def clear_cloud_cache
@@ -117,6 +117,8 @@ module Pvcglue
117
117
 
118
118
  def self.read_cached_stage_env
119
119
  # TODO: Only use cache in development of gem, do not cache by default, use Manager config
120
+ return false # disable cache for now
121
+
120
122
  if File.exists?(stage_env_cache_file_name)
121
123
  stage_env = File.read(stage_env_cache_file_name)
122
124
  Pvcglue.cloud.stage_env = TOML.parse(stage_env)
@@ -134,7 +136,7 @@ module Pvcglue
134
136
  end
135
137
 
136
138
  def self.stage_env_cache_file_name
137
- File.join(Pvcglue.configuration.tmp_dir, "pvcglue_cache_#{stage_env_file_name_base}")
139
+ File.join(Pvcglue.configuration.pvcglue_tmp_dir, "pvcglue_cache_#{stage_env_file_name_base}")
138
140
  end
139
141
 
140
142
  def self.clear_stage_env_cache
@@ -15,8 +15,11 @@ module Pvcglue
15
15
  end
16
16
 
17
17
  def self.start
18
+ FileUtils.rm_rf(local_cache_dir)
19
+
18
20
  if vagrant("up #{machines_in_stage}")
19
21
  update_local_config(get_info_for_machines)
22
+ get_ssh_config
20
23
  else
21
24
  remove_cache_info_for_machines
22
25
  raise(Thor::Error, "Error starting virtual machines. :(")
@@ -28,7 +31,7 @@ module Pvcglue
28
31
  end
29
32
 
30
33
  def self.update_local_config_from_cache
31
- data = File.read(cache_file_name)
34
+ data = File.read(machine_cache_file_name)
32
35
  machines = JSON.parse(data)
33
36
  update_local_config(machines)
34
37
  end
@@ -133,7 +136,7 @@ module Pvcglue
133
136
 
134
137
  Pvcglue.cloud.data = data
135
138
  File.write(::Pvcglue.cloud.local_file_name, TOML.dump(Pvcglue.cloud.data))
136
- File.write(Pvcglue.configuration.cloud_cache_file_name, TOML.dump(Pvcglue.cloud.data))
139
+ File.write(Pvcglue.configuration.cloud_cache_file_name, TOML::PvcDumper.new(Pvcglue.cloud.data).toml_str)
137
140
  end
138
141
 
139
142
  def self.stop
@@ -166,7 +169,7 @@ module Pvcglue
166
169
  end
167
170
 
168
171
  def self.remove_cache_info_for_machines
169
- File.delete(cache_file_name)
172
+ File.delete(machine_cache_file_name)
170
173
  end
171
174
 
172
175
  =begin
@@ -213,14 +216,40 @@ module Pvcglue
213
216
  # cat ~/.ssh/id_rsa.pub | vagrant ssh manager -c 'sudo tee /root/.ssh/authorized_keys'
214
217
  raise $? unless system %Q(cat ~/.ssh/id_rsa.pub | vagrant ssh #{machine_name} -c 'sudo tee /root/.ssh/authorized_keys')
215
218
  end
216
- FileUtils.mkdir_p(File.dirname(cache_file_name)) # the 'tmp' directory may not always exist
217
- File.write(cache_file_name, machines.to_json)
219
+ FileUtils.mkdir_p(File.dirname(machine_cache_file_name)) # the 'tmp' directory may not always exist
220
+ File.write(machine_cache_file_name, machines.to_json)
218
221
  machines
219
222
  end
220
223
 
221
- def self.cache_file_name
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
236
+
237
+ def self.ssh_config
238
+ JSON.parse(File.read(ssh_config_cache_file_name))
239
+ end
240
+
241
+ def self.local_cache_dir
242
+ Pvcglue.configuration.pvcglue_tmp_dir
243
+ end
244
+
245
+ def self.machine_cache_file_name
246
+ # TODO: Remove caching, maybe?
247
+ File.join(local_cache_dir, 'pvcglue-machines.json')
248
+ end
249
+
250
+ def self.ssh_config_cache_file_name
222
251
  # TODO: Remove caching, maybe?
223
- File.join(Pvcglue::Configuration.application_dir, 'tmp', 'pvcglue-machines.json')
252
+ File.join(local_cache_dir, 'pvcglue-ssh-config.json')
224
253
  end
225
254
  end
226
255
 
@@ -130,6 +130,7 @@ module Pvcglue
130
130
  end
131
131
 
132
132
  def self.read_cached_cloud_data
133
+ return false # disable cache for now
133
134
  # TODO: Expire cache after given interval
134
135
  if File.exists?(Pvcglue.configuration.cloud_cache_file_name)
135
136
  data = File.read(Pvcglue.configuration.cloud_cache_file_name)
@@ -1,3 +1,3 @@
1
1
  module Pvcglue
2
- VERSION = "0.1.20"
2
+ VERSION = "0.1.21"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pvcglue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20
4
+ version: 0.1.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Lyric
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-08 00:00:00.000000000 Z
11
+ date: 2015-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler