diff --git a/src/api/vm.coffee b/src/api/vm.coffee index aac200392..fcbecd326 100644 --- a/src/api/vm.coffee +++ b/src/api/vm.coffee @@ -55,6 +55,7 @@ checkPermissionOnSrs = (vm, permission = 'operate') -> ( # TODO: Implement ACLs create = $coroutine ({ + clone resourceSet installation name_description @@ -143,6 +144,7 @@ create = $coroutine ({ throw new Unauthorized() xapiVm = yield xapi.createVm(template._xapiId, { + clone, installRepository: installation && installation.repository, nameDescription: name_description, nameLabel: name_label, @@ -163,6 +165,11 @@ create = $coroutine ({ return vm.id create.params = { + clone: { + type: 'boolean' + optional: true + } + resourceSet: { type: 'string', optional: true diff --git a/src/xapi.js b/src/xapi.js index 8e9e9c342..8b5be7143 100644 --- a/src/xapi.js +++ b/src/xapi.js @@ -1058,6 +1058,7 @@ export default class Xapi extends XapiBase { // TODO: clean up on error. async createVm (templateId, { + clone = true, nameDescription = undefined, nameLabel = undefined, pvArgs = undefined, @@ -1083,7 +1084,7 @@ export default class Xapi extends XapiBase { // Clones the template. const vm = await this._getOrWaitObject( - await this._cloneVm(template, nameLabel) + await this[clone ? '_cloneVm' : '_copyVm'](template, nameLabel) ) // TODO: copy BIOS strings?