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

@rubiojr wrote mock code for openstack routers.

This commit is contained in:
Tomokazu Hirai 2013-02-28 10:44:56 +09:00
parent 55cffa7ad0
commit 54453be564
4 changed files with 8 additions and 8 deletions

View file

@ -39,15 +39,15 @@ module Fog
data = {
'router' => {
'status' => 'ACTIVE',
'external_gateway_info' => null,
'external_gateway_info' => nil,
'name' => 'another_router',
'admin_state_up' => true,
'tenant_id' => '6b96ff0cb17a4b859e1e575d221683d3',
'id' => '8604a0de-7f6b-409a-a47c-a1cc7bc77b2e'
}
}
self.data[:routers][data['id']] = data
response.body = { 'router' => data }
self.data[:routers] = []
self.data[:routers] << data['router']
response
end
end

View file

@ -15,10 +15,10 @@ module Fog
class Mock
def get_router(router_id)
response = Excon::Response.new
if data = self.data[:routers][router_id]
if data = (self.data[:routers].find { |r| r['id'] == router_id })
response.status = 200
response.body = {
'routers' => {
'router' => {
'status' => 'ACTIVE',
'external_gateway_info' => {
'network_id' => '3c5bcddd-6af9-4e6b-9c3e-c153e521cab8'

View file

@ -16,7 +16,7 @@ module Fog
class Mock
def list_routers(filters = {})
Excon::Response.new(
:body => { 'routers' => self.data[:routers].values },
:body => { 'routers' => (self.data[:routers] || []) },
:status => 200
)
end

View file

@ -52,7 +52,8 @@ module Fog
end
class Mock
def update_router(router_id, network_id, options = {})
def update_router(router_id, options = {})
raise Fog::Network::OpenStack::NotFound if router_id == 0
response = Excon::Response.new
response.status = 201
data = {
@ -65,7 +66,6 @@ module Fog
'tenant_id' => '6b96ff0cb17a4b859e1e575d221683d3',
'id' => '8604a0de-7f6b-409a-a47c-a1cc7bc77b2e'
}
self.data[:router_id][data['router_id']] = data
response.body = { 'router' => data }
response
end