rubber 2.6.0 → 2.6.1

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: 3ec3be4c2c2b486ddd2528e9db6b72b96d1fbf2f
4
- data.tar.gz: ad0afb86cac74f88bc397e87a851434015d6683c
3
+ metadata.gz: ec73202ff7ae4b8b7141a4628e7ab7d4b5e3d628
4
+ data.tar.gz: 1ed2f951bbd777e967b53185dd8fed1ae3692e5f
5
5
  SHA512:
6
- metadata.gz: 1184ac231a4cbdaad613d17749e53bf4a993d6affae6830ffd0b65a1ea9ea7af9a2a2965e86cc0408344cb4625f97a8071a1d8ac9b27963490687ba53a20f280
7
- data.tar.gz: 3f25823f1f87443b3d4f9f0b189e5c3572a74dd5deafd3cdc7368339168308b2d50181b3b717d33343308918049e3742ada873919d1c17e051ced82914efb3bd
6
+ metadata.gz: 040dedab057535bbb42a545bd2c77569153c7317530a8f118b879eef54596c74f6a619ba65cf1eced96b89a60bd6416d04f058e3a10f4520f2931f72712be9f7
7
+ data.tar.gz: b746357fc5923292cbd90fce4c05358598708caa33079f95a1509914ccd5367631ca9da9207b7bb14f694b2f9625cf09dfbb658317d35874d73a98c680134ae4
data/CHANGELOG CHANGED
@@ -1,3 +1,17 @@
1
+ 2.6.1 (11/06/2013)
2
+
3
+ Improvements:
4
+ ============
5
+
6
+ [core] Don't try to connect to the fog compute or storage providers until we actually need them. <5536511>
7
+
8
+ Bug Fixes:
9
+ =========
10
+
11
+ [core] Fixed a bug attaching EBS volumes, introduced by a recent refactoring. <51d2619>
12
+ [core] Fixed setup_remote_aliases to work when an SSH gateway is in place. <3a776f9>
13
+
14
+
1
15
  2.6.0 (11/05/2013)
2
16
 
3
17
  New Features:
@@ -42,7 +42,7 @@ module Rubber
42
42
  opts = {}
43
43
  opts["instance-id"] = instance_id if instance_id
44
44
 
45
- response = @compute_provider.servers.all(opts)
45
+ response = compute_provider.servers.all(opts)
46
46
  response.each do |item|
47
47
  instance = {}
48
48
  instance[:id] = item.id
@@ -158,14 +158,14 @@ module Rubber
158
158
  CMD
159
159
 
160
160
  image_location = "#{env.image_bucket}/#{image_name}.manifest.xml"
161
- response = @compute_provider.register_image(image_name,
161
+ response = compute_provider.register_image(image_name,
162
162
  "rubber bundled image",
163
163
  image_location)
164
164
  return response.body["imageId"]
165
165
  end
166
166
 
167
167
  def destroy_image(image_id)
168
- image = @compute_provider.images.get(image_id)
168
+ image = compute_provider.images.get(image_id)
169
169
  raise "Could not find image: #{image_id}, aborting destroy_image" if image.nil?
170
170
 
171
171
  location_parts = image.location.split('/')
@@ -204,7 +204,7 @@ module Rubber
204
204
 
205
205
  def describe_availability_zones
206
206
  zones = []
207
- response = @compute_provider.describe_availability_zones()
207
+ response = compute_provider.describe_availability_zones()
208
208
  items = response.body["availabilityZoneInfo"]
209
209
  items.each do |item|
210
210
  zone = {}
@@ -216,7 +216,7 @@ module Rubber
216
216
  end
217
217
 
218
218
  def create_spot_instance_request(spot_price, ami, ami_type, security_groups, availability_zone)
219
- response = @compute_provider.spot_requests.create(:price => spot_price,
219
+ response = compute_provider.spot_requests.create(:price => spot_price,
220
220
  :image_id => ami,
221
221
  :flavor_id => ami_type,
222
222
  :groups => security_groups,
@@ -230,7 +230,7 @@ module Rubber
230
230
  requests = []
231
231
  opts = {}
232
232
  opts["spot-instance-request-id"] = request_id if request_id
233
- response = @compute_provider.spot_requests.all(opts)
233
+ response = compute_provider.spot_requests.all(opts)
234
234
  response.each do |item|
235
235
  request = {}
236
236
  request[:id] = item.id
@@ -264,7 +264,7 @@ module Rubber
264
264
 
265
265
  opts = {}
266
266
  opts["group-name"] = group_name if group_name
267
- response = @compute_provider.security_groups.all(opts)
267
+ response = compute_provider.security_groups.all(opts)
268
268
 
269
269
  response.each do |item|
270
270
  group = {}
@@ -302,33 +302,33 @@ module Rubber
302
302
  end
303
303
 
304
304
  def create_volume(instance, volume_spec)
305
- volume = @compute_provider.volumes.create(:size => volume_spec['size'], :availability_zone => volume_spec['zone'])
305
+ volume = compute_provider.volumes.create(:size => volume_spec['size'], :availability_zone => volume_spec['zone'])
306
306
  volume.id
307
307
  end
308
308
 
309
309
  def after_create_volume(instance, volume_id, volume_spec)
310
310
  # After we create an EBS volume, we need to attach it to the instance.
311
- volume = @compute_provider.volumes.get(volume_id)
312
- server = @compute_provider.servers.get(instance.instance_id)
313
- volume.device = device
311
+ volume = compute_provider.volumes.get(volume_id)
312
+ server = compute_provider.servers.get(instance.instance_id)
313
+ volume.device = volume_spec['device']
314
314
  volume.server = server
315
315
  end
316
316
 
317
317
  def before_destroy_volume(volume_id)
318
318
  # Before we can destroy an EBS volume, we must detach it from any running instances.
319
- volume = @compute_provider.volumes.get(volume_id)
319
+ volume = compute_provider.volumes.get(volume_id)
320
320
  volume.force_detach
321
321
  end
322
322
 
323
323
  def destroy_volume(volume_id)
324
- @compute_provider.volumes.get(volume_id).destroy
324
+ compute_provider.volumes.get(volume_id).destroy
325
325
  end
326
326
 
327
327
  def describe_volumes(volume_id=nil)
328
328
  volumes = []
329
329
  opts = {}
330
330
  opts[:'volume-id'] = volume_id if volume_id
331
- response = @compute_provider.volumes.all(opts)
331
+ response = compute_provider.volumes.all(opts)
332
332
 
333
333
  response.each do |item|
334
334
  volume = {}
@@ -351,7 +351,7 @@ module Rubber
351
351
  def create_tags(resource_id, tags)
352
352
  # Tags need to be created individually in fog
353
353
  tags.each do |k, v|
354
- @compute_provider.tags.create(:resource_id => resource_id,
354
+ compute_provider.tags.create(:resource_id => resource_id,
355
355
  :key => k.to_s, :value => v.to_s)
356
356
  end
357
357
  end
@@ -359,15 +359,15 @@ module Rubber
359
359
  private
360
360
 
361
361
  def create_security_group(group_name, group_description)
362
- @compute_provider.security_groups.create(:name => group_name, :description => group_description)
362
+ compute_provider.security_groups.create(:name => group_name, :description => group_description)
363
363
  end
364
364
 
365
365
  def destroy_security_group(group_name)
366
- @compute_provider.security_groups.get(group_name).destroy
366
+ compute_provider.security_groups.get(group_name).destroy
367
367
  end
368
368
 
369
369
  def add_security_group_rule(group_name, protocol, from_port, to_port, source)
370
- group = @compute_provider.security_groups.get(group_name)
370
+ group = compute_provider.security_groups.get(group_name)
371
371
  opts = {:ip_protocol => protocol || 'tcp'}
372
372
 
373
373
  if source.instance_of? Hash
@@ -380,7 +380,7 @@ module Rubber
380
380
  end
381
381
 
382
382
  def remove_security_group_rule(group_name, protocol, from_port, to_port, source)
383
- group = @compute_provider.security_groups.get(group_name)
383
+ group = compute_provider.security_groups.get(group_name)
384
384
  opts = {:ip_protocol => protocol || 'tcp'}
385
385
 
386
386
  if source.instance_of? Hash
@@ -5,21 +5,24 @@ module Rubber
5
5
  module Cloud
6
6
 
7
7
  class Fog < Base
8
-
9
- attr_reader :compute_provider, :storage_provider
10
8
 
11
9
  def initialize(env, capistrano)
12
10
  super(env, capistrano)
13
11
 
14
- compute_credentials = Rubber::Util.symbolize_keys(env.compute_credentials) if env.compute_credentials
15
- storage_credentials = Rubber::Util.symbolize_keys(env.storage_credentials) if env.storage_credentials
12
+ @compute_credentials = Rubber::Util.symbolize_keys(env.compute_credentials) if env.compute_credentials
13
+ @storage_credentials = Rubber::Util.symbolize_keys(env.storage_credentials) if env.storage_credentials
14
+ end
15
+
16
+ def compute_provider
17
+ @compute_provider ||= @compute_credentials ? ::Fog::Compute.new(@compute_credentials) : nil
18
+ end
16
19
 
17
- @compute_provider = compute_credentials ? ::Fog::Compute.new(compute_credentials) : nil
18
- @storage_provider = storage_credentials ? ::Fog::Storage.new(storage_credentials) : nil
20
+ def storage_provider
21
+ @storage_provider ||= @storage_credentials ? ::Fog::Storage.new(@storage_credentials) : nil
19
22
  end
20
23
 
21
24
  def storage(bucket)
22
- return Rubber::Cloud::FogStorage.new(@storage_provider, bucket)
25
+ return Rubber::Cloud::FogStorage.new(storage_provider, bucket)
23
26
  end
24
27
 
25
28
  def table_store(table_key)
@@ -27,7 +30,7 @@ module Rubber
27
30
  end
28
31
 
29
32
  def create_instance(instance_alias, ami, ami_type, security_groups, availability_zone, region)
30
- response = @compute_provider.servers.create(:image_id => ami,
33
+ response = compute_provider.servers.create(:image_id => ami,
31
34
  :flavor_id => ami_type,
32
35
  :groups => security_groups,
33
36
  :availability_zone => availability_zone,
@@ -38,40 +41,40 @@ module Rubber
38
41
  end
39
42
 
40
43
  def destroy_instance(instance_id)
41
- response = @compute_provider.servers.get(instance_id).destroy()
44
+ response = compute_provider.servers.get(instance_id).destroy()
42
45
  end
43
46
 
44
47
  def destroy_spot_instance_request(request_id)
45
- @compute_provider.spot_requests.get(request_id).destroy
48
+ compute_provider.spot_requests.get(request_id).destroy
46
49
  end
47
50
 
48
51
  def reboot_instance(instance_id)
49
- response = @compute_provider.servers.get(instance_id).reboot()
52
+ response = compute_provider.servers.get(instance_id).reboot()
50
53
  end
51
54
 
52
55
  def stop_instance(instance, force=false)
53
56
  # Don't force the stop process. I.e., allow the instance to flush its file system operations.
54
- response = @compute_provider.servers.get(instance.instance_id).stop(force)
57
+ response = compute_provider.servers.get(instance.instance_id).stop(force)
55
58
  end
56
59
 
57
60
  def start_instance(instance)
58
- response = @compute_provider.servers.get(instance.instance_id).start()
61
+ response = compute_provider.servers.get(instance.instance_id).start()
59
62
  end
60
63
 
61
64
  def create_static_ip
62
- address = @compute_provider.addresses.create()
65
+ address = compute_provider.addresses.create()
63
66
  return address.public_ip
64
67
  end
65
68
 
66
69
  def attach_static_ip(ip, instance_id)
67
- address = @compute_provider.addresses.get(ip)
68
- server = @compute_provider.servers.get(instance_id)
70
+ address = compute_provider.addresses.get(ip)
71
+ server = compute_provider.servers.get(instance_id)
69
72
  response = (address.server = server)
70
73
  return ! response.nil?
71
74
  end
72
75
 
73
76
  def detach_static_ip(ip)
74
- address = @compute_provider.addresses.get(ip)
77
+ address = compute_provider.addresses.get(ip)
75
78
  response = (address.server = nil)
76
79
  return ! response.nil?
77
80
  end
@@ -80,7 +83,7 @@ module Rubber
80
83
  ips = []
81
84
  opts = {}
82
85
  opts["public-ip"] = ip if ip
83
- response = @compute_provider.addresses.all(opts)
86
+ response = compute_provider.addresses.all(opts)
84
87
  response.each do |item|
85
88
  ip = {}
86
89
  ip[:instance_id] = item.server_id
@@ -91,7 +94,7 @@ module Rubber
91
94
  end
92
95
 
93
96
  def destroy_static_ip(ip)
94
- address = @compute_provider.addresses.get(ip)
97
+ address = compute_provider.addresses.get(ip)
95
98
  return address.destroy
96
99
  end
97
100
 
@@ -103,7 +106,7 @@ module Rubber
103
106
  images = []
104
107
  opts = {"Owner" => "self"}
105
108
  opts["image-id"] = image_id if image_id
106
- response = @compute_provider.images.all(opts)
109
+ response = compute_provider.images.all(opts)
107
110
  response.each do |item|
108
111
  image = {}
109
112
  image[:id] = item.id
@@ -148,7 +148,7 @@ module Rubber
148
148
  end
149
149
 
150
150
  def create_volume(instance, volume_spec)
151
- server = @compute_provider.servers.get(instance.instance_id)
151
+ server = compute_provider.servers.get(instance.instance_id)
152
152
  datastore = volume_spec['datastore']
153
153
  thin_disk = volume_spec.has_key?('thin') ? volume_spec['thin'] : true
154
154
 
@@ -177,7 +177,7 @@ module Rubber
177
177
 
178
178
  def destroy_volume(volume_id)
179
179
  # TODO (nirvdrum 10/28/13): Fog currently lacks the ability to fetch a volume by ID, so we need to fetch all volumes for all servers to find the volume we want. This is terribly inefficient and fog should be updated.
180
- volume = @compute_provider.servers.collect { |s| s.volumes.all }.flatten.find { |v| v.id == volume_id }
180
+ volume = compute_provider.servers.collect { |s| s.volumes.all }.flatten.find { |v| v.id == volume_id }
181
181
 
182
182
  if volume.unit_number == 0
183
183
  raise "Cannot destroy volume because it is the VM root device. Destroy the VM if you really want to free this volume."
@@ -192,9 +192,9 @@ module Rubber
192
192
  opts[:'volume-id'] = volume_id if volume_id
193
193
 
194
194
  if volume_id
195
- response = [@compute_provider.servers.collect { |s| s.volumes.all }.flatten.find { |v| v.id == volume_id }]
195
+ response = [compute_provider.servers.collect { |s| s.volumes.all }.flatten.find { |v| v.id == volume_id }]
196
196
  else
197
- response = @compute_provider.servers.collect { |s| s.volumes.all }.flatten
197
+ response = compute_provider.servers.collect { |s| s.volumes.all }.flatten
198
198
  end
199
199
 
200
200
  response.each do |item|
@@ -247,7 +247,6 @@ module Rubber
247
247
  # Null values are represented as "null" in YAML, but Rubyists tend to use "nil", which will get translated
248
248
  # to the literal String "nil". Which guarding against this is arguably bad, letting "nil" go through as a valid
249
249
  # gateway value is even worse.
250
- puts "\n\nGateway: #{nic['gateway']}\n\n"
251
250
  if nic['gateway'] && nic['gateway'] != 'nil'
252
251
  hash['gateway'] = [nic['gateway']]
253
252
  end
@@ -187,15 +187,25 @@ namespace :rubber do
187
187
 
188
188
  replace="#{delim}\\n#{remote_hosts.join("\\n")}\\n#{delim}"
189
189
 
190
- rubber.sudo_script 'setup_remote_aliases', <<-ENDSCRIPT
190
+ setup_remote_aliases_script = <<-ENDSCRIPT
191
191
  sed -i.bak '/#{delim}/,/#{delim}/c #{replace}' /etc/hosts
192
192
  if ! grep -q "#{delim}" /etc/hosts; then
193
193
  echo -e "#{replace}" >> /etc/hosts
194
194
  fi
195
195
  ENDSCRIPT
196
196
 
197
+ # If an SSH gateway is being used to deploy to the cluster, we need to ensure that gateway has an updated /etc/hosts
198
+ # first, otherwise it won't be able to resolve the hostnames for the other servers we need to connect to.
199
+ gateway = fetch(:gateway, nil)
200
+ if gateway
201
+ rubber.sudo_script 'setup_remote_aliases', setup_remote_aliases_script, :hosts => gateway
202
+ end
203
+
204
+ rubber.sudo_script 'setup_remote_aliases', setup_remote_aliases_script
205
+
197
206
  # Setup hostname on instance so shell, etcs have nice display
198
207
  rsudo "echo $CAPISTRANO:HOST$ > /etc/hostname && hostname $CAPISTRANO:HOST$"
208
+
199
209
  # Newer ubuntus ec2-init script always resets hostname, so prevent it
200
210
  rsudo "mkdir -p /etc/ec2-init && echo compat=0 > /etc/ec2-init/is-compat-env"
201
211
  end
@@ -1,3 +1,3 @@
1
1
  module Rubber
2
- VERSION = "2.6.0"
2
+ VERSION = "2.6.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubber
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Conway
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-05 00:00:00.000000000 Z
12
+ date: 2013-11-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano