Class: Veronic::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/config/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options={})
	default_config_file = "/etc/veronic/veronic.yml"
	config_from_file = Hash.new(nil)
	if options[:config_file] && File.exists?(options[:config_file])
		config_from_file = YAML.load_file(options[:config_file])
	elsif File.exists?(default_config_file)
		config_from_file = YAML.load_file(default_config_file)
	end

	@dnsprovider                      = options[:dnsprovider]                      || config_from_file['dnsprovider'] || :route53
	@cloudprovider                    = options[:cloudprovider]                    || config_from_file['cloudprovider'] || :ec2
	@configprovider                   = options[:configprovider]                   || config_from_file['configprovider'] || :chefserver
	@dnsprovider_access_key_id        = options[:dnsprovider_access_key_id]        || config_from_file['dnsprovider_access_key_id']
	@dnsprovider_secret_access_key    = options[:dnsprovider_secret_access_key]    || config_from_file['dnsprovider_secret_access_key']
	@dnsprovider_zones                = options[:dnsprovider_zones]                || config_from_file['dnsprovider_zones']
	@cloudprovider_access_key_id      = options[:cloudprovider_access_key_id]      || config_from_file['cloudprovider_access_key_id']
	@cloudprovider_secret_access_key  = options[:cloudprovider_secret_access_key]  || config_from_file['cloudprovider_secret_access_key']
	@cloudprovider_images_owner_id    = options[:cloudprovider_images_owner_id]    || config_from_file['cloudprovider_images_owner_id']
	@region                           = options[:region]                           || config_from_file['region']
	@availability_zone                = options[:availability_zone]                || config_from_file['availability_zone']
	@aws_ssh_key_id                   = options[:aws_ssh_key_id]                   || config_from_file['aws_ssh_key_id']
	@node_name                        = options[:node_name]                        || config_from_file['node_name']
	@client_key                       = options[:client_key]                       || config_from_file['client_key']
	@validation_client_name           = options[:validation_client_name]           || config_from_file['validation_client_name']
	@validation_key                   = options[:validation_key]                   || config_from_file['validation_key']
	@chef_server_url                  = options[:chef_server_url]                  || config_from_file['chef_server_url']
	@ssl_version                      = options[:ssl_version]                      || config_from_file['ssl_version']
	@identity_file                    = options[:identity_file]                    || config_from_file['identity_file']
	@branch                           = options[:branch]                           || config_from_file['branch']
	@environment                      = options[:environment]                      || config_from_file['environment']
	@ssh_user                         = options[:ssh_user]                         || config_from_file['ssh_user']	|| 'ubuntu'
	@ssh_port                         = options[:ssh_port]                         || config_from_file['ssh_port']	|| 22
	@role                             = options[:role]                             || config_from_file['role']
	@flavor                           = options[:flavor]                           || config_from_file['flavor'] || 'm1.medium'
	@security_groups                  = (options[:security_groups] || 'default').split(',')       || (config_from_file['security_groups'] || 'default').split(',')
	@deploy_cmd                       = options[:deploy_cmd]                       || config_from_file['deploy_cmd'] || 'sudo chef-client'
	@name                             = (options[:branch] || config_from_file['branch']) ? (options[:branch] 	|| config_from_file['branch']) : (options[:name] || config_from_file['name'])
	@image                            = options[:ami_image]                        || config_from_file['ami_image']
	@verbose                          = options[:verbose]                          || config_from_file['verbose']
	@query                            = options[:query]                            || config_from_file['query']
end

Instance Attribute Details

#availability_zoneObject

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_idObject

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

#branchObject

Returns the value of attribute branch.



3
4
5
# File 'lib/config/config.rb', line 3

def branch
  @branch
end

#chef_server_urlObject

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_keyObject

Returns the value of attribute client_key.



3
4
5
# File 'lib/config/config.rb', line 3

def client_key
  @client_key
end

#cloudproviderObject

Returns the value of attribute cloudprovider.



3
4
5
# File 'lib/config/config.rb', line 3

def cloudprovider
  @cloudprovider
end

#cloudprovider_access_key_idObject

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_idObject

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_keyObject

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

#configproviderObject

Returns the value of attribute configprovider.



3
4
5
# File 'lib/config/config.rb', line 3

def configprovider
  @configprovider
end

#deploy_cmdObject

Returns the value of attribute deploy_cmd.



3
4
5
# File 'lib/config/config.rb', line 3

def deploy_cmd
  @deploy_cmd
end

#dnsproviderObject

Returns the value of attribute dnsprovider.



3
4
5
# File 'lib/config/config.rb', line 3

def dnsprovider
  @dnsprovider
end

#dnsprovider_access_key_idObject

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_keyObject

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_zonesObject

Returns the value of attribute dnsprovider_zones.



3
4
5
# File 'lib/config/config.rb', line 3

def dnsprovider_zones
  @dnsprovider_zones
end

#environmentObject

Returns the value of attribute environment.



3
4
5
# File 'lib/config/config.rb', line 3

def environment
  @environment
end

#flavorObject

Returns the value of attribute flavor.



3
4
5
# File 'lib/config/config.rb', line 3

def flavor
  @flavor
end

#identity_fileObject

Returns the value of attribute identity_file.



3
4
5
# File 'lib/config/config.rb', line 3

def identity_file
  @identity_file
end

#imageObject

Returns the value of attribute image.



3
4
5
# File 'lib/config/config.rb', line 3

def image
  @image
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/config/config.rb', line 3

def name
  @name
end

#node_nameObject

Returns the value of attribute node_name.



3
4
5
# File 'lib/config/config.rb', line 3

def node_name
  @node_name
end

#queryObject

Returns the value of attribute query.



3
4
5
# File 'lib/config/config.rb', line 3

def query
  @query
end

#regionObject

Returns the value of attribute region.



3
4
5
# File 'lib/config/config.rb', line 3

def region
  @region
end

#roleObject

Returns the value of attribute role.



3
4
5
# File 'lib/config/config.rb', line 3

def role
  @role
end

#security_groupsObject

Returns the value of attribute security_groups.



3
4
5
# File 'lib/config/config.rb', line 3

def security_groups
  @security_groups
end

#ssh_portObject

Returns the value of attribute ssh_port.



3
4
5
# File 'lib/config/config.rb', line 3

def ssh_port
  @ssh_port
end

#ssh_userObject

Returns the value of attribute ssh_user.



3
4
5
# File 'lib/config/config.rb', line 3

def ssh_user
  @ssh_user
end

#ssl_versionObject

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_nameObject

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_keyObject

Returns the value of attribute validation_key.



3
4
5
# File 'lib/config/config.rb', line 3

def validation_key
  @validation_key
end

#verboseObject

Returns the value of attribute verbose.



3
4
5
# File 'lib/config/config.rb', line 3

def verbose
  @verbose
end

#zone_nameObject

Returns the value of attribute zone_name.



3
4
5
# File 'lib/config/config.rb', line 3

def zone_name
  @zone_name
end

#zone_urlObject

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_hashObject



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