Sha256: d483f8202420a989b69e7f386e844c98f6aedb96735ab724b0f4cdee83d6064b
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
require 'yaml' module ChefVPCToolkit module Util def self.load_configs config_file=ENV['CLOUD_TEST_CONFIG_FILE'] if config_file.nil? then config_file=ENV['HOME']+File::SEPARATOR+".cloud_toolkit.conf" if not File.exists?(config_file) then config_file="/etc/cloud_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/cloud_toolkit.conf or create a .cloud_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.0 | lib/chef-vpc-toolkit/util.rb |