Class: VagrantPlugins::VCloud::Action::ConnectVCloud
- Inherits:
-
Object
- Object
- VagrantPlugins::VCloud::Action::ConnectVCloud
- Defined in:
- lib/vagrant-vcloud/action/connect_vcloud.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ ConnectVCloud
constructor
A new instance of ConnectVCloud.
Constructor Details
#initialize(app, env) ⇒ ConnectVCloud
Returns a new instance of ConnectVCloud.
5 6 7 8 |
# File 'lib/vagrant-vcloud/action/connect_vcloud.rb', line 5 def initialize(app, env) @app = app @logger = Log4r::Logger.new('vagrant_vcloud::action::connect_vcloud') end |
Instance Method Details
#call(env) ⇒ Object
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 46 47 48 49 50 51 52 |
# File 'lib/vagrant-vcloud/action/connect_vcloud.rb', line 10 def call(env) config = env[:machine].provider_config if !config.vcloud_cnx or !config.vcloud_cnx.driver.auth_key @logger.info('Connecting to vCloud Director...') @logger.debug("config.hostname : #{config.hostname}") @logger.debug("config.username : #{config.username}") @logger.debug("config.password : <hidden>") @logger.debug("config.org_name : #{config.org_name}") # Create the vcloud-rest connection object with the configuration # information. config.vcloud_cnx = Driver::Meta.new( config.hostname, config.username, config.password, config.org_name ) @logger.info('Logging into vCloud Director...') config.vcloud_cnx.login # Check for the vCloud Director authentication token if config.vcloud_cnx.driver.auth_key @logger.info('Logged in successfully!') @logger.debug( "x-vcloud-authorization=#{config.vcloud_cnx.driver.auth_key}" ) else @logger.info("Login failed in to #{config.hostname}.") env[:ui].error("Login failed in to #{config.hostname}.") raise end else @logger.info('Already logged in, using current session') @logger.debug( "x-vcloud-authorization=#{config.vcloud_cnx.driver.auth_key}" ) end @app.call env end |