feat(xo-web/tab-advanced): allow to update VM creator (#7276)
Related to [forum#7313](https://xcp-ng.org/forum/topic/7313/change-created-by-and-date-information)
This commit is contained in:
parent
a624330818
commit
f0242380ca
@ -13,6 +13,7 @@
|
||||
- [Sign in] Support _Remember me_ feature with external providers (PR [#7298](https://github.com/vatesfr/xen-orchestra/pull/7298))
|
||||
- [Pool/Host] Add a warning if hosts do not have the same version within a pool [#7059](https://github.com/vatesfr/xen-orchestra/issues/7059) (PR [#7280](https://github.com/vatesfr/xen-orchestra/pull/7280))
|
||||
- [Plugins] Loading, or unloading, will respectively enable, or disable, _Auto-load at server start_, this should lead to least surprising behaviors (PR [#7317](https://github.com/vatesfr/xen-orchestra/pull/7317))
|
||||
- [VM/Advanced] Admin can change VM creator [Forum#7313](https://xcp-ng.org/forum/topic/7313/change-created-by-and-date-information) (PR [#7276](https://github.com/vatesfr/xen-orchestra/pull/7276))
|
||||
|
||||
### Bug fixes
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import * as multiparty from 'multiparty'
|
||||
import * as xoData from '@xen-orchestra/xapi/xoData.mjs'
|
||||
import assignWith from 'lodash/assignWith.js'
|
||||
import { asyncEach } from '@vates/async-each'
|
||||
import asyncMapSettled from '@xen-orchestra/async-map/legacy.js'
|
||||
@ -655,6 +656,12 @@ export const set = defer(async function ($defer, params) {
|
||||
await this.getXapiObject(VM).update_xenstore_data(mapKeys(xenStoreData, (v, k) => autoPrefix('vm-data/', k)))
|
||||
}
|
||||
|
||||
const creation = extract(params, 'creation')
|
||||
if (creation !== undefined) {
|
||||
const xapiVm = await this.getXapiObject(VM)
|
||||
await xoData.set(xapiVm, { creation: { ...VM.creation, ...creation } })
|
||||
}
|
||||
|
||||
return xapi.editVm(vmId, params, async (limits, vm) => {
|
||||
const resourceSet = xapi.xo.getData(vm, 'resourceSet')
|
||||
|
||||
@ -755,6 +762,14 @@ set.params = {
|
||||
|
||||
blockedOperations: { type: 'object', optional: true, properties: { '*': { type: ['boolean', 'null', 'string'] } } },
|
||||
|
||||
creation: {
|
||||
type: 'object',
|
||||
optional: true,
|
||||
properties: {
|
||||
user: { type: 'string', optional: true },
|
||||
},
|
||||
},
|
||||
|
||||
suspendSr: { type: ['string', 'null'], optional: true },
|
||||
|
||||
xenStoreData: {
|
||||
|
@ -1427,6 +1427,7 @@ const messages = {
|
||||
vmLimitsLabel: 'VM limits',
|
||||
resourceSet: 'Resource set',
|
||||
resourceSetNone: 'None',
|
||||
selectUser: 'Select user',
|
||||
suspendSr: 'Suspend SR',
|
||||
viridian: 'Viridian',
|
||||
vmCpuLimitsLabel: 'CPU limits',
|
||||
@ -1454,6 +1455,7 @@ const messages = {
|
||||
removeAcl: 'Delete',
|
||||
moreAcls: '{nAcls, number} more…',
|
||||
vmBootFirmware: 'Boot firmware',
|
||||
vmCreator: 'VM creator',
|
||||
vmDefaultBootFirmwareLabel: 'default (bios)',
|
||||
vmBootFirmwareWarningMessage:
|
||||
"You're about to change your boot firmware. This is still experimental in CH/XCP-ng 8.0. Are you sure you want to continue?",
|
||||
|
@ -691,6 +691,19 @@ export const SelectSubject = makeSubscriptionSelect(
|
||||
{ placeholder: _('selectSubjects') }
|
||||
)
|
||||
|
||||
export const SelectUser = makeSubscriptionSelect(
|
||||
subscriber => {
|
||||
const unsubscribeUsers = subscribeUsers(users => {
|
||||
subscriber({
|
||||
xoObjects: users,
|
||||
})
|
||||
})
|
||||
|
||||
return unsubscribeUsers
|
||||
},
|
||||
{ placeholder: _('selectUser') }
|
||||
)
|
||||
|
||||
// ===================================================================
|
||||
|
||||
export const SelectRole = makeSubscriptionSelect(
|
||||
|
@ -20,7 +20,7 @@ import { CustomFields } from 'custom-fields'
|
||||
import { injectState, provideState } from 'reaclette'
|
||||
import { Number, Select as EditableSelect, Size, Text, XoSelect } from 'editable'
|
||||
import { Select, Toggle } from 'form'
|
||||
import { SelectResourceSet, SelectRole, SelectSubject, SelectVgpuType } from 'select-objects'
|
||||
import { SelectResourceSet, SelectRole, SelectSubject, SelectUser, SelectVgpuType } from 'select-objects'
|
||||
import { addSubscriptions, connectStore, formatSize, getVirtualizationModeLabel, osFamily } from 'utils'
|
||||
import { every, filter, find, isEmpty, keyBy, map, times, some, uniq } from 'lodash'
|
||||
import {
|
||||
@ -487,6 +487,8 @@ export default class TabAdvanced extends Component {
|
||||
return deleteVtpm(vtpm)
|
||||
}
|
||||
|
||||
_updateUser = user => editVm(this.props.vm, { creation: { user: user.id } })
|
||||
|
||||
render() {
|
||||
const { container, isAdmin, vgpus, vm, vmPool } = this.props
|
||||
const isWarmMigrationAvailable = getXoaPlan().value >= PREMIUM.value
|
||||
@ -1023,6 +1025,12 @@ export default class TabAdvanced extends Component {
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
<tr>
|
||||
<th>{_('vmCreator')}</th>
|
||||
<td>
|
||||
<SelectUser onChange={this._updateUser} value={vm.creation?.user} />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</Col>
|
||||
|
Loading…
Reference in New Issue
Block a user