Sha256: 8bcc0ef9572ad4e6eeb7703223df46eeca76b8e66ac50e8b3586ac05b56352eb

Contents?: true

Size: 1.32 KB

Versions: 6

Compression:

Stored size: 1.32 KB

Contents

require 'odania/version'
require 'diplomat'
require 'erubis'
require 'fileutils'
require 'uri/http'
require 'public_suffix'
require 'deep_merge'
require 'json'
require 'socket'
require 'logger'

BASE_DIR = File.absolute_path File.join File.dirname(__FILE__), '..'
ENVIRONMENT = ENV['ENVIRONMENT'].nil? ? 'development' : ENV['ENVIRONMENT']
LOCAL_TEST_MODE = 'development'.eql?(ENVIRONMENT) unless defined? LOCAL_TEST_MODE
$logger = Logger.new(STDOUT)

module Odania
	CORE_PLUGIN_NAME = 'odania-core'

	autoload :Config, 'odania/config'
	autoload :Consul, 'odania/consul'
	autoload :Plugin, 'odania/plugin'

	def self.plugin
		Odania.configure
		@plugin = Plugin.new(@consul) if @plugin.nil?
		@plugin
	end

	def self.consul
		Odania.configure
		@consul
	end

	def self.configure(consul_url=nil)
		@consul = Consul.new(consul_url) if @consul.nil?
		$debug = false
	end

	def self.ips
		ips = []
		Socket.ip_address_list.each do |address|
			ip = address.ip_address
			ips << ip unless %w(127.0.0.1 ::1).include? ip
		end
		ips
	end

	# Rancher assigns two ip's the ip starting with 10. is routed through the hosts
	def self.primary_ip(ips)
		ips.each do |ip|
			return ip if ip.start_with? '10.'
		end

		ips.first
	end

	def self.varnish_sanitize(name)
		raise 'Could not sanitize varnish name!!' if name.nil?
		name.gsub(/[^0-9a-zA-Z_]/, '_')
	end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
odania-0.0.38 lib/odania.rb
odania-0.0.37 lib/odania.rb
odania-0.0.36 lib/odania.rb
odania-0.0.35 lib/odania.rb
odania-0.0.34 lib/odania.rb
odania-0.0.33 lib/odania.rb