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')
```
This commit is contained in:
Julien Fontanet 2019-02-22 19:47:52 +01:00
parent 8e8b1c009a
commit 66f685165e
2 changed files with 9 additions and 9 deletions

View File

@ -83,19 +83,17 @@ ${cliName} v${pkg.version}
await Promise.all([ await Promise.all([
srcSnapshot.update_other_config(metadata), srcSnapshot.update_other_config(metadata),
srcSnapshot.update_other_config({ srcSnapshot.update_other_config('xo:backup:exported', 'true'),
'xo:backup:exported': 'true',
}),
tgtVm.set_name_label(`${srcVm.name_label} (${srcSnapshot.snapshot_time})`), tgtVm.set_name_label(`${srcVm.name_label} (${srcSnapshot.snapshot_time})`),
tgtVm.update_other_config(metadata), tgtVm.update_other_config(metadata),
tgtVm.update_other_config({ tgtVm.update_other_config({
'xo:backup:sr': tgtSr.uuid, 'xo:backup:sr': tgtSr.uuid,
'xo:copy_of': srcSnapshotUuid, 'xo:copy_of': srcSnapshotUuid,
}), }),
tgtVm.update_blocked_operations({ tgtVm.update_blocked_operations(
start: 'start',
'Start operation for this vm is blocked, clone it if you want to use it.', 'Start operation for this vm is blocked, clone it if you want to use it.'
}), ),
Promise.all( Promise.all(
userDevices.map(userDevice => { userDevices.map(userDevice => {
const srcDisk = srcDisks[userDevice] const srcDisk = srcDisks[userDevice]

View File

@ -1102,8 +1102,10 @@ export class Xapi extends EventEmitter {
}) })
return result return result
} }
props[`update_${field}`] = function(entries) { props[`update_${field}`] = function(entries, value) {
return xapi.setFieldEntries(this.$type, this.$ref, field, entries) 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)) { } else if (value === '' || isOpaqueRef(value)) {
// 2019-02-07 - JFT: even if `value` should not be an empty string for // 2019-02-07 - JFT: even if `value` should not be an empty string for