Sha256: f3254a1669f0292feedc515b0b4bbe388f346b603a212a46cca9448083195350
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
require 'yaml' module ChefVPCToolkit module Util def self.load_configs config_file=ENV['CHEF_VPC_TOOLKIT_CONF'] if config_file.nil? then config_file=ENV['HOME']+File::SEPARATOR+".chef_vpc_toolkit.conf" if not File.exists?(config_file) then config_file="/etc/chef_vpc_toolkit.conf" end end if File.exists?(config_file) then configs=YAML.load_file(config_file) raise_if_nil_or_empty(configs, "cloud_servers_vpc_url") raise_if_nil_or_empty(configs, "cloud_servers_vpc_username") raise_if_nil_or_empty(configs, "cloud_servers_vpc_password") return configs else raise "Failed to load cloud toolkit config file. Please configure /etc/chef_vpc_toolkit.conf or create a .chef_vpc_toolkit.conf config file in your HOME directory." end end def self.raise_if_nil_or_empty(options, key) if options[key].nil? || options[key].empty? then raise "Please specify a valid #{key.to_s} parameter." end end def self.hash_for_group(configs=Util.load_configs) id=ENV['GROUP_ID'] configs=Util.load_configs hash=nil if id.nil? then hash=CloudServersVPC.most_recent_server_group_hash(File.join(TMP_SG, '*.xml')) else file=File.join(TMP_SG, "#{id}.xml") hash = CloudServersVPC.server_group_hash(IO.read(file)) end raise "Create a cloud before running this command." if hash.nil? hash end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
chef-vpc-toolkit-2.0.1 | lib/chef-vpc-toolkit/util.rb |