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

Vcloud director: Add static routing support to Edge Gateway

This commit is contained in:
Simas Cepaitis 2014-09-12 11:57:24 +01:00
parent 6d3be81162
commit d3d11ae68a
2 changed files with 49 additions and 1 deletions

View file

@ -15,6 +15,7 @@ module Fog
build_load_balancer_service(xml)
build_vpn(xml)
build_dhcp(xml)
build_static_routing_service(xml)
}
end.to_xml
end
@ -177,6 +178,27 @@ module Fog
}
end
def build_static_routing_service(xml)
routing_config = @configuration[:StaticRoutingService]
return unless routing_config
xml.StaticRoutingService {
xml.IsEnabled routing_config[:IsEnabled]
routing_config[:StaticRoute].each do |rule|
xml.StaticRoute{
xml.Name rule[:Name]
xml.Network rule[:Network]
xml.NextHopIp rule[:NextHopIp]
xml.GatewayInterface(
:type => rule[:GatewayInterface][:type],
:name => rule[:GatewayInterface][:name],
:href => rule[:GatewayInterface][:href]
)
}
end
}
end
def build_firewall_service(xml)
firewall_config = @configuration[:FirewallService]
return unless firewall_config

View file

@ -45,6 +45,24 @@ Shindo.tests('Compute::VcloudDirector | edge gateway requests', ['vclouddirector
}
}
@routing_service_configuration = {
:StaticRoutingService => {
:IsEnabled => "true",
:StaticRoute => [
{
:Name => "Test static route #1",
:Network => "192.168.192.0/24",
:NextHopIp => "192.168.0.1",
:GatewayServiceInterface => {
:name => '',
:type => '',
:href => ''
}
}
]
}
}
@new_edge_gateway_configuration = {
:FirewallService =>
{
@ -71,7 +89,7 @@ Shindo.tests('Compute::VcloudDirector | edge gateway requests', ['vclouddirector
}
]
}
}.merge!(@vpn_configuration).merge!(@dhcp_configuration)
}.merge!(@vpn_configuration).merge!(@dhcp_configuration).merge!(@routing_service_configuration)
@service = Fog::Compute::VcloudDirector.new
@org = VcloudDirector::Compute::Helper.current_org(@service)
@ -141,6 +159,14 @@ Shindo.tests('Compute::VcloudDirector | edge gateway requests', ['vclouddirector
edge_gateway[:Configuration][:EdgeGatewayServiceConfiguration][:FirewallService][:FirewallRule].find { |rule| rule[:Id] == FIREWALL_RULE_ID }
end
test('#check Static Routing service configuration').returns(true) do
response = @service.post_configure_edge_gateway_services(@edge_gateway_id,
@original_gateway_conf[:Configuration][:EdgeGatewayServiceConfiguration])
@service.process_task(response.body)
edge_gateway = @service.get_edge_gateway(@edge_gateway_id).body
edge_gateway[:Configuration][:EdgeGatewayServiceConfiguration][:StaticRoutingService][:IsEnabled] == "true"
end
tests('#check VPN xml from generator').returns(true) do
xml = Nokogiri.XML Fog::Generators::Compute::VcloudDirector::EdgeGatewayServiceConfiguration.new(@vpn_configuration).generate_xml
#Not comprehensive, only checks that the generator actually knows how to handle it and that the output looks vagely sane