1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

create/delete for security groups

This commit is contained in:
Wesley Beary 2009-07-05 12:43:35 -07:00
parent a6f52d5e1c
commit c5f355130c
3 changed files with 65 additions and 2 deletions

View file

@ -48,11 +48,28 @@ module Fog
}, Fog::Parsers::AWS::EC2::AllocateAddress.new)
end
# Create a new security group
#
# ==== Parameters
# :group_name<~String>:: Name of the security group.
# :group_description<~String>:: Description of group.
#
# ==== Returns
# response::
# body<~Hash>::
# :return<~Boolean>:: success?
def create_security_group(name, description)
request({
'Action' => 'CreateSecurityGroup',
'GroupName' => name,
'GroupDescription' => CGI.escape(description)
}, Fog::Parsers::AWS::EC2::Basic.new)
end
# Create an EBS volume
#
# ==== Parameters
# :availability_zone<~String>::
# availability zone to create volume in
# :availability_zone<~String>:: availability zone to create volume in
# :size<~Integer>:: Size in GiBs for volume. Must be between 1 and 1024.
# :snapshot_id<~String>:: Optional, snapshot to create volume from
#
@ -74,6 +91,22 @@ module Fog
}, Fog::Parsers::AWS::EC2::CreateVolume.new)
end
# Delete a security group that you own
#
# ==== Parameters
# :group_name<~String>:: Name of the security group.
#
# ==== Returns
# response::
# body<~Hash>::
# :return<~Boolean>:: success?
def delete_security_group(name)
request({
'Action' => 'DeleteSecurityGroup',
'GroupName' => name
}, Fog::Parsers::AWS::EC2::Basic.new)
end
# Delete an EBS volume
#
# ==== Parameters

View file

@ -0,0 +1,15 @@
require File.dirname(__FILE__) + '/../../spec_helper'
describe 'EC2.create_security_group' do
after(:all) do
ec2.delete_security_group('fog_security_group')
end
it "should return proper attributes" do
actual = ec2.create_security_group('fog_security_group', 'a security group for testing fog')
actual.body[:request_id].should be_a(String)
[false, true].should include(actual.body[:return])
end
end

View file

@ -0,0 +1,15 @@
require File.dirname(__FILE__) + '/../../spec_helper'
describe 'EC2.delete_security_group' do
before(:all) do
ec2.create_security_group('fog_security_group', 'a security group for testing fog')
end
it "should return proper attributes" do
actual = ec2.delete_security_group('fog_security_group')
actual.body[:request_id].should be_a(String)
[false, true].should include(actual.body[:return])
end
end