mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[compute|openstack] cleanup for list security groups request/mock
This commit is contained in:
parent
230c61dad5
commit
b0fc6067e0
1 changed files with 14 additions and 10 deletions
|
@ -4,10 +4,14 @@ module Fog
|
|||
class Real
|
||||
|
||||
def list_security_groups(server_id = nil)
|
||||
path = "os-security-groups.json"
|
||||
if server_id
|
||||
path = "servers/#{server_id}/#{path}"
|
||||
end
|
||||
request(
|
||||
:expects => [200],
|
||||
:method => 'GET',
|
||||
:path => "#{%Q|servers/#{server_id}/| if server_id }os-security-groups.json"
|
||||
:path => path
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -15,13 +19,6 @@ module Fog
|
|||
|
||||
class Mock
|
||||
def list_security_groups
|
||||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
response.headers = {
|
||||
"X-Compute-Request-Id" => "req-#{Fog::Mock.random_base64(36)}",
|
||||
"Content-Type" => "application/json",
|
||||
"Date" => Date.new
|
||||
}
|
||||
self.data[:security_groups] ||= [
|
||||
{ "rules" => [
|
||||
{ "from_port" => 44,
|
||||
|
@ -61,8 +58,15 @@ module Fog
|
|||
"description" => "this is a test"
|
||||
}
|
||||
]
|
||||
response.body = { 'security_groups' => self.data[:security_groups] }
|
||||
response
|
||||
Excon::Response.new(
|
||||
:body => { 'security_groups' => self.data[:security_groups] },
|
||||
:headers => {
|
||||
"X-Compute-Request-Id" => "req-#{Fog::Mock.random_base64(36)}",
|
||||
"Content-Type" => "application/json",
|
||||
"Date" => Date.new
|
||||
},
|
||||
:status => 200
|
||||
)
|
||||
end
|
||||
end # mock
|
||||
end # openstack
|
||||
|
|
Loading…
Add table
Reference in a new issue