From 4ed2bb37ea8283f79aecca8b78e80b141e9eff50 Mon Sep 17 00:00:00 2001 From: elijah Date: Wed, 24 Apr 2013 18:04:48 -0700 Subject: provider base - service definitions are now versioned (requires new leap_cli) --- .../files/service-definitions/eip-service.json.erb | 48 ---------------------- .../service-definitions/v1/eip-service.json.erb | 48 ++++++++++++++++++++++ provider_base/services/webapp.json | 5 ++- 3 files changed, 51 insertions(+), 50 deletions(-) delete mode 100644 provider_base/files/service-definitions/eip-service.json.erb create mode 100644 provider_base/files/service-definitions/v1/eip-service.json.erb (limited to 'provider_base') diff --git a/provider_base/files/service-definitions/eip-service.json.erb b/provider_base/files/service-definitions/eip-service.json.erb deleted file mode 100644 index ca42bef5..00000000 --- a/provider_base/files/service-definitions/eip-service.json.erb +++ /dev/null @@ -1,48 +0,0 @@ -<%= - def underscore(words) - words = words.to_s.dup - words.downcase! - words.gsub! /[^a-z]/, '_' - words - end - - def add_gateway(node, locations, options={}) - return nil if options[:ip] == 'REQUIRED' - gateway = {} - gateway["capabilities"] = node.openvpn.pick(:ports, :protocols, :user_ips, :adblock, :filter_dns) - gateway["capabilities"]["transport"] = ["openvpn"] - gateway["host"] = node.domain.full - gateway["ip_address"] = options[:ip] - gateway["capabilities"]["limited"] = options[:limited] - if node.location - location_name = underscore(node.location.name) - gateway["location"] = location_name - locations[location_name] ||= node.location - end - gateway - end - - hsh = {} - hsh["serial"] = 1 - hsh["version"] = 1 - locations = {} - gateways = [] - nodes_like_me[:services => 'openvpn'].each_node do |node| - if node.openvpn.allow_limited && node.openvpn.allow_unlimited - gateways << add_gateway(node, locations, :ip => node.openvpn.gateway_address, :limited => false) - gateways << add_gateway(node, locations, :ip => node.openvpn.second_gateway_address, :limited => true) - elsif node.openvpn.allow_unlimited - gateways << add_gateway(node, locations, :ip => node.openvpn.gateway_address, :limited => false) - elsif node.openvpn.allow_limited - gateways << add_gateway(node, locations, :ip => node.openvpn.gateway_address, :limited => true) - end - end - hsh["gateways"] = gateways.compact - hsh["locations"] = locations - hsh["openvpn_configuration"] = { - "tls-cipher" => "DHE-RSA-AES128-SHA", - "auth" => "SHA1", - "cipher" => "AES-128-CBC" - } - generate_json hsh -%> \ No newline at end of file diff --git a/provider_base/files/service-definitions/v1/eip-service.json.erb b/provider_base/files/service-definitions/v1/eip-service.json.erb new file mode 100644 index 00000000..ca42bef5 --- /dev/null +++ b/provider_base/files/service-definitions/v1/eip-service.json.erb @@ -0,0 +1,48 @@ +<%= + def underscore(words) + words = words.to_s.dup + words.downcase! + words.gsub! /[^a-z]/, '_' + words + end + + def add_gateway(node, locations, options={}) + return nil if options[:ip] == 'REQUIRED' + gateway = {} + gateway["capabilities"] = node.openvpn.pick(:ports, :protocols, :user_ips, :adblock, :filter_dns) + gateway["capabilities"]["transport"] = ["openvpn"] + gateway["host"] = node.domain.full + gateway["ip_address"] = options[:ip] + gateway["capabilities"]["limited"] = options[:limited] + if node.location + location_name = underscore(node.location.name) + gateway["location"] = location_name + locations[location_name] ||= node.location + end + gateway + end + + hsh = {} + hsh["serial"] = 1 + hsh["version"] = 1 + locations = {} + gateways = [] + nodes_like_me[:services => 'openvpn'].each_node do |node| + if node.openvpn.allow_limited && node.openvpn.allow_unlimited + gateways << add_gateway(node, locations, :ip => node.openvpn.gateway_address, :limited => false) + gateways << add_gateway(node, locations, :ip => node.openvpn.second_gateway_address, :limited => true) + elsif node.openvpn.allow_unlimited + gateways << add_gateway(node, locations, :ip => node.openvpn.gateway_address, :limited => false) + elsif node.openvpn.allow_limited + gateways << add_gateway(node, locations, :ip => node.openvpn.gateway_address, :limited => true) + end + end + hsh["gateways"] = gateways.compact + hsh["locations"] = locations + hsh["openvpn_configuration"] = { + "tls-cipher" => "DHE-RSA-AES128-SHA", + "auth" => "SHA1", + "cipher" => "AES-128-CBC" + } + generate_json hsh +%> \ No newline at end of file diff --git a/provider_base/services/webapp.json b/provider_base/services/webapp.json index f87b0833..e4926ba7 100644 --- a/provider_base/services/webapp.json +++ b/provider_base/services/webapp.json @@ -11,7 +11,8 @@ "allow_limited_certs": "= global.provider.service.allow_limited_bandwidth", "allow_unlimited_certs": "= global.provider.service.allow_unlimited_bandwidth", "allow_anonymous_certs": "= global.provider.service.allow_anonymous", - "secret_token": "= secret :webapp_secret_token" + "secret_token": "= secret :webapp_secret_token", + "api_version": 1 }, "stunnel": { "couch_client": "= stunnel_client(nodes_like_me[:services => :couchdb], global.services[:couchdb].couch.port)" @@ -21,7 +22,7 @@ }, "definition_files": { "provider": "= file :provider_json_template", - "eip_service": "= file :eip_service_json_template" + "eip_service": "= file [:eip_service_json_template, 'v'+webapp.api_version.to_s]" }, "service_type": "public_service", "api": { -- cgit v1.2.3