Class: Vmpooler::PoolManager::Dns::Base
- Inherits:
-
Object
- Object
- Vmpooler::PoolManager::Dns::Base
- Defined in:
- lib/vmpooler/dns/base.rb
Instance Attribute Summary collapse
-
#dns_options ⇒ Object
readonly
Provider options passed in during initialization.
-
#logger ⇒ Object
readonly
Helper Methods Global Logger object.
-
#metrics ⇒ Object
readonly
Global Metrics object.
Instance Method Summary collapse
- #create_or_replace_record(hostname) ⇒ Object
- #delete_record(hostname) ⇒ Object
-
#dns_config ⇒ Object
Returns this dns plugin’s configuration.
- #get_ip(vm_name) ⇒ Object
- #global_config ⇒ Object
-
#initialize(config, logger, metrics, redis_connection_pool, name, options) ⇒ Base
constructor
A new instance of Base.
- #name ⇒ Object
- #pool_config(pool_name) ⇒ Object
-
#provided_pools ⇒ Object
returns Array : Array of pool names this provider services.
Constructor Details
#initialize(config, logger, metrics, redis_connection_pool, name, options) ⇒ Base
Returns a new instance of Base.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/vmpooler/dns/base.rb', line 17 def initialize(config, logger, metrics, redis_connection_pool, name, ) @config = config @logger = logger @metrics = metrics @redis = redis_connection_pool @dns_plugin_name = name @dns_options = logger.log('s', "[!] Creating dns plugin '#{name}'") end |
Instance Attribute Details
#dns_options ⇒ Object (readonly)
Provider options passed in during initialization
15 16 17 |
# File 'lib/vmpooler/dns/base.rb', line 15 def @dns_options end |
#logger ⇒ Object (readonly)
Helper Methods Global Logger object
11 12 13 |
# File 'lib/vmpooler/dns/base.rb', line 11 def logger @logger end |
#metrics ⇒ Object (readonly)
Global Metrics object
13 14 15 |
# File 'lib/vmpooler/dns/base.rb', line 13 def metrics @metrics end |
Instance Method Details
#create_or_replace_record(hostname) ⇒ Object
71 72 73 |
# File 'lib/vmpooler/dns/base.rb', line 71 def create_or_replace_record(hostname) raise("#{self.class.name} does not implement create_or_replace_record #{hostname}") end |
#delete_record(hostname) ⇒ Object
75 76 77 |
# File 'lib/vmpooler/dns/base.rb', line 75 def delete_record(hostname) raise("#{self.class.name} does not implement delete_record for #{hostname}") end |
#dns_config ⇒ Object
Returns this dns plugin’s configuration
41 42 43 44 45 46 47 48 |
# File 'lib/vmpooler/dns/base.rb', line 41 def dns_config @config[:dns_configs].each do |dns| # Convert the symbol from the config into a string for comparison return (dns[1].nil? ? {} : dns[1]) if dns[0].to_s == @dns_plugin_name end nil end |
#get_ip(vm_name) ⇒ Object
59 60 61 62 63 |
# File 'lib/vmpooler/dns/base.rb', line 59 def get_ip(vm_name) @redis.with_metrics do |redis| redis.hget("vmpooler__vm__#{vm_name}", 'ip') end end |
#global_config ⇒ Object
50 51 52 53 |
# File 'lib/vmpooler/dns/base.rb', line 50 def global_config # This entire VM Pooler config @config end |
#name ⇒ Object
55 56 57 |
# File 'lib/vmpooler/dns/base.rb', line 55 def name @dns_plugin_name end |
#pool_config(pool_name) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/vmpooler/dns/base.rb', line 29 def pool_config(pool_name) # Get the configuration of a specific pool @config[:pools].each do |pool| return pool if pool['name'] == pool_name end nil end |
#provided_pools ⇒ Object
returns
Array[String] : Array of pool names this provider services
67 68 69 |
# File 'lib/vmpooler/dns/base.rb', line 67 def provided_pools @config[:pools].select { |pool| pool['dns_config'] == name }.map { |pool| pool['name'] } end |