Created
January 23, 2014 17:04
-
-
Save snehaso/8582515 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'vcloud' | |
module Vcloud | |
module EdgeGateway | |
module ConfigurationGenerator | |
class LoadBalancerService | |
def generate_config(input_config) | |
output_config = {} | |
output_config[:IsEnabled] = input_config.key?(:enabled) ? input_config[:enabled].to_s : 'true' | |
pools = [] | |
if in_pools = input_config[:pools] | |
in_pools.each do |pool| | |
out_pool = {} | |
out_pool[:name] = pool[:name] | |
out_pool[:ServicePort] = [ | |
{ IsEnabled: 'false', | |
Protocol: 'HTTP', | |
Port: '', | |
HealthCheckPort: '', | |
HealthCheck: { Mode: 'HTTP', Uri: '', HeathThreshold: '2', UnhealthThreshold: '3', Interval: '5', Timeout: '15' }, | |
}, | |
{ IsEnabled: 'false', | |
Protocol: 'HTTPS', | |
Port: '', | |
HealthCheckPort: '', | |
HealthCheck: { Mode: 'HTTPS', Uri: '', HeathThreshold: '2', UnhealthThreshold: '3', Interval: '5', Timeout: '15' }, | |
}, | |
{ IsEnabled: 'false', | |
Protocol: 'TCP', | |
Port: '', | |
HealthCheckPort: '', | |
HealthCheck: { Mode: 'TCP', Uri: '', HeathThreshold: '2', UnhealthThreshold: '3', Interval: '5', Timeout: '15' }, | |
}, | |
] | |
in_pool[:service_ports].each do |sp| | |
next unless sp[:protocol] =~ /^(HTTP|HTTPS|TCP)$/ | |
proto = $1 | |
out_pool[:ServicePort] | |
end | |
out_pool[:Description] = pool.key?(:description) ? pool[:description] : '' | |
out_pool[:Description] = pool.key?(:description) ? pool[:description] : '' | |
end | |
end | |
#firewall_service = {} | |
#firewall_service[:IsEnabled] = input_config.key?(:enabled) ? input_config[:enabled].to_s : 'true' | |
#firewall_service[:DefaultAction] = input_config.key?(:policy) ? input_config[:policy] : "drop" | |
#firewall_service[:LogDefaultAction] = input_config.key?(:log_default_action) ? input_config[:log_default_action].to_s : 'false' | |
#firewall_service[:FirewallRule] = populate_firewall_rules(input_config[:firewall_rules]) if input_config.key?(:firewall_rules) | |
#firewall_service | |
output_config | |
end | |
end | |
private | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment