Class: Mist::Config
- Inherits:
-
Object
- Object
- Mist::Config
- Defined in:
- lib/mist/config.rb
Instance Attribute Summary collapse
-
#default_distro ⇒ Object
readonly
Server config attributes.
-
#default_release ⇒ Object
readonly
Server config attributes.
-
#instance_name ⇒ Object
readonly
Returns the value of attribute instance_name.
-
#machine_type ⇒ Object
readonly
Returns the value of attribute machine_type.
-
#network ⇒ Object
readonly
Returns the value of attribute network.
-
#servers ⇒ Object
readonly
Client config attributes.
-
#ssh_private_key ⇒ Object
readonly
Returns the value of attribute ssh_private_key.
-
#ssh_public_key ⇒ Object
readonly
Returns the value of attribute ssh_public_key.
-
#startup_script_path ⇒ Object
readonly
Returns the value of attribute startup_script_path.
-
#subnet ⇒ Object
readonly
Returns the value of attribute subnet.
-
#use_public_ip ⇒ Object
readonly
Returns the value of attribute use_public_ip.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
-
#zone ⇒ Object
readonly
Returns the value of attribute zone.
Instance Method Summary collapse
-
#initialize(path) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(path) ⇒ Config
Returns a new instance of Config.
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 |
# File 'lib/mist/config.rb', line 27 def initialize(path) config = YAML.load(File.read(path)) server_config = config['server'] || nil client_config = config['client'] || nil if server_config @default_distro = server_config['default_distro'] || 'ubuntu' @default_release = server_config['default_release'] || 'trusty' @username = server_config['username'] || 'mist' @ssh_public_key = server_config['ssh_public_key'] || File.join(%w(/ etc mist id_rsa.pub)) @ssh_private_key = server_config['ssh_private_key'] || File.join(%w(/ etc mist id_rsa)) @network = server_config['network'] || 'default' @subnet = server_config['subnet'] || nil @zone = server_config['zone'] || 'us-central1-a' @machine_type = server_config['machine_type'] || 'f1-micro' @instance_name = server_config['instance_name'] || 'mist' @startup_script_path = server_config['startup_scripts'] || File.join(%w(/ etc mist startup-scripts)) @use_public_ip = server_config['use_public_ip'] || true end if client_config @servers = client_config['servers'] @ssh_private_key = client_config['ssh_private_key'] || File.join(%w(/ etc mist id_rsa)) end rescue StandardError => ex Mist.logger.error "Failed to load configuration file #{path}: #{ex}" abort 'could not load configuration file' end |
Instance Attribute Details
#default_distro ⇒ Object (readonly)
Server config attributes
19 20 21 |
# File 'lib/mist/config.rb', line 19 def default_distro @default_distro end |
#default_release ⇒ Object (readonly)
Server config attributes
19 20 21 |
# File 'lib/mist/config.rb', line 19 def default_release @default_release end |
#instance_name ⇒ Object (readonly)
Returns the value of attribute instance_name.
21 22 23 |
# File 'lib/mist/config.rb', line 21 def instance_name @instance_name end |
#machine_type ⇒ Object (readonly)
Returns the value of attribute machine_type.
21 22 23 |
# File 'lib/mist/config.rb', line 21 def machine_type @machine_type end |
#network ⇒ Object (readonly)
Returns the value of attribute network.
21 22 23 |
# File 'lib/mist/config.rb', line 21 def network @network end |
#servers ⇒ Object (readonly)
Client config attributes
25 26 27 |
# File 'lib/mist/config.rb', line 25 def servers @servers end |
#ssh_private_key ⇒ Object (readonly)
Returns the value of attribute ssh_private_key.
20 21 22 |
# File 'lib/mist/config.rb', line 20 def ssh_private_key @ssh_private_key end |
#ssh_public_key ⇒ Object (readonly)
Returns the value of attribute ssh_public_key.
20 21 22 |
# File 'lib/mist/config.rb', line 20 def ssh_public_key @ssh_public_key end |
#startup_script_path ⇒ Object (readonly)
Returns the value of attribute startup_script_path.
21 22 23 |
# File 'lib/mist/config.rb', line 21 def startup_script_path @startup_script_path end |
#subnet ⇒ Object (readonly)
Returns the value of attribute subnet.
21 22 23 |
# File 'lib/mist/config.rb', line 21 def subnet @subnet end |
#use_public_ip ⇒ Object (readonly)
Returns the value of attribute use_public_ip.
22 23 24 |
# File 'lib/mist/config.rb', line 22 def use_public_ip @use_public_ip end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
20 21 22 |
# File 'lib/mist/config.rb', line 20 def username @username end |
#zone ⇒ Object (readonly)
Returns the value of attribute zone.
21 22 23 |
# File 'lib/mist/config.rb', line 21 def zone @zone end |