Class: Veronic::Config
- Inherits:
-
Object
- Object
- Veronic::Config
- Defined in:
- lib/config/config.rb
Instance Attribute Summary collapse
-
#availability_zone ⇒ Object
Returns the value of attribute availability_zone.
-
#aws_ssh_key_id ⇒ Object
Returns the value of attribute aws_ssh_key_id.
-
#branch ⇒ Object
Returns the value of attribute branch.
-
#chef_server_url ⇒ Object
Returns the value of attribute chef_server_url.
-
#client_key ⇒ Object
Returns the value of attribute client_key.
-
#cloudprovider ⇒ Object
Returns the value of attribute cloudprovider.
-
#cloudprovider_access_key_id ⇒ Object
Returns the value of attribute cloudprovider_access_key_id.
-
#cloudprovider_images_owner_id ⇒ Object
Returns the value of attribute cloudprovider_images_owner_id.
-
#cloudprovider_secret_access_key ⇒ Object
Returns the value of attribute cloudprovider_secret_access_key.
-
#configprovider ⇒ Object
Returns the value of attribute configprovider.
-
#deploy_cmd ⇒ Object
Returns the value of attribute deploy_cmd.
-
#dnsprovider ⇒ Object
Returns the value of attribute dnsprovider.
-
#dnsprovider_access_key_id ⇒ Object
Returns the value of attribute dnsprovider_access_key_id.
-
#dnsprovider_secret_access_key ⇒ Object
Returns the value of attribute dnsprovider_secret_access_key.
-
#dnsprovider_zones ⇒ Object
Returns the value of attribute dnsprovider_zones.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#flavor ⇒ Object
Returns the value of attribute flavor.
-
#identity_file ⇒ Object
Returns the value of attribute identity_file.
-
#image ⇒ Object
Returns the value of attribute image.
-
#name ⇒ Object
Returns the value of attribute name.
-
#node_name ⇒ Object
Returns the value of attribute node_name.
-
#query ⇒ Object
Returns the value of attribute query.
-
#region ⇒ Object
Returns the value of attribute region.
-
#role ⇒ Object
Returns the value of attribute role.
-
#security_groups ⇒ Object
Returns the value of attribute security_groups.
-
#ssh_port ⇒ Object
Returns the value of attribute ssh_port.
-
#ssh_user ⇒ Object
Returns the value of attribute ssh_user.
-
#ssl_version ⇒ Object
Returns the value of attribute ssl_version.
-
#validation_client_name ⇒ Object
Returns the value of attribute validation_client_name.
-
#validation_key ⇒ Object
Returns the value of attribute validation_key.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
-
#zone_name ⇒ Object
Returns the value of attribute zone_name.
-
#zone_url ⇒ Object
Returns the value of attribute zone_url.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Config
constructor
A new instance of Config.
- #to_hash ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Config
Returns a new instance of Config.
5 6 7 8 9 10 11 12 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 |
# File 'lib/config/config.rb', line 5 def initialize(={}) default_config_file = "/etc/veronic/veronic.yml" config_from_file = Hash.new(nil) if [:config_file] && File.exists?([:config_file]) config_from_file = YAML.load_file([:config_file]) elsif File.exists?(default_config_file) config_from_file = YAML.load_file(default_config_file) end @dnsprovider = [:dnsprovider] || config_from_file['dnsprovider'] || :route53 @cloudprovider = [:cloudprovider] || config_from_file['cloudprovider'] || :ec2 @configprovider = [:configprovider] || config_from_file['configprovider'] || :chefserver @dnsprovider_access_key_id = [:dnsprovider_access_key_id] || config_from_file['dnsprovider_access_key_id'] @dnsprovider_secret_access_key = [:dnsprovider_secret_access_key] || config_from_file['dnsprovider_secret_access_key'] @dnsprovider_zones = [:dnsprovider_zones] || config_from_file['dnsprovider_zones'] @cloudprovider_access_key_id = [:cloudprovider_access_key_id] || config_from_file['cloudprovider_access_key_id'] @cloudprovider_secret_access_key = [:cloudprovider_secret_access_key] || config_from_file['cloudprovider_secret_access_key'] @cloudprovider_images_owner_id = [:cloudprovider_images_owner_id] || config_from_file['cloudprovider_images_owner_id'] @region = [:region] || config_from_file['region'] @availability_zone = [:availability_zone] || config_from_file['availability_zone'] @aws_ssh_key_id = [:aws_ssh_key_id] || config_from_file['aws_ssh_key_id'] @node_name = [:node_name] || config_from_file['node_name'] @client_key = [:client_key] || config_from_file['client_key'] @validation_client_name = [:validation_client_name] || config_from_file['validation_client_name'] @validation_key = [:validation_key] || config_from_file['validation_key'] @chef_server_url = [:chef_server_url] || config_from_file['chef_server_url'] @ssl_version = [:ssl_version] || config_from_file['ssl_version'] @identity_file = [:identity_file] || config_from_file['identity_file'] @branch = [:branch] || config_from_file['branch'] @environment = [:environment] || config_from_file['environment'] @ssh_user = [:ssh_user] || config_from_file['ssh_user'] || 'ubuntu' @ssh_port = [:ssh_port] || config_from_file['ssh_port'] || 22 @role = [:role] || config_from_file['role'] @flavor = [:flavor] || config_from_file['flavor'] || 'm1.medium' @security_groups = ([:security_groups] || 'default').split(',') || (config_from_file['security_groups'] || 'default').split(',') @deploy_cmd = [:deploy_cmd] || config_from_file['deploy_cmd'] || 'sudo chef-client' @name = ([:branch] || config_from_file['branch']) ? ([:branch] || config_from_file['branch']) : ([:name] || config_from_file['name']) @image = [:ami_image] || config_from_file['ami_image'] @verbose = [:verbose] || config_from_file['verbose'] @query = [:query] || config_from_file['query'] end |
Instance Attribute Details
#availability_zone ⇒ Object
Returns the value of attribute availability_zone.
3 4 5 |
# File 'lib/config/config.rb', line 3 def availability_zone @availability_zone end |
#aws_ssh_key_id ⇒ Object
Returns the value of attribute aws_ssh_key_id.
3 4 5 |
# File 'lib/config/config.rb', line 3 def aws_ssh_key_id @aws_ssh_key_id end |
#branch ⇒ Object
Returns the value of attribute branch.
3 4 5 |
# File 'lib/config/config.rb', line 3 def branch @branch end |
#chef_server_url ⇒ Object
Returns the value of attribute chef_server_url.
3 4 5 |
# File 'lib/config/config.rb', line 3 def chef_server_url @chef_server_url end |
#client_key ⇒ Object
Returns the value of attribute client_key.
3 4 5 |
# File 'lib/config/config.rb', line 3 def client_key @client_key end |
#cloudprovider ⇒ Object
Returns the value of attribute cloudprovider.
3 4 5 |
# File 'lib/config/config.rb', line 3 def cloudprovider @cloudprovider end |
#cloudprovider_access_key_id ⇒ Object
Returns the value of attribute cloudprovider_access_key_id.
3 4 5 |
# File 'lib/config/config.rb', line 3 def cloudprovider_access_key_id @cloudprovider_access_key_id end |
#cloudprovider_images_owner_id ⇒ Object
Returns the value of attribute cloudprovider_images_owner_id.
3 4 5 |
# File 'lib/config/config.rb', line 3 def cloudprovider_images_owner_id @cloudprovider_images_owner_id end |
#cloudprovider_secret_access_key ⇒ Object
Returns the value of attribute cloudprovider_secret_access_key.
3 4 5 |
# File 'lib/config/config.rb', line 3 def cloudprovider_secret_access_key @cloudprovider_secret_access_key end |
#configprovider ⇒ Object
Returns the value of attribute configprovider.
3 4 5 |
# File 'lib/config/config.rb', line 3 def configprovider @configprovider end |
#deploy_cmd ⇒ Object
Returns the value of attribute deploy_cmd.
3 4 5 |
# File 'lib/config/config.rb', line 3 def deploy_cmd @deploy_cmd end |
#dnsprovider ⇒ Object
Returns the value of attribute dnsprovider.
3 4 5 |
# File 'lib/config/config.rb', line 3 def dnsprovider @dnsprovider end |
#dnsprovider_access_key_id ⇒ Object
Returns the value of attribute dnsprovider_access_key_id.
3 4 5 |
# File 'lib/config/config.rb', line 3 def dnsprovider_access_key_id @dnsprovider_access_key_id end |
#dnsprovider_secret_access_key ⇒ Object
Returns the value of attribute dnsprovider_secret_access_key.
3 4 5 |
# File 'lib/config/config.rb', line 3 def dnsprovider_secret_access_key @dnsprovider_secret_access_key end |
#dnsprovider_zones ⇒ Object
Returns the value of attribute dnsprovider_zones.
3 4 5 |
# File 'lib/config/config.rb', line 3 def dnsprovider_zones @dnsprovider_zones end |
#environment ⇒ Object
Returns the value of attribute environment.
3 4 5 |
# File 'lib/config/config.rb', line 3 def environment @environment end |
#flavor ⇒ Object
Returns the value of attribute flavor.
3 4 5 |
# File 'lib/config/config.rb', line 3 def flavor @flavor end |
#identity_file ⇒ Object
Returns the value of attribute identity_file.
3 4 5 |
# File 'lib/config/config.rb', line 3 def identity_file @identity_file end |
#image ⇒ Object
Returns the value of attribute image.
3 4 5 |
# File 'lib/config/config.rb', line 3 def image @image end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/config/config.rb', line 3 def name @name end |
#node_name ⇒ Object
Returns the value of attribute node_name.
3 4 5 |
# File 'lib/config/config.rb', line 3 def node_name @node_name end |
#query ⇒ Object
Returns the value of attribute query.
3 4 5 |
# File 'lib/config/config.rb', line 3 def query @query end |
#region ⇒ Object
Returns the value of attribute region.
3 4 5 |
# File 'lib/config/config.rb', line 3 def region @region end |
#role ⇒ Object
Returns the value of attribute role.
3 4 5 |
# File 'lib/config/config.rb', line 3 def role @role end |
#security_groups ⇒ Object
Returns the value of attribute security_groups.
3 4 5 |
# File 'lib/config/config.rb', line 3 def security_groups @security_groups end |
#ssh_port ⇒ Object
Returns the value of attribute ssh_port.
3 4 5 |
# File 'lib/config/config.rb', line 3 def ssh_port @ssh_port end |
#ssh_user ⇒ Object
Returns the value of attribute ssh_user.
3 4 5 |
# File 'lib/config/config.rb', line 3 def ssh_user @ssh_user end |
#ssl_version ⇒ Object
Returns the value of attribute ssl_version.
3 4 5 |
# File 'lib/config/config.rb', line 3 def ssl_version @ssl_version end |
#validation_client_name ⇒ Object
Returns the value of attribute validation_client_name.
3 4 5 |
# File 'lib/config/config.rb', line 3 def validation_client_name @validation_client_name end |
#validation_key ⇒ Object
Returns the value of attribute validation_key.
3 4 5 |
# File 'lib/config/config.rb', line 3 def validation_key @validation_key end |
#verbose ⇒ Object
Returns the value of attribute verbose.
3 4 5 |
# File 'lib/config/config.rb', line 3 def verbose @verbose end |
#zone_name ⇒ Object
Returns the value of attribute zone_name.
3 4 5 |
# File 'lib/config/config.rb', line 3 def zone_name @zone_name end |
#zone_url ⇒ Object
Returns the value of attribute zone_url.
3 4 5 |
# File 'lib/config/config.rb', line 3 def zone_url @zone_url end |
Instance Method Details
#to_hash ⇒ Object
47 48 49 50 51 |
# File 'lib/config/config.rb', line 47 def to_hash hash = {} self.instance_variables.each {|var| hash[var.to_s.delete("@").to_sym] = self.instance_variable_get(var) } return hash end |