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

[hp|network] Add request method for get_network.

This commit is contained in:
Rupak Ganguly 2013-03-21 14:54:07 -04:00
parent b1a94f9a2e
commit 24c7d7e407
3 changed files with 51 additions and 2 deletions

View file

@ -15,7 +15,7 @@ module Fog
request_path 'fog/hp/requests/network'
#request :create_network
#request :delete_network
#request :get_network
request :get_network
request :list_networks
#request :update_network

View file

@ -0,0 +1,49 @@
module Fog
module HP
class Network
class Real
# Get details for an existing network by id
#
# ==== Parameters
# * 'network_id'<~String>: - UUId for the network to get details for
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * network<~Hash>:
# * 'id'<~String>: - UUId for the network
# * 'name'<~String>: - Name of the network
# * 'tenant_id'<~String>: - TenantId that owns the network
# * 'status'<~String>: - Status of the network i.e. "ACTIVE"
# * 'subnets'<~Array>: - Subnets for the network
# * 'id'<~Integer>: - UUId for the subnet
# * 'router:external'<~Boolean>: - true or false
# * 'admin_state_up'<~Boolean>: - true or false
# * 'shared'<~Boolean>: - true or false
def get_network(network_id)
request(
:expects => 200,
:method => 'GET',
:path => "networks/#{network_id}"
)
end
end
class Mock
def get_network(network_id)
response = Excon::Response.new
if network = list_networks.body['networks'].detect {|_| _['id'] == network_id}
response.status = 200
response.body = { 'network' => network }
response
else
raise Fog::HP::Network::NotFound
end
end
end
end
end
end

View file

@ -13,7 +13,7 @@ module Fog
# * response<~Excon::Response>:
# * body<~Hash>:
# * networks<~Array>:
# * 'id'<~Integer>: - UUId for the network
# * 'id'<~String>: - UUId for the network
# * 'name'<~String>: - Name of the network
# * 'tenant_id'<~String>: - TenantId that owns the network
# * 'status'<~String>: - Status of the network i.e. "ACTIVE"