Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

OS-1753 / joyent/smartos-live#147 fixed update to nics.*.model

  • Loading branch information...
commit 9a713533372779b53b5ab2e9d9f1d41c3ec9e720 1 parent ff0982e
@joshwilsdon joshwilsdon authored
Showing with 94 additions and 5 deletions.
  1. +7 −1 src/vm/node_modules/VM.js
  2. +87 −4 src/vm/tests/test-update-kvm.js
View
8 src/vm/node_modules/VM.js
@@ -912,7 +912,7 @@ var BRAND_OPTIONS = {
'nics.*.interface': ['add', 'update'],
'nics.*.ip': ['add', 'update'],
'nics.*.mac': ['add', 'update'],
- 'nics.*.model': ['add'],
+ 'nics.*.model': ['add', 'update'],
'nics.*.netmask': ['add', 'update'],
'nics.*.nic_tag': ['add', 'update'],
'nics.*.primary': ['add', 'update'],
@@ -7832,6 +7832,8 @@ exports.start = function (uuid, extra, callback)
{
var zoneobj;
+ assert(callback, 'undefined callback!');
+
ensureLogging('start', true);
VM.log.info('Starting VM ' + uuid);
@@ -8190,6 +8192,7 @@ function applyUpdates(oldobj, newobj, payload, callback)
var changed_datasets = false;
// Note: oldobj is the VM *before* the update, newobj *after*
+ VM.log.debug('applying updates to ' + oldobj.uuid);
async.series([
function (cb) {
@@ -8319,6 +8322,8 @@ function applyUpdates(oldobj, newobj, payload, callback)
c(err);
});
+ } else {
+ c();
}
}
}, cb);
@@ -8490,6 +8495,7 @@ function applyUpdates(oldobj, newobj, payload, callback)
}
], function (err, res) {
+ VM.log.debug('done applying updates to ' + oldobj.uuid);
callback(err);
});
}
View
91 src/vm/tests/test-update-kvm.js
@@ -14,13 +14,14 @@ var PAYLOADS = {
"create": {
"brand": "kvm",
"ram": 256,
+ "autoboot": false,
"alias": "autotest-vm" + process.pid,
- "disks": [{"size": 1024, "model": "virtio"}],
+ "disks": [{"size": 1024, "model": "ide"}],
"do_not_inventory": true
}, "add_net0": {
"add_nics": [
{
- "model": "virtio",
+ "model": "e1000",
"ip": "10.254.254.254",
"netmask": "255.255.255.0",
"nic_tag": "external",
@@ -89,7 +90,48 @@ test('create zone', {'timeout': 240000}, function(t) {
});
});
-test('add net0', function(t) {
+test('update disk model', {'timeout': 60000}, function(t) {
+
+ VM.load(vm_uuid, function (err, before_obj) {
+ var path;
+
+ if (err) {
+ t.ok(false, 'error loading existing VM: ' + err.message);
+ t.end();
+ return;
+ }
+
+ path = before_obj.disks[0].path;
+
+ VM.update(vm_uuid, {'update_disks': [{'path': path, 'model': 'virtio'}]}, function(err) {
+ if (err) {
+ t.ok(false, 'error updating VM: ' + err.message);
+ t.end();
+ } else {
+ VM.load(vm_uuid, function (err, obj) {
+ if (err) {
+ t.ok(false, 'failed reloading VM');
+ t.end();
+ return;
+ }
+ t.ok((obj.disks[0].model === 'virtio'), 'obj.disks[0].model: '
+ + obj.disks[0].model + ' expected: virtio');
+ t.end();
+ });
+ }
+ });
+ });
+});
+
+test('boot zone', function(t) {
+ VM.start(vm_uuid, {}, function (err) {
+ t.ok(!err, 'error starting VM' + (err ? ': ' + err.message : ''));
+ t.end();
+ });
+});
+
+test('add net0', {'timeout': 60000}, function(t) {
+ console.log('boarg');
VM.update(vm_uuid, PAYLOADS.add_net0, function (err) {
if (err) {
t.ok(false, 'error updating VM: ' + err.message);
@@ -123,6 +165,47 @@ test('add net0', function(t) {
});
});
+test('update nic model', {'timeout': 60000}, function(t) {
+
+ VM.load(vm_uuid, function (err, before_obj) {
+ var mac;
+
+ if (err) {
+ t.ok(false, 'error loading existing VM: ' + err.message);
+ t.end();
+ return;
+ }
+
+ if (!before_obj || !before_obj.hasOwnProperty('nics')
+ || before_obj.nics.length < 1) {
+
+ t.ok(false, 'VM is in a broken state before NIC update');
+ t.end();
+ return;
+ }
+
+ mac = before_obj.nics[0].mac;
+
+ VM.update(vm_uuid, {'update_nics': [{'mac': mac, 'model': 'virtio'}]}, function(err) {
+ if (err) {
+ t.ok(false, 'error updating VM: ' + err.message);
+ t.end();
+ } else {
+ VM.load(vm_uuid, function (err, obj) {
+ if (err) {
+ t.ok(false, 'failed reloading VM');
+ t.end();
+ return;
+ }
+ t.ok((obj.nics[0].model === 'virtio'), 'obj.nics[0].model: '
+ + obj.nics[0].model + ' expected: virtio');
+ t.end();
+ });
+ }
+ });
+ });
+});
+
test('remove net0', function(t) {
VM.update(vm_uuid, PAYLOADS.remove_net0, function(err) {
if (err) {
@@ -199,7 +282,7 @@ test('remove net0 and net1', function(t) {
});
});
-test('set then unset simple properties', function(t) {
+test('set then unset simple properties', {'timeout': 240000}, function(t) {
async.forEachSeries(simple_properties,
function (item, cb) {
var prop = item[0];
Please sign in to comment.
Something went wrong with that request. Please try again.