Add NamedBase for commands which take a name for multivm (optionally)
This commit is contained in:
parent
d86884699e
commit
3da5fc87a3
|
@ -13,6 +13,7 @@ module Vagrant
|
|||
autoload :Base, 'vagrant/command/base'
|
||||
autoload :GroupBase, 'vagrant/command/group_base'
|
||||
autoload :Helpers, 'vagrant/command/helpers'
|
||||
autoload :NamedBase, 'vagrant/command/named_base'
|
||||
end
|
||||
|
||||
# The source root is the path to the root directory of
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Vagrant
|
||||
module Command
|
||||
class DestroyCommand < Base
|
||||
class DestroyCommand < NamedBase
|
||||
desc "Destroy the environment, deleting the created virtual machines"
|
||||
register "destroy"
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Vagrant
|
||||
module Command
|
||||
class HaltCommand < Base
|
||||
class HaltCommand < NamedBase
|
||||
desc "Halt the running VMs in the environment"
|
||||
class_option :force, :type => :boolean, :default => false, :aliases => "-f"
|
||||
register "halt"
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
module Vagrant
|
||||
module Command
|
||||
# Same as {Base} except adds the `name` argument so that you
|
||||
# can use methods such as `target_vms` in your command.
|
||||
class NamedBase < Base
|
||||
argument :name, :type => :string, :optional => true
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
module Vagrant
|
||||
module Command
|
||||
class PackageCommand < Base
|
||||
class PackageCommand < NamedBase
|
||||
desc "Package a Vagrant environment for distribution"
|
||||
class_option :base, :type => :string, :default => nil
|
||||
class_option :output, :type => :string, :default => nil
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Vagrant
|
||||
module Command
|
||||
class ProvisionCommand < Base
|
||||
class ProvisionCommand < NamedBase
|
||||
desc "Rerun the provisioning scripts on a running VM"
|
||||
register "provision"
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Vagrant
|
||||
module Command
|
||||
class ReloadCommand < Base
|
||||
class ReloadCommand < NamedBase
|
||||
desc "Reload the environment, halting it then restarting it."
|
||||
register "reload"
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Vagrant
|
||||
module Command
|
||||
class ResumeCommand < Base
|
||||
class ResumeCommand < NamedBase
|
||||
desc "Resume a suspended Vagrant environment."
|
||||
register "resume"
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Vagrant
|
||||
module Command
|
||||
class SSHCommand < Base
|
||||
class SSHCommand < NamedBase
|
||||
desc "SSH into the currently running Vagrant environment."
|
||||
class_option :execute, :type => :string, :default => false, :aliases => "-e"
|
||||
register "ssh"
|
||||
|
@ -31,7 +31,7 @@ module Vagrant
|
|||
|
||||
def ssh_vm
|
||||
@ssh_vm ||= begin
|
||||
vm = self.name.nil? && env.multivm? ? env.primary_vm
|
||||
vm = self.name.nil? && env.multivm? ? env.primary_vm : nil
|
||||
raise MultiVMTargetRequired.new("A target or primary VM must be specified for SSH in a multi-vm environment.") if !vm && target_vms.length > 1
|
||||
vm = target_vms.first if !vm
|
||||
vm
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
module Vagrant
|
||||
module Command
|
||||
class UpCommand < Base
|
||||
class UpCommand < NamedBase
|
||||
desc "Creates the Vagrant environment"
|
||||
argument :name, :type => :string, :optional => true
|
||||
class_option :provision, :type => :boolean, :default => true
|
||||
register "up"
|
||||
|
||||
def execute
|
||||
# TODO: Make the options[:provision] actually mean something
|
||||
|
||||
target_vms.each do |vm|
|
||||
if vm.created?
|
||||
vm.env.ui.info "VM already created. Booting if its not already running..."
|
||||
|
|
Loading…
Reference in New Issue