diff --git a/lib/fog/vcloudng/parsers/compute/get_network.rb b/lib/fog/vcloudng/parsers/compute/get_network.rb index 46807e3c3..a6fcd55e7 100644 --- a/lib/fog/vcloudng/parsers/compute/get_network.rb +++ b/lib/fog/vcloudng/parsers/compute/get_network.rb @@ -1,3 +1,29 @@ +# +# +# +# +# +# +# +# +# true +# 10.192.0.1 +# 255.255.252.0 +# 10.192.0.11 +# 10.192.0.12 +# dev.ad.mdsol.com +# +# +# 10.192.0.100 +# 10.192.3.254 +# +# +# +# bridged +# false +# +# + module Fog module Parsers module Vcloudng @@ -8,31 +34,32 @@ module Fog def reset @response = { - "links" => [] + "Links" => [], "IpRanges" => [] } + @ip_range = {} 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 + @response["Links"] << link end end def end_element(name) case name - when "Gateway", "Netmask", "FenceMode" - @response[name.downcase] = value + when "Gateway", "Netmask", "Dns1", "Dns2", "DnsSuffix", "FenceMode" + @response[name] = value + when "IsInherited", "RetainNetInfoAcrossDeployments" + @response[name] = value.to_bool + when "StartAddress", "EndAddress" + @ip_range[name] = value + if @ip_range.keys.size == 2 + @response["IpRanges"] << @ip_range + @ip_range = {} + end end end diff --git a/lib/fog/vcloudng/shared.rb b/lib/fog/vcloudng/shared.rb index 94e28802f..c9ce9bbd6 100644 --- a/lib/fog/vcloudng/shared.rb +++ b/lib/fog/vcloudng/shared.rb @@ -1,3 +1,11 @@ +class String + def to_bool + return true if self == true || self =~ (/(true|t|yes|y|1)$/i) + return false if self == false || self.empty? || self =~ (/(false|f|no|n|0)$/i) + raise ArgumentError.new("invalid value for Boolean: \"#{self}\"") + end +end + module Fog module Vcloudng module Shared