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

support retrieving edge gateway status

This commit is contained in:
Dan Abel 2013-10-07 13:13:22 +01:00
parent 85b6ea13a4
commit d8be4421bc
5 changed files with 339 additions and 0 deletions

View file

@ -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={})

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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