당신은 당신이 VM을 요구하려는 행동과 VALIDATE_ACTIONS
를 업데이트하여 Vagrantfile의 맨 위에 다음을 추가 할 수 있습니다 다음과 같이
는 clarities을 위해, 내 설정이다. 단 하나의 VM 만 정의되어있는 경우에도 vagrant destroy
(지정된 VM없이) 명령이 허용됩니다.
# Actions to validate
VALIDATE_ACTIONS = [ 'halt', 'destroy' ]
# Override default actions to check machine list
class ValidateCommand < Vagrant.plugin(2, :command)
class << self
attr_accessor :delegate_action
end
def initialize argv, env
super(argv, env)
@argv = argv
end
def execute
vms = []
with_target_vms(@argv, :reverse => true) do | machine |
vms << machine
end
if vms.size > 1
puts 'Please specify a single VM'
1
else
with_target_vms(@argv, :reverse => true) do | machine |
machine.action(ValidateCommand.delegate_action)
end
0
end
end
end
# Wrap validate command in plugin and invoke for overridden actions
class ValidatePlugin < Vagrant.plugin(2)
name "Validate"
VALIDATE_ACTIONS.each do | action |
command action do
ValidateCommand.delegate_action = action
ValidateCommand
end
end
end
이것은 효과가있었습니다. 고맙습니다! – RubberDucky
굉장합니다. 그것을 듣고 기뻐. – pauljm
매우 유용합니다 !!!!!, thanks !!! – Robert