Class: VagrantPlugins::Proxmox::Action::CloneVm
- Inherits:
-
ProxmoxAction
- Object
- ProxmoxAction
- VagrantPlugins::Proxmox::Action::CloneVm
- Defined in:
- lib/vagrant-proxmox/action/clone_vm.rb
Overview
This action clones from a qemu template on the Proxmox server and stores its node and vm_id env.id
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ CloneVm
constructor
A new instance of CloneVm.
Constructor Details
#initialize(app, env) ⇒ CloneVm
Returns a new instance of CloneVm.
9 10 11 12 |
# File 'lib/vagrant-proxmox/action/clone_vm.rb', line 9 def initialize app, env @app = app @logger = Log4r::Logger.new 'vagrant_proxmox::action::clone_vm' end |
Instance Method Details
#call(env) ⇒ Object
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 |
# File 'lib/vagrant-proxmox/action/clone_vm.rb', line 14 def call env env[:ui].info I18n.t('vagrant_proxmox.cloning_vm') config = env[:machine].provider_config node = env[:proxmox_selected_node] vm_id = nil template_vm_id = nil begin template_vm_id = connection(env).get_qemu_template_id(config.qemu_template) rescue StandardError => e raise VagrantPlugins::Proxmox::Errors::VMCloneError, proxmox_exit_status: e. end begin vm_id = connection(env).get_free_vm_id params = create_params_qemu(config, env, vm_id, template_vm_id) exit_status = connection(env).clone_vm node: node, vm_type: config.vm_type, params: params exit_status == 'OK' ? exit_status : raise(VagrantPlugins::Proxmox::Errors::ProxmoxTaskFailed, proxmox_exit_status: exit_status) rescue StandardError => e raise VagrantPlugins::Proxmox::Errors::VMCloneError, proxmox_exit_status: e. end env[:machine].id = "#{node}/#{vm_id}" env[:ui].info I18n.t('vagrant_proxmox.done') next_action env end |