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
|
class Real
|
||||||
|
|
||||||
def list_security_groups(server_id = nil)
|
def list_security_groups(server_id = nil)
|
||||||
|
path = "os-security-groups.json"
|
||||||
|
if server_id
|
||||||
|
path = "servers/#{server_id}/#{path}"
|
||||||
|
end
|
||||||
request(
|
request(
|
||||||
:expects => [200],
|
:expects => [200],
|
||||||
:method => 'GET',
|
:method => 'GET',
|
||||||
:path => "#{%Q|servers/#{server_id}/| if server_id }os-security-groups.json"
|
:path => path
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -15,13 +19,6 @@ module Fog
|
||||||
|
|
||||||
class Mock
|
class Mock
|
||||||
def list_security_groups
|
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] ||= [
|
self.data[:security_groups] ||= [
|
||||||
{ "rules" => [
|
{ "rules" => [
|
||||||
{ "from_port" => 44,
|
{ "from_port" => 44,
|
||||||
|
@ -61,8 +58,15 @@ module Fog
|
||||||
"description" => "this is a test"
|
"description" => "this is a test"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
response.body = { 'security_groups' => self.data[:security_groups] }
|
Excon::Response.new(
|
||||||
response
|
: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
|
||||||
end # mock
|
end # mock
|
||||||
end # openstack
|
end # openstack
|
||||||
|
|
Loading…
Add table
Reference in a new issue