Class: Vcloud::EdgeGateway::ConfigurationGenerator::StaticRoutingService
- Inherits:
-
Object
- Object
- Vcloud::EdgeGateway::ConfigurationGenerator::StaticRoutingService
- Defined in:
- lib/vcloud/edge_gateway/configuration_generator/static_routing_service.rb
Instance Method Summary collapse
- #find_egw_interface(network_name) ⇒ Object
- #generate_fog_config ⇒ Object
- #generate_gateway_interface_section(network_name) ⇒ Object
- #generate_static_route_section ⇒ Object
-
#initialize(input_config, edge_gateway_interfaces) ⇒ StaticRoutingService
constructor
A new instance of StaticRoutingService.
- #routing_enabled? ⇒ Boolean
Constructor Details
#initialize(input_config, edge_gateway_interfaces) ⇒ StaticRoutingService
Returns a new instance of StaticRoutingService.
6 7 8 9 |
# File 'lib/vcloud/edge_gateway/configuration_generator/static_routing_service.rb', line 6 def initialize input_config, edge_gateway_interfaces @input_config = input_config @edge_gateway_interfaces = edge_gateway_interfaces end |
Instance Method Details
#find_egw_interface(network_name) ⇒ Object
51 52 53 |
# File 'lib/vcloud/edge_gateway/configuration_generator/static_routing_service.rb', line 51 def find_egw_interface(network_name) @edge_gateway_interfaces.find{|i| i.network_name == network_name} end |
#generate_fog_config ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/vcloud/edge_gateway/configuration_generator/static_routing_service.rb', line 11 def generate_fog_config return nil unless @input_config { IsEnabled: routing_enabled?, StaticRoute: generate_static_route_section } end |
#generate_gateway_interface_section(network_name) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/vcloud/edge_gateway/configuration_generator/static_routing_service.rb', line 35 def generate_gateway_interface_section(network_name) egw_interface = find_egw_interface(network_name) raise "unable to find gateway network interface with id #{network_id}" unless egw_interface { type: "application/vnd.vmware.vcloud.orgVdcNetwork+xml", name: egw_interface.network_name, href: egw_interface.network_href } end |
#generate_static_route_section ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/vcloud/edge_gateway/configuration_generator/static_routing_service.rb', line 19 def generate_static_route_section routes = @input_config[:static_routes] return [] if routes.nil? routes.collect do |route| route[:enabled] ||= 'true' { Name: route[:name], Network: route[:network], NextHopIp: route[:next_hop], IsEnabled: route[:enabled], GatewayInterface: generate_gateway_interface_section(route[:apply_on]) } end end |
#routing_enabled? ⇒ Boolean
46 47 48 49 |
# File 'lib/vcloud/edge_gateway/configuration_generator/static_routing_service.rb', line 46 def routing_enabled? return 'false' unless @input_config @input_config.key?(:enabled) ? @input_config[:enabled].to_s : 'true' end |