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

get_network implemented

This commit is contained in:
Rodrigo Estebanez 2013-06-12 19:50:20 +02:00
parent b6dcaf21e5
commit aeae34e948
3 changed files with 87 additions and 2 deletions

View file

@ -0,0 +1,44 @@
module Fog
module Parsers
module Vcloudng
module Compute
class GetNetwork < VcloudngParser
def reset
@response = {
"links" => []
}
end
def start_element(name,attributes=[])
super
case name
when "Network"
@response = extract_attributes(attributes)
if @response.has_key?("name")
@response["subnet"] = @response["name"]
end
if @response.has_key?("href")
@response["id"] = @response["href"].split("/").last
end
when "Link"
link = extract_attributes(attributes)
@response["links"] << link
end
end
def end_element(name)
case name
when "Gateway", "Netmask", "FenceMode"
@response[name.downcase] = value
end
end
end
end
end
end
end

View file

@ -0,0 +1,42 @@
module Fog
module Vcloudng
module Compute
class Real
require 'fog/vcloudng/parsers/compute/get_network'
# Get details for a Network
#
# ==== Parameters
# * network_id<~String> - Id of the network to look up
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
#
# ==== How to get the catalog_uuid?
#
# org_uuid = vcloud.get_organizations.data[:body]["OrgList"].first["href"].split('/').last
# org = vcloud.get_organization(org_uuid)
#
# network_id = org.data[:body]["Links"].detect {|l| l["type"] =~ /vcloud.orgNetwork/ }["href"].split('/').last
def get_network(network_id)
request(
:expects => 200,
:headers => { 'Accept' => 'application/*+xml;version=1.5' },
:method => 'GET',
:parser => Fog::Parsers::Vcloudng::Compute::GetNetwork.new,
:path => "network/#{network_id}"
)
end
def network_end_point(network_id = nil)
end_point + ( network_id ? "network/#{network_id}" : "network" )
end
end
end
end
end

View file

@ -260,7 +260,6 @@ module Fog
#require 'fog/vcloudng/parsers/compute/get_keys_list'
#require 'fog/vcloudng/parsers/compute/instantiate_vapp_template'
#require 'fog/vcloudng/parsers/compute/internet_service'
#require 'fog/vcloudng/parsers/compute/network'
#require 'fog/vcloudng/parsers/compute/node_service'
#require 'fog/vcloudng/parsers/compute/public_ip'
#require 'fog/vcloudng/parsers/compute/task'
@ -276,7 +275,7 @@ module Fog
require 'fog/vcloudng/requests/compute/get_catalog'
require 'fog/vcloudng/requests/compute/get_catalog_item'
#require 'fog/vcloudng/requests/compute/get_internet_services'
#require 'fog/vcloudng/requests/compute/get_network'
require 'fog/vcloudng/requests/compute/get_network'
#require 'fog/vcloudng/requests/compute/get_network_ips'
#require 'fog/vcloudng/requests/compute/get_node_services'
require 'fog/vcloudng/requests/compute/get_organization'