function loadVM(vmobj, do_autoboot) { var expire; VM.log('DEBUG', 'LOADING ' + JSON.stringify(vmobj)); if (vmobj.never_booted || (vmobj.autoboot && do_autoboot)) { VM.start(vmobj.uuid, {}, function (err) { // XXX: this ignores errors! VM.log('INFO', 'Autobooted ' + vmobj.uuid + ': [' + err + ']'); }); } if (vmobj.state === 'stopping' && vmobj.transition_expire) { VM.log('DEBUG', 'times: ' + Date.now() + ' ' + vmobj.transition_expire); if (Date.now() >= vmobj.transition_expire || (vmobj.transition_to === 'stopped' && vmobj.real_state === 'installed')) { VM.log('INFO', 'killing VM with expired running stop: ' + vmobj.uuid); // We assume kill will clear the transition even if the // vm is already stopped. VM.stop(vmobj.uuid, {'force': true}, function (err) { VM.log('DEBUG', 'vm.kill() = ' + err.message, err); }); } else { expire = ((Number(vmobj.transition_expire) + 1000) - Date.now()); setStopTimer(vmobj.uuid, expire); } } else { VM.log('DEBUG', 'state: ' + vmobj.state + ' expire: ' + vmobj.transition_expire); } // Start VNC spawnVNC(vmobj); }
VM.load(ev.zonename, function (err, obj) { if (err) { VM.log('ERROR', 'Unable to load vm', err); } else if (obj.brand !== 'kvm') { // do nothing VM.log('DEBUG', 'Ignoring freshly stopped vm ' + obj.uuid + ' with brand=' + obj.brand); } else { VM.stop(ev.zonename, {'force': true}, function (e) { if (e) { VM.log('ERROR', 'stop failed', e); } }); } });
VM.load(uuid, function (e, obj) { if (e) { VM.log('ERROR', "expire(): Unable to load vm: " + e.message, e); return; } // ensure we've not started and started stopping // again since we checked. VM.log('DEBUG', 'times two: ' + Date.now() + ' ' + obj.transition_expire); if (obj.state === 'stopping' && obj.transition_expire && (Date.now() >= obj.transition_expire)) { // We assume kill will clear the transition even if the // vm is already stopped. VM.stop(obj.uuid, {'force': true}, function (err) { VM.log('DEBUG', 'timeout vm.kill() = ' + JSON.stringify(err)); }); } });
VM.load(ev.zonename, function (err, obj) { if (err) { VM.log('ERROR', "Unable to load vm", err); return callback(err); } if (obj.brand !== 'kvm') { // do nothing VM.log('DEBUG', 'Ignoring freshly stopped vm ' + obj.uuid + ' with brand=' + obj.brand); return; } VM.stop(ev.zonename, {"force": true}, function (err) { if (err) { VM.log('ERROR', 'stop failed', err); } }); });