Class: VagrantPlugins::Vmck::Action::Create
- Inherits:
-
Object
- Object
- VagrantPlugins::Vmck::Action::Create
- Includes:
- Vagrant::Util::Retryable
- Defined in:
- lib/vagrant-vmck/action/create.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ Create
constructor
A new instance of Create.
Constructor Details
#initialize(app, env) ⇒ Create
Returns a new instance of Create.
9 10 11 12 |
# File 'lib/vagrant-vmck/action/create.rb', line 9 def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant_vmck::action::start_instance") 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 42 43 44 45 46 47 48 49 50 |
# File 'lib/vagrant-vmck/action/create.rb', line 14 def call(env) client = env[:vmck] if ENV['VMCK_JOB_ID'].nil? env[:ui].info("Vmck starting job ...") = { 'cpus': env[:machine].provider_config.cpus, 'memory': env[:machine].provider_config.memory, 'image_path': env[:machine].provider_config.image_path, 'storage': env[:machine].provider_config.storage, 'name': env[:machine].provider_config.name, 'restrict_network': env[:machine].provider_config.restrict_network, } id = client.create()['id'].to_s else id = ENV['VMCK_JOB_ID'] env[:ui].info("Vmck using existing job #{id}") end env[:machine].id = id env[:ui].info("Vmck waiting for job #{id} to be ready ...") retryable(:tries => 3600, :sleep => 1) do next if env[:interrupted] raise 'not ready' unless client.get(id)['ssh'] end env[:ui].info("Vmck job #{id} is ready, waiting for ssh ...") retryable(:tries => 120, :sleep => 1) do break if env[:interrupted] break if env[:machine].communicate.ready? sleep 2 end env[:ui].info("Vmck got ssh access to job #{id}") @app.call(env) end |