2009-08-17 12:45:00 -04:00
|
|
|
unless Fog.mocking?
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class EC2
|
|
|
|
|
|
|
|
# Create a new security group
|
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * group_name<~String> - Name of the security group.
|
|
|
|
# * group_description<~String> - Description of group.
|
|
|
|
#
|
|
|
|
# ==== Returns
|
2009-11-02 21:48:49 -05:00
|
|
|
# * response<~Excon::Response>:
|
2009-08-17 12:45:00 -04:00
|
|
|
# * body<~Hash>:
|
|
|
|
# * 'requestId'<~String> - Id of request
|
|
|
|
# * 'return'<~Boolean> - success?
|
|
|
|
def create_security_group(name, description)
|
2010-03-16 01:15:33 -04:00
|
|
|
request(
|
|
|
|
'Action' => 'CreateSecurityGroup',
|
|
|
|
'GroupName' => name,
|
|
|
|
'GroupDescription' => CGI.escape(description),
|
|
|
|
:parser => Fog::Parsers::AWS::EC2::Basic.new
|
|
|
|
)
|
2009-08-17 12:45:00 -04:00
|
|
|
end
|
|
|
|
|
2009-07-13 22:14:59 -04:00
|
|
|
end
|
2009-08-17 12:45:00 -04:00
|
|
|
end
|
|
|
|
end
|
2009-07-13 22:14:59 -04:00
|
|
|
|
2009-08-17 12:45:00 -04:00
|
|
|
else
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class EC2
|
|
|
|
|
|
|
|
def create_security_group(name, description)
|
2009-11-20 14:08:08 -05:00
|
|
|
response = Excon::Response.new
|
2009-08-20 22:25:52 -04:00
|
|
|
unless Fog::AWS::EC2.data[:security_groups][name]
|
2009-08-17 12:45:00 -04:00
|
|
|
data = {
|
2009-09-12 14:35:14 -04:00
|
|
|
'groupDescription' => description,
|
|
|
|
'groupName' => name,
|
2009-08-17 12:45:00 -04:00
|
|
|
'ipPermissions' => [],
|
2009-09-12 14:35:14 -04:00
|
|
|
'ownerId' => Fog::AWS::Mock.owner_id
|
2009-08-17 12:45:00 -04:00
|
|
|
}
|
2009-08-20 22:25:52 -04:00
|
|
|
Fog::AWS::EC2.data[:security_groups][name] = data
|
2009-08-17 12:45:00 -04:00
|
|
|
response.body = {
|
|
|
|
'requestId' => Fog::AWS::Mock.request_id,
|
|
|
|
'return' => true
|
|
|
|
}
|
|
|
|
else
|
|
|
|
response.status = 400
|
2009-11-20 14:08:08 -05:00
|
|
|
raise(Excon::Errors.status_error({:expects => 200}, response))
|
2009-08-17 12:45:00 -04:00
|
|
|
end
|
|
|
|
response
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2009-07-13 22:14:59 -04:00
|
|
|
end
|
|
|
|
end
|
2009-08-17 12:45:00 -04:00
|
|
|
|
2009-07-13 22:14:59 -04:00
|
|
|
end
|