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