right_agent 0.10.5 → 0.10.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/right_agent/platform.rb +8 -3
- data/right_agent.gemspec +1 -1
- data/spec/platform/platform_spec.rb +23 -1
- metadata +3 -3
data/lib/right_agent/platform.rb
CHANGED
@@ -159,7 +159,7 @@ module RightScale
|
|
159
159
|
# Are we in an EC2 cloud?
|
160
160
|
#
|
161
161
|
# === Return
|
162
|
-
# true:: If machine is located in an
|
162
|
+
# true:: If machine is located in an EC2 cloud
|
163
163
|
# false:: Otherwise
|
164
164
|
def ec2?
|
165
165
|
resolve_cloud_type if @ec2.nil?
|
@@ -288,17 +288,22 @@ module RightScale
|
|
288
288
|
# Determines which cloud we're on by the cheap but simple expedient of
|
289
289
|
# reading the RightScale cloud file
|
290
290
|
def resolve_cloud_type
|
291
|
-
cloud_type =
|
291
|
+
cloud_type = read_cloud_file
|
292
292
|
@ec2 = false
|
293
293
|
@rackspace = false
|
294
294
|
@eucalyptus = false
|
295
295
|
case cloud_type
|
296
|
-
when 'ec2' then ec2 = true
|
296
|
+
when 'ec2' then @ec2 = true
|
297
297
|
when 'rackspace' then @rackspace = true
|
298
298
|
when 'eucalyptus' then @eucalyptus = true
|
299
299
|
end
|
300
300
|
end
|
301
301
|
|
302
|
+
# Reads the RightScale cloud file and returns its contents
|
303
|
+
def read_cloud_file
|
304
|
+
File.read(File.join(self.filesystem.right_scale_state_dir, 'cloud')) rescue nil
|
305
|
+
end
|
306
|
+
|
302
307
|
# Retrieve platform specific service implementation
|
303
308
|
#
|
304
309
|
# === Parameters
|
data/right_agent.gemspec
CHANGED
@@ -24,7 +24,7 @@ require 'rubygems'
|
|
24
24
|
|
25
25
|
Gem::Specification.new do |spec|
|
26
26
|
spec.name = 'right_agent'
|
27
|
-
spec.version = '0.10.
|
27
|
+
spec.version = '0.10.6'
|
28
28
|
spec.date = '2012-05-08'
|
29
29
|
spec.authors = ['Lee Kirchhoff', 'Raphael Simon', 'Tony Spataro']
|
30
30
|
spec.email = 'lee@rightscale.com'
|
@@ -58,6 +58,28 @@ module RightScale
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
|
+
context 'cloud-family queries' do
|
63
|
+
# PLEASE NOTE: we are unable to use the magic RSpec "subject" because
|
64
|
+
# we are dispatching calls to a Singleton and we must partially mock its
|
65
|
+
# calls, and both __send__ and flexmock partial-mocking gets confused by
|
66
|
+
# the fact that #subject returns a Proc, not the actual subject. Do not
|
67
|
+
# attempt to use the pretty RSpec feature within this context. You have
|
68
|
+
# been warned!
|
69
|
+
before(:each) do
|
70
|
+
@subject = subject.instance
|
71
|
+
@subject.instance_variable_set(:@ec2, nil)
|
72
|
+
@subject.instance_variable_set(:@rackspace, nil)
|
73
|
+
@subject.instance_variable_set(:@eucalyptus, nil)
|
74
|
+
end
|
75
|
+
|
76
|
+
['ec2', 'rackspace', 'eucalyptus'].each do |cloud|
|
77
|
+
it "should detect #{cloud}" do
|
78
|
+
query = "#{cloud}?".to_sym
|
79
|
+
flexmock(@subject).should_receive(:read_cloud_file).once.and_return(cloud)
|
80
|
+
@subject.__send__(query).should be_true
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
62
84
|
end
|
63
85
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: right_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 10
|
9
|
-
-
|
10
|
-
version: 0.10.
|
9
|
+
- 6
|
10
|
+
version: 0.10.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Lee Kirchhoff
|