Class: VagrantPlugins::XenServer::Action::CloneVM
- Inherits:
-
Object
- Object
- VagrantPlugins::XenServer::Action::CloneVM
- Defined in:
- lib/vagrant-xenserver/action/clone_vm.rb
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.
8 9 10 11 |
# File 'lib/vagrant-xenserver/action/clone_vm.rb', line 8 def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant::xenserver::actions::clone_vm") end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vagrant-xenserver/action/clone_vm.rb', line 13 def call(env) template_ref = env[:template] box_name = env[:machine].box.name.to_s box_version = env[:machine].box.version.to_s username = Etc.getlogin if env[:machine].provider_config.name.nil? vm_name = "#{username}/#{box_name}/#{box_version}" else vm_name = env[:machine].provider_config.name end vm = nil Action.getlock.synchronize do vm = env[:xc].VM.clone(template_ref, vm_name) env[:xc].VM.provision(vm) end env[:machine].id = vm @app.call env end |