class VagrantPlugins::Openstack::Command::AbstractCommand
Public Class Methods
new(argv, env)
click to toggle source
Calls superclass method
# File lib/vagrant-openstack-provider/command/abstract_command.rb, line 8 def initialize(argv, env) @env = env super(normalize_args(argv), env) end
Public Instance Methods
before_cmd(_name, _argv, _env)
click to toggle source
# File lib/vagrant-openstack-provider/command/abstract_command.rb, line 42 def before_cmd(_name, _argv, _env) end
cmd(_name, _argv, _env)
click to toggle source
# File lib/vagrant-openstack-provider/command/abstract_command.rb, line 45 def cmd(_name, _argv, _env) fail 'Command not implemented. \'cmd\' method must be overridden in all subclasses' end
execute(name)
click to toggle source
# File lib/vagrant-openstack-provider/command/abstract_command.rb, line 13 def execute(name) env = {} with_target_vms(nil, provider: :openstack) do |machine| env[:machine] = machine env[:ui] = @env.ui end before_cmd(name, @argv, env) cmd(name, @argv, env) @env.ui.info('') # rubocop:disable Lint/RescueException rescue Errors::VagrantOpenstackError, SystemExit, Interrupt => e raise e rescue Exception => e puts I18n.t('vagrant_openstack.global_error').red unless e.message && e.message.start_with?('Catched Error:') raise e end
normalize_args(args)
click to toggle source
Before Vagrant 1.5, args list ends with an extra arg ‘–’. It removes it if present.
# File lib/vagrant-openstack-provider/command/abstract_command.rb, line 36 def normalize_args(args) return args if args.nil? args.pop if args.size > 0 && args.last == '--' args end