Load libraries and config from app's relative directory

This commit is contained in:
Scott Schneider 2013-10-01 12:06:26 -07:00
parent 6fdeed596e
commit b130e9911a

View file

@ -4,21 +4,25 @@ require 'rbvmomi'
require 'redis' require 'redis'
require 'yaml' require 'yaml'
require File.expand_path( File.dirname( __FILE__ ), 'lib/vsphere_helper.rb' ) $:.unshift( File.dirname( __FILE__ ) )
require 'lib/require_relative'
require 'lib/vsphere_helper'
vsphere_helper = VsphereHelper.new vsphere_helper = VsphereHelper.new
# Load the pool configuration Dir.chdir( File.dirname( __FILE__ ) )
pools = YAML.load_file('vmware-host-pooler.yaml')[:pools]
# Load fog credentials # Load the configuration file
fog_file = File.expand_path("~/.fog") config_file = File.expand_path( 'vmware-host-pooler.yaml' )
fog_data = YAML.load_file(fog_file)[:default]
pools = YAML.load_file( config_file )[:pools]
vsphere = YAML.load_file( config_file )[:vsphere]
# Connect to vSphere # Connect to vSphere
$vim = RbVmomi::VIM.connect( $vim = RbVmomi::VIM.connect(
:host => fog_data[:vsphere_server], :host => vsphere['server'],
:user => fog_data[:vsphere_username], :user => vsphere['username'],
:password => fog_data[:vsphere_password], :password => vsphere['password'],
:ssl => true, :ssl => true,
:insecure => true, :insecure => true,
:rev => '5.1' :rev => '5.1'