Class: Bosh::Deployer::Configuration
- Inherits:
-
Object
- Object
- Bosh::Deployer::Configuration
- Defined in:
- lib/bosh/deployer/configuration.rb
Instance Attribute Summary collapse
-
#agent_properties ⇒ Object
Returns the value of attribute agent_properties.
-
#base_dir ⇒ Object
readonly
Returns the value of attribute base_dir.
-
#cloud_options ⇒ Object
Returns the value of attribute cloud_options.
-
#db ⇒ Object
Returns the value of attribute db.
-
#env ⇒ Object
Returns the value of attribute env.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#name ⇒ Object
Returns the value of attribute name.
-
#net_conf ⇒ Object
Returns the value of attribute net_conf.
-
#resources ⇒ Object
Returns the value of attribute resources.
-
#spec_properties ⇒ Object
Returns the value of attribute spec_properties.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
Instance Method Summary collapse
- #agent_services_ip ⇒ Object
- #agent_url ⇒ Object
- #client_services_ip ⇒ Object
-
#cloud ⇒ Object
rubocop:enable MethodLength.
-
#configure(config) ⇒ Object
rubocop:disable MethodLength.
- #cpi_task_log ⇒ Object
- #internal_services_ip ⇒ Object
- #networks ⇒ Object
- #task_checkpoint ⇒ Object
Instance Attribute Details
#agent_properties ⇒ Object
Returns the value of attribute agent_properties.
7 8 9 |
# File 'lib/bosh/deployer/configuration.rb', line 7 def agent_properties @agent_properties end |
#base_dir ⇒ Object (readonly)
Returns the value of attribute base_dir.
10 11 12 |
# File 'lib/bosh/deployer/configuration.rb', line 10 def base_dir @base_dir end |
#cloud_options ⇒ Object
Returns the value of attribute cloud_options.
7 8 9 |
# File 'lib/bosh/deployer/configuration.rb', line 7 def end |
#db ⇒ Object
Returns the value of attribute db.
7 8 9 |
# File 'lib/bosh/deployer/configuration.rb', line 7 def db @db end |
#env ⇒ Object
Returns the value of attribute env.
7 8 9 |
# File 'lib/bosh/deployer/configuration.rb', line 7 def env @env end |
#logger ⇒ Object
Returns the value of attribute logger.
7 8 9 |
# File 'lib/bosh/deployer/configuration.rb', line 7 def logger @logger end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/bosh/deployer/configuration.rb', line 7 def name @name end |
#net_conf ⇒ Object
Returns the value of attribute net_conf.
7 8 9 |
# File 'lib/bosh/deployer/configuration.rb', line 7 def net_conf @net_conf end |
#resources ⇒ Object
Returns the value of attribute resources.
7 8 9 |
# File 'lib/bosh/deployer/configuration.rb', line 7 def resources @resources end |
#spec_properties ⇒ Object
Returns the value of attribute spec_properties.
7 8 9 |
# File 'lib/bosh/deployer/configuration.rb', line 7 def spec_properties @spec_properties end |
#uuid ⇒ Object
Returns the value of attribute uuid.
7 8 9 |
# File 'lib/bosh/deployer/configuration.rb', line 7 def uuid @uuid end |
Instance Method Details
#agent_services_ip ⇒ Object
103 104 105 106 107 108 109 110 111 |
# File 'lib/bosh/deployer/configuration.rb', line 103 def agent_services_ip if net_conf['type'] == 'dynamic' net_conf['vip'] elsif @deployment_network @deployment_network['ip'] else net_conf['ip'] end end |
#agent_url ⇒ Object
78 79 80 |
# File 'lib/bosh/deployer/configuration.rb', line 78 def agent_url ['properties']['agent']['mbus'] end |
#client_services_ip ⇒ Object
113 114 115 |
# File 'lib/bosh/deployer/configuration.rb', line 113 def client_services_ip net_conf['vip'] || net_conf['ip'] end |
#cloud ⇒ Object
rubocop:enable MethodLength
71 72 73 74 75 76 |
# File 'lib/bosh/deployer/configuration.rb', line 71 def cloud if @cloud.nil? @cloud = Bosh::Clouds::Provider.create(, @uuid) end @cloud end |
#configure(config) ⇒ Object
rubocop:disable MethodLength
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/bosh/deployer/configuration.rb', line 13 def configure(config) plugin = config['cloud']['plugin'] config = InfrastructureDefaults.merge_for(plugin, config) @base_dir = config['dir'] FileUtils.mkdir_p(@base_dir) @name = config['name'] = config['cloud'] @net_conf = config['network'] @resources = config['resources'] @env = config['env'] @deployment_network = config['deployment_network'] log_io = config['logging']['file'] || STDOUT if log_io.is_a?(String) log_io = File.open(log_io, (File::WRONLY | File::APPEND | File::CREAT)) end @logger = MonoLogger.new(log_io) @logger.level = MonoLogger.const_get(config['logging']['level'].upcase) @logger.formatter = ThreadFormatter.new apply_spec = config['apply_spec'] @spec_properties = apply_spec['properties'] @agent_properties = apply_spec['agent'] @db = Sequel.sqlite migrate_cpi @db.create_table :instances do primary_key :id column :name, :text, unique: true, null: false column :uuid, :text column :stemcell_cid, :text column :stemcell_sha1, :text column :stemcell_name, :text column :config_sha1, :text column :vm_cid, :text column :disk_cid, :text end Sequel::Model.plugin :validation_helpers Bosh::Clouds::Config.configure(self) Models.define_instance_from_table(db[:instances]) ['properties']['agent']['mbus'] ||= 'https://vcap:[email protected]:6868' @cloud = nil @networks = nil @uuid = SecureRandom.uuid self end |
#cpi_task_log ⇒ Object
121 122 123 |
# File 'lib/bosh/deployer/configuration.rb', line 121 def cpi_task_log .fetch('properties', {})['cpi_log'] end |
#internal_services_ip ⇒ Object
117 118 119 |
# File 'lib/bosh/deployer/configuration.rb', line 117 def internal_services_ip '127.0.0.1' end |
#networks ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/bosh/deployer/configuration.rb', line 82 def networks @networks ||= { 'bosh' => { 'cloud_properties' => @net_conf['cloud_properties'], 'netmask' => @net_conf['netmask'], 'gateway' => @net_conf['gateway'], 'ip' => @net_conf['ip'], 'dns' => @net_conf['dns'], 'type' => @net_conf['type'], 'default' => %w(dns gateway) } }.merge(vip_network).merge(deployment_network) end |
#task_checkpoint ⇒ Object
96 97 98 99 100 101 |
# File 'lib/bosh/deployer/configuration.rb', line 96 def task_checkpoint # Bosh::Clouds::Config (bosh_cli >= 0.5.1) delegates task_checkpoint # method to periodically check if director task is cancelled, # so we need to define a void method in Bosh::Deployer::Config to avoid # NoMethodError exceptions. end |