From d8be4421bc428bfee66c9e47059bc3da47ecf7d2 Mon Sep 17 00:00:00 2001 From: Dan Abel Date: Mon, 7 Oct 2013 13:13:22 +0100 Subject: [PATCH 1/3] support retrieving edge gateway status --- lib/fog/vcloud_director/compute.rb | 2 + .../requests/compute/get_edge_gateway.rb | 25 ++ .../requests/compute/get_edge_gateways.rb | 24 ++ .../requests/compute/edge_gateway_tests.rb | 51 ++++ .../requests/compute/schema_helper.rb | 237 ++++++++++++++++++ 5 files changed, 339 insertions(+) create mode 100644 lib/fog/vcloud_director/requests/compute/get_edge_gateway.rb create mode 100644 lib/fog/vcloud_director/requests/compute/get_edge_gateways.rb create mode 100644 tests/vcloud_director/requests/compute/edge_gateway_tests.rb diff --git a/lib/fog/vcloud_director/compute.rb b/lib/fog/vcloud_director/compute.rb index f56c6ca1c..dd5835236 100644 --- a/lib/fog/vcloud_director/compute.rb +++ b/lib/fog/vcloud_director/compute.rb @@ -126,6 +126,8 @@ module Fog request :put_memory request :put_network_connection_system_section_vapp request :put_vapp_metadata_item_metadata + request :get_edge_gateways + request :get_edge_gateway class Model < Fog::Model def initialize(attrs={}) diff --git a/lib/fog/vcloud_director/requests/compute/get_edge_gateway.rb b/lib/fog/vcloud_director/requests/compute/get_edge_gateway.rb new file mode 100644 index 000000000..0533c4987 --- /dev/null +++ b/lib/fog/vcloud_director/requests/compute/get_edge_gateway.rb @@ -0,0 +1,25 @@ +module Fog + module Compute + class VcloudDirector + class Real + # Retrieve an edge gateway + # + # @param [String] id Object identifier of the Edge Gateway + # @return [Excon::Response] + # * body<~Hash>: + # @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/GET-EdgeGateway.html + # vCloud API Documentation + # @since vCloud API version 5.1 + def get_edge_gateway(id) + request( + :expects => 200, + :method => 'GET', + :parser => Fog::ToHashDocument.new, + :path => "admin/edgeGateway/#{id}" + ) + end + end + end + end +end + diff --git a/lib/fog/vcloud_director/requests/compute/get_edge_gateways.rb b/lib/fog/vcloud_director/requests/compute/get_edge_gateways.rb new file mode 100644 index 000000000..f24925057 --- /dev/null +++ b/lib/fog/vcloud_director/requests/compute/get_edge_gateways.rb @@ -0,0 +1,24 @@ +module Fog + module Compute + class VcloudDirector + class Real + # List all gateways for this Org vDC. + # + # @param [String] vdc_id Object identifier of the VDC + # @return [Excon::Response] + # * body<~Hash>: + # @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/GET-OrgVdcGateways.html + # vCloud API Documentation + # @since vCloud API version 5.1 + def get_edge_gateways(vdc_id) + request( + :expects => 200, + :method => 'GET', + :parser => Fog::ToHashDocument.new, + :path => "admin/vdc/#{vdc_id}/edgeGateways" + ) + end + end + end + end +end diff --git a/tests/vcloud_director/requests/compute/edge_gateway_tests.rb b/tests/vcloud_director/requests/compute/edge_gateway_tests.rb new file mode 100644 index 000000000..f45584e05 --- /dev/null +++ b/tests/vcloud_director/requests/compute/edge_gateway_tests.rb @@ -0,0 +1,51 @@ +Shindo.tests('Compute::VcloudDirector | edge gateway requests', ['vclouddirector']) do + + @service = Fog::Compute::VcloudDirector.new + + tests('Get current organization') do + session = @service.get_current_session.body + link = session[:Link].detect do |l| + l[:type] == 'application/vnd.vmware.vcloud.org+xml' + end + @org = @service.get_organization(link[:href].split('/').last).body + end + + tests('Get first vdc') do + link = @org[:Link].detect do |l| + l[:type] == 'application/vnd.vmware.vcloud.vdc+xml' + end + @vdc_id = link[:href].split('/').last + end + + tests('#get_edge_gateways').data_matches_schema(VcloudDirector::Compute::Schema::QUERY_RESULT_RECORDS_TYPE) do + pending if Fog.mocking? + + @edge_gateways = @service.get_edge_gateways(@vdc_id).body + + # ensure that EdgeGatewayRecord is a list + if @edge_gateways[:EdgeGatewayRecord].is_a?(Hash) + @edge_gateways[:EdgeGatewayRecord] = [@edge_gateways[:EdgeGatewayRecord]] + end + + @edge_gateways[:EdgeGatewayRecord].each do |result| + tests("each EdgeGatewayRecord should follow schema") + .data_matches_schema(VcloudDirector::Compute::Schema::QUERY_RESULT_EDGE_GATEWAY_RECORD_TYPE) { result } + end + + @edge_gateways + end + + tests('#get_edge_gateway').data_matches_schema(VcloudDirector::Compute::Schema::GATEWAY_TYPE) do + pending if Fog.mocking? + + @service.get_edge_gateway(@edge_gateways[:EdgeGatewayRecord].first[:href].split('/').last).body + end + + + tests('Retrieve non-existent edge gateway').raises(Excon::Errors::Forbidden) do + @service.get_edge_gateway('00000000-0000-0000-0000-000000000000') + end + + + +end diff --git a/tests/vcloud_director/requests/compute/schema_helper.rb b/tests/vcloud_director/requests/compute/schema_helper.rb index 47fdfd117..fa30c33fe 100644 --- a/tests/vcloud_director/requests/compute/schema_helper.rb +++ b/tests/vcloud_director/requests/compute/schema_helper.rb @@ -257,6 +257,243 @@ class VcloudDirector :OperatingSystemFamilyInfo => [OPERATING_SYSTEM_FAMILY_INFO_TYPE] }) + # Container for query results in records format. + # Combine with QUERY_RESULT_RECORD_TYPE subtypes to validate query results + QUERY_RESULT_RECORDS_TYPE = { + :href => Fog::Nullable::String, + :type => Fog::Nullable::String, + :name => Fog::Nullable::String, + :page => Fog::Nullable::String, + :pageSize => Fog::Nullable::String, + :total => Fog::Nullable::String, + } + + # Base type for a single record from query result in records format. + # Subtypes define more specific elements. + QUERY_RESULT_RECORD_TYPE = { + :href => String, + :id => Fog::Nullable::String, + :type => Fog::Nullable::String + } + + # Type for a single edgeGateway query result in records format. + QUERY_RESULT_EDGE_GATEWAY_RECORD_TYPE = QUERY_RESULT_RECORD_TYPE.merge({ + :gatewayStatus => String, + :haStatus => String, + :isBusy => String, + :name => String, + :numberOfExtNetworks => String, + :numberOfOrgNetworks=> String, + :vdc => String + }) + + FIREWALL_RULE_TYPE__PROTOCOLS = { + :Icmp => Fog::Nullable::String, + :Asny => Fog::Nullable::String, + :Other => Fog::Nullable::String + } + + + # Represents a firewall rule. + FIREWALL_RULE_TYPE = { + :Id => String, + :IsEnabled => String, + :MatchOnTranslate => Fog::Nullable::String, + :Description => Fog::Nullable::String, + :Policy => Fog::Nullable::String, + :IcmpSubType => Fog::Nullable::String, + :Port => Fog::Nullable::String, + :DestinationPortRange => String, + :SourcePort => Fog::Nullable::String, + :SourcePortRange => String, + :Direction => Fog::Nullable::String, + :EnableLogging => Fog::Nullable::String, + :Protocols => FIREWALL_RULE_TYPE__PROTOCOLS + } + + # Represents a network firewall service. + FIREWALL_SERVICE_TYPE = { + :IsEnabled => String, + :DefaultAction => String, + :LogDefaultAction => String, + :FirewallRule => [FIREWALL_RULE_TYPE] + } + + #Represents the SNAT and DNAT rules. + GATEWAY_NAT_RULE_TYPE = { + :Interface => REFERENCE_TYPE, + :OriginalIp => String, + :OriginalPort => Fog::Nullable::String, + :TranslatedIp => String, + :TranslatedPort => Fog::Nullable::String, + :Protocol => Fog::Nullable::String, + :IcmpSubType => Fog::Nullable::String + } + + #Represents a NAT rule. + NAT_RULE_TYPE = { + :Description => Fog::Nullable::String, + :RuleType => String, + :IsEnabled => String, + :Id => String, + :GatewayNatRule => GATEWAY_NAT_RULE_TYPE + } + + # Represents a NAT network service. + NAT_SERVICE_TYPE = { + :IsEnabled => String, + :NatType => Fog::Nullable::String, + :Policy => Fog::Nullable::String, + :NatRule => [NAT_RULE_TYPE], + :ExternalIp => Fog::Nullable::String + } + + # Represents a service port in a load balancer pool. + LB_POOL_SERVICE_PORT_TYPE = { + :IsEnabled => Fog::Nullable::String, + :Protocol => String, + :Algorithm => Fog::Nullable::String, + :Port => String, + :HealthCheckPort => String, + #:HealthCheck => LBPoolHealthCheckType # not required + } + + # Represents a member in a load balancer pool. + LB_POOL_MEMBER_TYPE = { + :IpAddress => String, + :Weight => String, + :ServicePort => [LB_POOL_SERVICE_PORT_TYPE] + } + + # Represents a load balancer pool. + LOAD_BALANCER_POOL_TYPE = { + :Id => Fog::Nullable::String, + :Name => String, + :Description => Fog::Nullable::String, + :ServicePort => [LB_POOL_SERVICE_PORT_TYPE], + :Member => [LB_POOL_MEMBER_TYPE], + :Operational => String, + :ErrorDetails => Fog::Nullable::String + } + + # Represents persistence type for a load balancer service profile. + LB_PERSISTENCE_TYPE = { + :Method => String, + :CookieName => Fog::Nullable::String, + :CookieMode => Fog::Nullable::String + } + + # Represents service profile for a load balancing virtual server. + LB_VIRTUAL_SERVER_SERVICE_PROFILE_TYPE = { + :IsEnabled => String, + :Protocol => String, + :Port => String, + :Persistence => LB_PERSISTENCE_TYPE + } + + # Information about a vendor service template. This is optional. + VENDOR_TEMPLATE_TYPE = { + :Name => String, + :Id => String + } + + # Represents a load balancer virtual server. + LOAD_BALANCER_VIRTUAL_SERVER_TYPE = { + :IsEnabled => String, + :Name => String, + :Description => Fog::Nullable::String, + :Interface => REFERENCE_TYPE, + :IpAddress => String, + :ServiceProfile => [LB_VIRTUAL_SERVER_SERVICE_PROFILE_TYPE], + :Logging => String, + :Pool => String, + #:LoadBalancerTemplates => VENDOR_TEMPLATE_TYPE # not required + } + + # Represents gateway load balancer service. + LOAD_BALANCER_SERVICE_TYPE = { + :Pool => LOAD_BALANCER_POOL_TYPE, + :VirtualServer => LOAD_BALANCER_VIRTUAL_SERVER_TYPE, + :IsEnabled => Fog::Nullable::String + } + + # Represents Gateway DHCP service. + GATEWAY_DHCP_SERVICE_TYPE = { + :IsEnabled => String, + #:Pool => DHCP_POOL_SERVICE_TYPE # not required + } + + # Represents edge gateway services. + GATEWAY_FEATURES_TYPE = { + #:StaticRoutingService => STATIC_ROUTING_SERVICE_TYPE, #not required + #:GatewayIpsecVpnService => GATEWAY_IPSEC_VPN_SERVICE_TYPE, #not required + #:GatewayDhcpService => GATEWAY_DHCP_SERVICE_TYPE, #not required + #:LoadBalancerService => LOAD_BALANCER_SERVICE_TYPE, #not required + :NatService => NAT_SERVICE_TYPE, + :FirewallService => FIREWALL_SERVICE_TYPE + } + + # Represents a range of IP addresses, start and end inclusive. + IP_RANGE_TYPE = { + :StartAddress => String, + :EndAddress => String + } + + # Represents a list of IP ranges. + IP_RANGES_TYPE = { + :IpRange => [IP_RANGE_TYPE] + } + + # Allows to chose which subnets a gateway can be part of + SUBNET_PARTICIPATION_TYPE = { + :Gateway => String, + :Netmask => String, + :IpAddress => String, + :IpRanges => IP_RANGES_TYPE + } + + # Gateway Interface configuration. + GATEWAY_INTERFACE_TYPE = { + :Name => String, + :DisplayName => String, + :Network => REFERENCE_TYPE, + :InterfaceType => String, + #:SubnetParticipation => [SUBNET_PARTICIPATION_TYPE], #bug in parser means list or hash + :ApplyRateLimit => String, + :InRateLimit => Fog::Nullable::String, + :OutRateLimit => Fog::Nullable::String, + :UseForDefaultRoute => String, + } + + # A list of Gateway Interfaces. + GATEWAY_INTERFACES_TYPE = { + :GatewayInterface => [GATEWAY_INTERFACE_TYPE] + } + + # Gateway Configuration. + GATEWAY_CONFIGURATION_TYPE = { + :BackwardCompatibilityMode => Fog::Nullable::String, + :GatewayBackingConfig => String, + :GatewayInterfaces => GATEWAY_INTERFACES_TYPE, + :EdgeGatewayServiceConfiguration => GATEWAY_FEATURES_TYPE, + :HaEnabled => Fog::Nullable::String, + :UseDefaultRouteForDnsRelay => Fog::Nullable::String + } + + # Represents a gateway. + GATEWAY_TYPE = { + :href => String, + :type => String, + :id => String, + :operationKey => Fog::Nullable::String, + :name => String, + :status => Fog::Nullable::String, + #:Link => LINK_TYPE, # not required + :Description => Fog::Nullable::String, + #:Tasks => TASKS_IN_PROGRESS_TYPE, # not required + :Configuration => GATEWAY_CONFIGURATION_TYPE + } + end end end From 91bec6fe30caccb4b5e4ac0f6f70f202fecd812b Mon Sep 17 00:00:00 2001 From: Dan Abel Date: Mon, 7 Oct 2013 17:10:13 +0100 Subject: [PATCH 2/3] ensuring tests are good for empty orgs and are skipped when mocking --- tests/vcloud_director/requests/compute/edge_gateway_tests.rb | 2 ++ tests/vcloud_director/requests/compute/schema_helper.rb | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/vcloud_director/requests/compute/edge_gateway_tests.rb b/tests/vcloud_director/requests/compute/edge_gateway_tests.rb index f45584e05..d0ba4d873 100644 --- a/tests/vcloud_director/requests/compute/edge_gateway_tests.rb +++ b/tests/vcloud_director/requests/compute/edge_gateway_tests.rb @@ -43,6 +43,8 @@ Shindo.tests('Compute::VcloudDirector | edge gateway requests', ['vclouddirector tests('Retrieve non-existent edge gateway').raises(Excon::Errors::Forbidden) do + pending if Fog.mocking? + @service.get_edge_gateway('00000000-0000-0000-0000-000000000000') end diff --git a/tests/vcloud_director/requests/compute/schema_helper.rb b/tests/vcloud_director/requests/compute/schema_helper.rb index fa30c33fe..ce6fbfa12 100644 --- a/tests/vcloud_director/requests/compute/schema_helper.rb +++ b/tests/vcloud_director/requests/compute/schema_helper.rb @@ -316,7 +316,7 @@ class VcloudDirector :IsEnabled => String, :DefaultAction => String, :LogDefaultAction => String, - :FirewallRule => [FIREWALL_RULE_TYPE] + #:FirewallRule => [FIREWALL_RULE_TYPE] # not required } #Represents the SNAT and DNAT rules. @@ -344,7 +344,7 @@ class VcloudDirector :IsEnabled => String, :NatType => Fog::Nullable::String, :Policy => Fog::Nullable::String, - :NatRule => [NAT_RULE_TYPE], + #:NatRule => [NAT_RULE_TYPE], # not required :ExternalIp => Fog::Nullable::String } From c399318a4dc9d3aed14cb3d1e4c03812b3fe271c Mon Sep 17 00:00:00 2001 From: Dan Abel Date: Tue, 8 Oct 2013 10:14:50 +0100 Subject: [PATCH 3/3] Mocks for get_edge_gateways & get edge gateway --- lib/fog/vcloud_director/compute.rb | 56 +++++++++++++- .../requests/compute/get_edge_gateway.rb | 76 ++++++++++++++++++- .../requests/compute/get_edge_gateways.rb | 55 ++++++++++++++ .../requests/compute/edge_gateway_tests.rb | 17 ++--- 4 files changed, 187 insertions(+), 17 deletions(-) diff --git a/lib/fog/vcloud_director/compute.rb b/lib/fog/vcloud_director/compute.rb index dd5835236..91b0f99a8 100644 --- a/lib/fog/vcloud_director/compute.rb +++ b/lib/fog/vcloud_director/compute.rb @@ -326,6 +326,11 @@ module Fog def data @@data ||= Hash.new do |hash, key| + + vdc_uuid = uuid + default_network_uuid = uuid + uplink_network_uuid = uuid + hash[key] = { :catalogs => { uuid => { @@ -340,19 +345,55 @@ module Fog }, :medias => {}, :networks => { - uuid => { - :Description => 'Network for mocking', + default_network_uuid => { + :ApplyRateLimit => "false", + :Description => 'Org Network for mocking', :Dns1 => '8.8.8.8', :Dns2 => '8.8.4.4', :DnsSuffix => 'example.com', :Gateway => '192.168.1.1', + :InterfaceType => "internal", :IpRanges => [{ :StartAddress=>'192.168.1.2', :EndAddress=>'192.168.1.254' }], :IsInherited => false, :Netmask => '255.255.255.0', - :name => 'Default Network' + :name => 'Default Network', + :SubnetParticipation => { + :Gateway => "192.168.1.0", + :Netmask => "255.255.0.0", + :IpAddress => "192.168.1.0" + }, + :UseForDefaultRoute => "false" + }, + uplink_network_uuid => { + :ApplyRateLimit => "false", + :Description => 'Uplink Network for mocking', + :Dns1 => '8.8.8.8', + :Dns2 => '8.8.4.4', + :DnsSuffix => 'example.com', + :Gateway => '198.51.100.1', + :InterfaceType => "uplink", + :IpRanges => [{ + :StartAddress=>'198.51.100.2', + :EndAddress=>'198.51.100.254' + }], + :IsInherited => false, + :Netmask => '255.255.255.0', + :name => 'uplink Network', + :SubnetParticipation => { + :Gateway => "198.51.100.81", + :Netmask => "255.255.255.248", + :IpAddress => "198.51.100.83", + :IpRanges => { + :IpRange => { + :StartAddress => "198.51.100.84", + :EndAddress => "198.51.100.86" + } + } + }, + :UseForDefaultRoute => "true" } }, :org => { @@ -363,10 +404,17 @@ module Fog }, :tasks => {}, :vdcs => { - uuid => { + vdc_uuid => { :description => 'vDC for mocking', :name => 'MockVDC' } + }, + :edge_gateways => { + uuid => { + :name => 'MockEdgeGateway', + :vdc => vdc_uuid, + :networks => [uplink_network_uuid, default_network_uuid] + } } } end[@vcloud_director_username] diff --git a/lib/fog/vcloud_director/requests/compute/get_edge_gateway.rb b/lib/fog/vcloud_director/requests/compute/get_edge_gateway.rb index 0533c4987..2b7c2b719 100644 --- a/lib/fog/vcloud_director/requests/compute/get_edge_gateway.rb +++ b/lib/fog/vcloud_director/requests/compute/get_edge_gateway.rb @@ -19,7 +19,79 @@ module Fog ) end end + + class Mock + def get_edge_gateway(id) + response = Excon::Response.new + + unless valid_uuid?(id) + response.status = 400 + raise Excon::Errors.status_error({:expects => 200}, response) + end + + unless edge_gateway = data[:edge_gateways][id] + response.status = 403 + raise Excon::Errors.status_error({:expects => 200}, response) + end + + vdc_id = edge_gateway[:vdc] + + body = { + :xmlns => xmlns, + :xmlns_xsi => xmlns_xsi, + :status => "1", + :name => edge_gateway[:name], + :id => "urn:vcloud:gateway:27805d5d-868b-4678-b30b-11e14ad34eca", + :type => "application/vnd.vmware.admin.edgeGateway+xml", + :href => make_href("admin/edgeGateway/#{id}"), + :xsi_schemaLocation => xsi_schema_location, + :Link =>[{:rel => "up", + :type => "application/vnd.vmware.vcloud.vdc+xml", + :href => make_href("vdc/#{vdc_id}")}, + {:rel => "edgeGateway:redeploy", + :href => make_href("admin/edgeGateway/#{id}/action/redeploy")}, + {:rel => "edgeGateway:configureServices", + :type => "application/vnd.vmware.admin.edgeGatewayServiceConfiguration+xml", + :href => make_href("admin/edgeGateway/#{id}/action/configureServices")}, + {:rel => "edgeGateway:reapplyServices", + :href => make_href("admin/edgeGateway/#{id}/action/reapplyServices")}, + {:rel => "edgeGateway:syncSyslogSettings", + :href => make_href("admin/edgeGateway/#{id}/action/syncSyslogServerSettings")}], + :Description => "vCloud CI (nft00052i2)", + :Configuration => + {:GatewayBackingConfig => "compact", + :GatewayInterfaces => + {:GatewayInterface => []}, + :EdgeGatewayServiceConfiguration => + {:FirewallService => + {:IsEnabled => "true", + :DefaultAction => "drop", + :LogDefaultAction => "false"}, + :NatService => {:IsEnabled => "true"}}, + :HaEnabled => "false", + :UseDefaultRouteForDnsRelay => "false"}} + + body[:Configuration][:GatewayInterfaces][:GatewayInterface] += edge_gateway[:networks].map do |network| + + extras = { + :Network => { + :type => "application/vnd.vmware.admin.network+xml", + :name => "anything", + :href => make_href("admin/network/#{network}") + }, + :Name => data[:networks][network][:name], + :DisplayName => data[:networks][network][:name] + } + + data[:networks][network].merge extras + end + + response.status = 200 + response.headers = {'Content-Type' => "#{body[:type]};version=#{api_version}"} + response.body = body + response + end + end end end -end - +end \ No newline at end of file diff --git a/lib/fog/vcloud_director/requests/compute/get_edge_gateways.rb b/lib/fog/vcloud_director/requests/compute/get_edge_gateways.rb index f24925057..d643a4b5c 100644 --- a/lib/fog/vcloud_director/requests/compute/get_edge_gateways.rb +++ b/lib/fog/vcloud_director/requests/compute/get_edge_gateways.rb @@ -19,6 +19,61 @@ module Fog ) end end + + class Mock + def get_edge_gateways(vdc_id) + response = Excon::Response.new + + unless valid_uuid?(vdc_id) + response.status = 400 + raise Excon::Errors.status_error({:expects => 200}, response) + end + unless vdc = data[:vdcs][vdc_id] + response.status = 403 + raise Excon::Errors.status_error({:expects => 200}, response) + end + + body = + {:xmlns => xmlns, + :xmlns_xsi => xmlns_xsi, + :total => "1", + :pageSize => "25", + :page => "1", + :name => "edgeGateways", + :type => "application/vnd.vmware.vcloud.query.records+xml", + :href => make_href("admin/vdc/#{vdc_id}edgeGateways?page=1&pageSize=25&format=records"), + :xsi_schemaLocation => xsi_schema_location, + :Link => + [{:rel => "alternate", + :type => "application/vnd.vmware.vcloud.query.references+xml", + :href => make_href("admin/vdc/#{vdc_id}edgeGateways?page=1&pageSize=25&format=references")}, + {:rel => "alternate", + :type => "application/vnd.vmware.vcloud.query.idrecords+xml", + :href => make_href("admin/vdc/#{vdc_id}edgeGateways?page=1&pageSize=25&format=records")}], + :EdgeGatewayRecord => []} + + vdc_edge_gateways = data[:edge_gateways].select do |id, edge_gateway| + edge_gateway[:vdc] == vdc_id + end + + body[:EdgeGatewayRecord] += vdc_edge_gateways.map do |id, edge_gateway| + {:vdc => make_href("vdc/#{vdc_id}"), + :numberOfOrgNetworks => "1", + :numberOfExtNetworks => "1", + :name => edge_gateway[:name], + :isBusy => "false", + :haStatus => "DISABLED", + :gatewayStatus => "READY", + :href => make_href("admin/edgeGateway/#{id}"), + :isSyslogServerSettingInSync => "true"} + end + + response.status = 200 + response.headers = {'Content-Type' => "#{body[:type]};version=#{api_version}"} + response.body = body + response + end + end end end end diff --git a/tests/vcloud_director/requests/compute/edge_gateway_tests.rb b/tests/vcloud_director/requests/compute/edge_gateway_tests.rb index d0ba4d873..04cdc46c0 100644 --- a/tests/vcloud_director/requests/compute/edge_gateway_tests.rb +++ b/tests/vcloud_director/requests/compute/edge_gateway_tests.rb @@ -18,8 +18,6 @@ Shindo.tests('Compute::VcloudDirector | edge gateway requests', ['vclouddirector end tests('#get_edge_gateways').data_matches_schema(VcloudDirector::Compute::Schema::QUERY_RESULT_RECORDS_TYPE) do - pending if Fog.mocking? - @edge_gateways = @service.get_edge_gateways(@vdc_id).body # ensure that EdgeGatewayRecord is a list @@ -28,26 +26,23 @@ Shindo.tests('Compute::VcloudDirector | edge gateway requests', ['vclouddirector end @edge_gateways[:EdgeGatewayRecord].each do |result| - tests("each EdgeGatewayRecord should follow schema") - .data_matches_schema(VcloudDirector::Compute::Schema::QUERY_RESULT_EDGE_GATEWAY_RECORD_TYPE) { result } + tests("each EdgeGatewayRecord should follow schema"). + data_matches_schema(VcloudDirector::Compute::Schema::QUERY_RESULT_EDGE_GATEWAY_RECORD_TYPE) { result } end @edge_gateways end tests('#get_edge_gateway').data_matches_schema(VcloudDirector::Compute::Schema::GATEWAY_TYPE) do - pending if Fog.mocking? - @service.get_edge_gateway(@edge_gateways[:EdgeGatewayRecord].first[:href].split('/').last).body end - tests('Retrieve non-existent edge gateway').raises(Excon::Errors::Forbidden) do - pending if Fog.mocking? - @service.get_edge_gateway('00000000-0000-0000-0000-000000000000') end + tests('Retrieve edge gateways for non-existent VDC').raises(Excon::Errors::Forbidden) do + @service.get_edge_gateways('00000000-0000-0000-0000-000000000000') + end - -end +end \ No newline at end of file