From 6d5a5a46e40bd84cdf50f4513c8c098f1f8a835a Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Wed, 4 Mar 2020 08:43:28 +0100 Subject: [PATCH] feat(xo-server/createVdi): allow setting sm_config (#4841) --- packages/xo-server/src/xapi/index.js | 43 ++++++++++++++++------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/packages/xo-server/src/xapi/index.js b/packages/xo-server/src/xapi/index.js index ff9e33ab6..65bd98704 100644 --- a/packages/xo-server/src/xapi/index.js +++ b/packages/xo-server/src/xapi/index.js @@ -1718,25 +1718,31 @@ export default class Xapi extends XapiBase { return this.callAsync('VDI.clone', vdi.$ref).then(extractOpaqueRef) } - async createVdi({ - // blindly copying `sm_config` from another VDI can create problems, - // therefore it is ignored by this method - // - // see https://github.com/vatesfr/xen-orchestra/issues/4482 - name_description, - name_label, - other_config = {}, - read_only = false, - sharable = false, - SR, - tags, - type = 'user', - virtual_size, - xenstore_data, + async createVdi( + { + name_description, + name_label, + other_config = {}, + read_only = false, + sharable = false, + sm_config, + SR, + tags, + type = 'user', + virtual_size, + xenstore_data, - size, - sr = SR !== undefined && SR !== NULL_REF ? SR : this.pool.default_SR, - }) { + size, + sr = SR !== undefined && SR !== NULL_REF ? SR : this.pool.default_SR, + }, + { + // blindly copying `sm_config` from another VDI can create problems, + // therefore it is ignored by default by this method + // + // see https://github.com/vatesfr/xen-orchestra/issues/4482 + setSmConfig = false, + } = {} + ) { sr = this.getObject(sr) log.debug(`Creating VDI ${name_label} on ${sr.name_label}`) @@ -1750,6 +1756,7 @@ export default class Xapi extends XapiBase { SR: sr.$ref, tags, type, + sm_config: setSmConfig ? sm_config : undefined, virtual_size: size !== undefined ? parseSize(size) : virtual_size, xenstore_data, }).then(extractOpaqueRef)