From 66f685165e6489f64c8736eea949b24963772a12 Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Fri, 22 Feb 2019 19:47:52 +0100 Subject: [PATCH] feat(xen-api/Record#update_): easier use for single entry ```js // before await object.update_property({ entry: 'value', }) // after await object.update_property('entry', 'value') ``` --- @xen-orchestra/cr-seed-cli/index.js | 12 +++++------- packages/xen-api/src/index.js | 6 ++++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/@xen-orchestra/cr-seed-cli/index.js b/@xen-orchestra/cr-seed-cli/index.js index ec8e90cd0..10a346bf1 100755 --- a/@xen-orchestra/cr-seed-cli/index.js +++ b/@xen-orchestra/cr-seed-cli/index.js @@ -83,19 +83,17 @@ ${cliName} v${pkg.version} await Promise.all([ srcSnapshot.update_other_config(metadata), - srcSnapshot.update_other_config({ - 'xo:backup:exported': 'true', - }), + srcSnapshot.update_other_config('xo:backup:exported', 'true'), tgtVm.set_name_label(`${srcVm.name_label} (${srcSnapshot.snapshot_time})`), tgtVm.update_other_config(metadata), tgtVm.update_other_config({ 'xo:backup:sr': tgtSr.uuid, 'xo:copy_of': srcSnapshotUuid, }), - tgtVm.update_blocked_operations({ - start: - 'Start operation for this vm is blocked, clone it if you want to use it.', - }), + tgtVm.update_blocked_operations( + 'start', + 'Start operation for this vm is blocked, clone it if you want to use it.' + ), Promise.all( userDevices.map(userDevice => { const srcDisk = srcDisks[userDevice] diff --git a/packages/xen-api/src/index.js b/packages/xen-api/src/index.js index a9fccbd90..8284ea2c1 100644 --- a/packages/xen-api/src/index.js +++ b/packages/xen-api/src/index.js @@ -1102,8 +1102,10 @@ export class Xapi extends EventEmitter { }) return result } - props[`update_${field}`] = function(entries) { - return xapi.setFieldEntries(this.$type, this.$ref, field, entries) + props[`update_${field}`] = function(entries, value) { + return typeof entries === 'string' + ? xapi.setFieldEntry(this.$type, this.$ref, field, entries, value) + : xapi.setFieldEntries(this.$type, this.$ref, field, entries) } } else if (value === '' || isOpaqueRef(value)) { // 2019-02-07 - JFT: even if `value` should not be an empty string for