cloudster 2.14.0 → 2.14.1
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.
- data/VERSION +1 -1
- data/cloudster.gemspec +2 -2
- data/lib/cloudster/cloud.rb +27 -0
- data/spec/cloud_spec.rb +33 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.14.
|
1
|
+
2.14.1
|
data/cloudster.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "cloudster"
|
8
|
-
s.version = "2.14.
|
8
|
+
s.version = "2.14.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Emil Soman"]
|
12
|
-
s.date = "2012-12-
|
12
|
+
s.date = "2012-12-28"
|
13
13
|
s.description = "Cloudster is a Ruby gem that was born to cut the learning curve involved \n in writing your own CloudFormation templates. If you don't know what a CloudFormation template is, \n but know about the AWS Cloud offerings, you can still use cloudster to provision your stack. \n Still in infancy , cloudster can create a very basic stack like a breeze. All kinds of contribution welcome !"
|
14
14
|
s.email = "emil.soman@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/cloudster/cloud.rb
CHANGED
@@ -401,6 +401,33 @@ module Cloudster
|
|
401
401
|
return ec2.describe_security_groups.body["securityGroupInfo"] rescue []
|
402
402
|
end
|
403
403
|
|
404
|
+
# Returns true if S3 bucket name is available, else returns false
|
405
|
+
#
|
406
|
+
# ==== Examples
|
407
|
+
# cloud = Cloudster::Cloud.new(
|
408
|
+
# :access_key_id => 'aws_access_key_id',
|
409
|
+
# :secret_access_key => 'aws_secret_access_key',
|
410
|
+
# :region => 'us-east-1'
|
411
|
+
# )
|
412
|
+
# cloud.is_s3_bucket_name_available?('test-bucket-name')
|
413
|
+
#
|
414
|
+
# ==== Parameter
|
415
|
+
# * String containing the bucket name
|
416
|
+
#
|
417
|
+
# ==== Returns
|
418
|
+
# * true - If bucket name is available
|
419
|
+
# * false - If bucket name is not available
|
420
|
+
def is_s3_bucket_name_available?(bucket_name)
|
421
|
+
s3 = Fog::Storage::AWS.new(:aws_access_key_id => @access_key_id, :aws_secret_access_key => @secret_access_key)
|
422
|
+
begin
|
423
|
+
response = s3.get_bucket(bucket_name)
|
424
|
+
rescue Exception => e
|
425
|
+
response = e.response
|
426
|
+
end
|
427
|
+
not_found_status = 404
|
428
|
+
return response.status == not_found_status
|
429
|
+
end
|
430
|
+
|
404
431
|
private
|
405
432
|
|
406
433
|
#Returns a hash {<logical_resource_id> => <physical_resource_id>}
|
data/spec/cloud_spec.rb
CHANGED
@@ -126,4 +126,37 @@ describe Cloudster::Cloud do
|
|
126
126
|
cloud.delete(:stack_name => 'stack_name')
|
127
127
|
end
|
128
128
|
end
|
129
|
+
|
130
|
+
describe "#is_s3_bucket_name_available?" do
|
131
|
+
it "should return true if bucket is available" do
|
132
|
+
cloud = Cloudster::Cloud.new(:access_key_id => 'test', :secret_access_key => 'test')
|
133
|
+
response = double('Response')
|
134
|
+
response.stub(:status).and_return(404)
|
135
|
+
s3 = double('S3')
|
136
|
+
s3.should_receive(:get_bucket).and_raise(Excon::Errors.status_error({:expects => 200}, response))
|
137
|
+
Fog::Storage::AWS.should_receive(:new).and_return(s3)
|
138
|
+
cloud.is_s3_bucket_name_available?('test-bucket-name').should be_true
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should return false if bucket access is forbidden" do
|
142
|
+
cloud = Cloudster::Cloud.new(:access_key_id => 'test', :secret_access_key => 'test')
|
143
|
+
response = double('Response')
|
144
|
+
response.stub(:status).and_return(403)
|
145
|
+
s3 = double('S3')
|
146
|
+
s3.should_receive(:get_bucket).and_raise(Excon::Errors.status_error({:expects => 200}, response))
|
147
|
+
Fog::Storage::AWS.should_receive(:new).and_return(s3)
|
148
|
+
cloud.is_s3_bucket_name_available?('test-bucket-name').should be_false
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should return false if bucket is already owned by user" do
|
152
|
+
cloud = Cloudster::Cloud.new(:access_key_id => 'test', :secret_access_key => 'test')
|
153
|
+
response = double('Response')
|
154
|
+
response.stub(:status).and_return(200)
|
155
|
+
s3 = double('S3')
|
156
|
+
s3.should_receive(:get_bucket).and_return response
|
157
|
+
Fog::Storage::AWS.should_receive(:new).and_return(s3)
|
158
|
+
cloud.is_s3_bucket_name_available?('test-bucket-name').should be_false
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
129
162
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.14.
|
4
|
+
version: 2.14.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
@@ -160,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
160
160
|
version: '0'
|
161
161
|
segments:
|
162
162
|
- 0
|
163
|
-
hash:
|
163
|
+
hash: 524787187
|
164
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
165
|
none: false
|
166
166
|
requirements:
|