feat(xo-web/pool,VM/advanced): ability to set suspend SR (#6044)
Fixes #4163
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
- [About] Show commit instead of version numbers for source users (PR [#6045](https://github.com/vatesfr/xen-orchestra/pull/6045))
|
||||
- [Health] Display default SRs that aren't shared [#5871](https://github.com/vatesfr/xen-orchestra/issues/5871) (PR [#6033](https://github.com/vatesfr/xen-orchestra/pull/6033))
|
||||
- [Pool,VM/advanced] Ability to change the suspend SR [#4163](https://github.com/vatesfr/xen-orchestra/issues/4163) (PR [#6044](https://github.com/vatesfr/xen-orchestra/pull/6044))
|
||||
|
||||
### Bug fixes
|
||||
|
||||
|
||||
@@ -117,6 +117,7 @@ const TRANSFORMS = {
|
||||
cores: cpuInfo && +cpuInfo.cpu_count,
|
||||
sockets: cpuInfo && +cpuInfo.socket_count,
|
||||
},
|
||||
suspendSr: link(obj, 'suspend_image_SR'),
|
||||
zstdSupported: obj.restrictions.restrict_zstd_export === 'false',
|
||||
|
||||
// TODO
|
||||
@@ -437,6 +438,7 @@ const TRANSFORMS = {
|
||||
startDelay: +obj.start_delay,
|
||||
startTime: metrics && toTimestamp(metrics.start_time),
|
||||
secureBoot: obj.platform.secureboot === 'true',
|
||||
suspendSr: link(obj, 'suspend_SR'),
|
||||
tags: obj.tags,
|
||||
VIFs: link(obj, 'VIFs'),
|
||||
virtualizationMode: domainType,
|
||||
|
||||
@@ -1267,6 +1267,7 @@ const messages = {
|
||||
vmLimitsLabel: 'VM limits',
|
||||
resourceSet: 'Resource set',
|
||||
resourceSetNone: 'None',
|
||||
suspendSr: 'Suspend SR',
|
||||
vmCpuLimitsLabel: 'CPU limits',
|
||||
vmCpuTopology: 'Topology',
|
||||
vmChooseCoresPerSocket: 'Default behavior',
|
||||
|
||||
50
packages/xo-web/src/common/select-suspend-sr.js
Normal file
50
packages/xo-web/src/common/select-suspend-sr.js
Normal file
@@ -0,0 +1,50 @@
|
||||
import _ from 'intl'
|
||||
import React from 'react'
|
||||
import defined, { get } from '@xen-orchestra/defined'
|
||||
import { injectState, provideState } from 'reaclette'
|
||||
|
||||
import decorate from './apply-decorators'
|
||||
import Icon from './icon'
|
||||
import renderXoItem from './render-xo-item'
|
||||
import { connectStore } from './utils'
|
||||
import { createGetObject } from './selectors'
|
||||
import { editVm, editPool, isSrWritable } from './xo'
|
||||
import { XoSelect } from './editable'
|
||||
|
||||
export const SelectSuspendSr = decorate([
|
||||
connectStore({
|
||||
suspendSr: createGetObject((_, { pool, vm }) => (vm || pool).suspendSr),
|
||||
}),
|
||||
provideState({
|
||||
effects: {
|
||||
onChange(_, value) {
|
||||
const { isVm } = this.state
|
||||
const method = isVm ? editVm : editPool
|
||||
method(isVm ? this.props.vm : this.props.pool, {
|
||||
suspendSr: defined(
|
||||
get(() => value.id),
|
||||
null
|
||||
),
|
||||
})
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
isVm: (state, props) => props.vm !== undefined,
|
||||
predicate: (state, props) => sr =>
|
||||
isSrWritable(sr) && (state.isVm ? props.vm.$pool === sr.$pool : props.pool.id === sr.$pool),
|
||||
},
|
||||
}),
|
||||
injectState,
|
||||
({ effects: { onChange }, state: { predicate }, suspendSr }) => (
|
||||
<span>
|
||||
<XoSelect onChange={onChange} predicate={predicate} value={suspendSr} xoType='SR'>
|
||||
{suspendSr !== undefined ? renderXoItem(suspendSr) : _('noValue')}
|
||||
</XoSelect>{' '}
|
||||
{suspendSr !== undefined && (
|
||||
<a role='button' onClick={onChange}>
|
||||
<Icon icon='remove' />
|
||||
</a>
|
||||
)}
|
||||
</span>
|
||||
),
|
||||
])
|
||||
@@ -32,6 +32,7 @@ import {
|
||||
subscribePlugins,
|
||||
synchronizeNetbox,
|
||||
} from 'xo'
|
||||
import { SelectSuspendSr } from 'select-suspend-sr'
|
||||
|
||||
@connectStore(() => ({
|
||||
master: createGetObjectsOfType('host').find((_, { pool }) => ({
|
||||
@@ -202,6 +203,12 @@ export default class TabAdvanced extends Component {
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{_('suspendSr')}</th>
|
||||
<td>
|
||||
<SelectSuspendSr pool={pool} />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</Col>
|
||||
|
||||
@@ -50,6 +50,7 @@ import {
|
||||
XEN_VIDEORAM_VALUES,
|
||||
} from 'xo'
|
||||
import { createGetObject, createGetObjectsOfType, createSelector, isAdmin } from 'selectors'
|
||||
import { SelectSuspendSr } from 'select-suspend-sr'
|
||||
|
||||
import BootOrder from './boot-order'
|
||||
|
||||
@@ -798,6 +799,12 @@ export default class TabAdvanced extends Component {
|
||||
<CustomFields object={vm.id} />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{_('suspendSr')}</th>
|
||||
<td>
|
||||
<SelectSuspendSr vm={vm} />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br />
|
||||
|
||||
Reference in New Issue
Block a user