Sha256: b538d309a1a006492ac7306f686c44c04fd86d0c7ee99ffb41fd0cbfc816947e

Contents?: true

Size: 1.84 KB

Versions: 7

Compression:

Stored size: 1.84 KB

Contents

module VagrantPlugins
module CORL
module Command
class Launcher < ::Vagrant.plugin("2", :command)
  
  include ::CORL::Parallel # Mainly for auto locking of resources
  
  #-----------------------------------------------------------------------------
  
  def self.synopsis
    "execute CORL actions within the defined network"
  end
 
  #-----------------------------------------------------------------------------
  # Property accessors / modifiers
  
  def env
    @env
  end
  
  #-----------------------------------------------------------------------------
  # Execution

  def execute
    # Set the base command so we can access in any actions executed
    ::CORL::Vagrant.command = ::CORL.handle(self)   
    ::CORL.executable(@argv - [ "--" ], "[ vagrant ] corl")
  end
  
  #-----------------------------------------------------------------------------
  # Utilities
  
  def vm_machine(name, provider = nil, refresh = false)
    machine = nil
    
    # Mostly derived from Vagrant base command with_target_vms() method 
    provider = provider.to_sym if provider

    env.active_machines.each do |active_name, active_provider|
      if name == active_name
        if provider && provider != active_provider
          raise ::Vagrant::Errors::ActiveMachineWithDifferentProvider,
            :name               => active_name.to_s,
            :active_provider    => active_provider.to_s,
            :requested_provider => provider.to_s
        else
          @logger.info("Active machine found with name #{active_name}. " +
                       "Using provider: #{active_provider}")
          provider = active_provider
          break
        end
      end
    end

    provider ||= env.default_provider
    
    machine = env.machine(name, provider, refresh)
    machine.ui.opts[:color] = :default # TODO: Something better??
    
    machine
  end
end
end
end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
corl-0.4.29 lib/core/vagrant/commands/launcher.rb
corl-0.4.28 lib/core/vagrant/commands/launcher.rb
corl-0.4.27 lib/core/vagrant/commands/launcher.rb
corl-0.4.26 lib/core/vagrant/commands/launcher.rb
corl-0.4.25 lib/core/vagrant/commands/launcher.rb
corl-0.4.24 lib/core/vagrant/commands/launcher.rb
corl-0.4.23 lib/core/vagrant/commands/launcher.rb