feat(xo-web/new-vm): ability to copy host bios strings (#4755)

Fixes #4204
This commit is contained in:
Rajaa.BARHTAOUI 2020-02-26 09:52:39 +01:00 committed by GitHub
parent 6abe399e36
commit 7abc833ebe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 76 additions and 1 deletions

View File

@ -12,6 +12,7 @@
- [Proxy] Support network configuration for the deployed proxy (PR [#4810](https://github.com/vatesfr/xen-orchestra/pull/4810))
- [Menu] Display a warning icon in case of missing patches [#4475](https://github.com/vatesfr/xen-orchestra/issues/4475) (PR [#4683](https://github.com/vatesfr/xen-orchestra/pull/4683))
- [SR/general] Clickable SR usage graph: shows the corresponding disks when you click on one of the sections [#4747](https://github.com/vatesfr/xen-orchestra/issues/4747) (PR [#4754](https://github.com/vatesfr/xen-orchestra/pull/4754))
- [New VM] Ability to copy host BIOS strings [#4204](https://github.com/vatesfr/xen-orchestra/issues/4204) (PR [4755](https://github.com/vatesfr/xen-orchestra/pull/4755))
### Bug fixes

View File

@ -324,6 +324,8 @@ create.params = {
hvmBootFirmware: { type: 'string', optional: true },
copyHostBiosStrings: { type: 'boolean', optional: true },
// other params are passed to `editVm`
'*': { type: 'any' },
}

View File

@ -284,6 +284,7 @@ const TRANSFORMS = {
addresses: (guestMetrics && guestMetrics.networks) || null,
affinityHost: link(obj, 'affinity'),
auto_poweron: otherConfig.auto_poweron === 'true',
bios_strings: obj.bios_strings,
boot: obj.HVM_boot_params,
CPUs: {
max: +obj.VCPUs_max,

View File

@ -57,6 +57,8 @@ export default {
vgpuType = undefined,
gpuGroup = undefined,
copyHostBiosStrings = false,
...props
} = {},
checkLimits
@ -82,7 +84,22 @@ export default {
)
$defer.onFailure(() => this.deleteVm(vmRef))
// TODO: copy BIOS strings?
// Copy BIOS strings
// https://support.citrix.com/article/CTX230618
if (
isEmpty(template.bios_strings) &&
props.hvmBootFirmware !== 'uefi' &&
isVmHvm(template) &&
copyHostBiosStrings
) {
await this.callAsync(
'VM.copy_bios_strings',
vmRef,
this.getObject(
props.affinityHost ?? this.getObject(template.$pool).master
).$ref
)
}
// Removes disks from the provision XML, we will create them by
// ourselves.

View File

@ -1314,6 +1314,7 @@ const messages = {
createVmModalTitle: 'Create VM',
createVmModalWarningMessage:
"You're about to use a large amount of resources available on the resource set. Are you sure you want to continue?",
copyHostBiosStrings: 'Copy host BIOS strings to VM',
newVmCreateNewVmOn: 'Create a new VM on {select}',
newVmCreateNewVmNoPermission: 'You have no permission to create a VM',
newVmInfoPanel: 'Infos',
@ -1385,6 +1386,8 @@ const messages = {
newVmUserConfigLabel: 'User config',
newVmNoCloudDatasource: 'NoCloud datasource',
newVmNetworkConfigDoc: 'Network config documentation',
templateHasBiosStrings: 'The template already contains the BIOS strings',
vmBootFirmwareIsUefi: 'The boot firmware is UEFI',
// ----- Self -----
resourceSets: 'Resource sets',

View File

@ -345,6 +345,7 @@ export default class NewVm extends BaseComponent {
this._replaceState(
{
bootAfterCreate: true,
copyHostBiosStrings: this._templateHasBiosStrings(),
coresPerSocket: undefined,
CPUs: '',
cpuCap: '',
@ -513,6 +514,10 @@ export default class NewVm extends BaseComponent {
pv_args: state.pv_args,
autoPoweron: state.autoPoweron,
bootAfterCreate: state.bootAfterCreate,
copyHostBiosStrings:
state.hvmBootFirmware !== 'uefi' &&
!this._templateHasBiosStrings() &&
state.copyHostBiosStrings,
share: state.share,
cloudConfig,
networkConfig: this._isCoreOs() ? undefined : networkConfig,
@ -598,6 +603,7 @@ export default class NewVm extends BaseComponent {
nameLabels: map(Array(+state.nbVms), (_, index) =>
replacer({ name_label, name_description, template }, index + 1)
),
copyHostBiosStrings: !isEmpty(template.bios_strings),
// performances
CPUs: template.CPUs.number,
cpusMax: template.CPUs.max,
@ -759,6 +765,11 @@ export default class NewVm extends BaseComponent {
'%': (_, i) => i,
})
_templateHasBiosStrings = createSelector(
() => this.props.template,
template => template !== undefined && !isEmpty(template.bios_strings)
)
_getVgpuTypePredicate = createSelector(
() => this.props.pool,
pool => vgpuType => pool !== undefined && pool.id === vgpuType.$pool
@ -1643,6 +1654,7 @@ export default class NewVm extends BaseComponent {
affinityHost,
autoPoweron,
bootAfterCreate,
copyHostBiosStrings,
cpuCap,
cpusMax,
cpuWeight,
@ -1662,6 +1674,25 @@ export default class NewVm extends BaseComponent {
const { isAdmin } = this.props
const { formatMessage } = this.props.intl
const isHvm = this._isHvm()
const _copyHostBiosStrings =
isAdmin && isHvm ? (
<label>
<input
checked={
hvmBootFirmware !== 'uefi' &&
(this._templateHasBiosStrings() || copyHostBiosStrings)
}
className='form-control'
disabled={
hvmBootFirmware === 'uefi' || this._templateHasBiosStrings()
}
onChange={this._toggleState('copyHostBiosStrings')}
type='checkbox'
/>
&nbsp;
{_('copyHostBiosStrings')}
</label>
) : null
return (
<Section
@ -1873,6 +1904,26 @@ export default class NewVm extends BaseComponent {
</Item>
</SectionContent>
),
isAdmin && isHvm && (
<SectionContent>
<Item>
{hvmBootFirmware === 'uefi' ||
this._templateHasBiosStrings() ? (
<Tooltip
content={
hvmBootFirmware === 'uefi'
? _('vmBootFirmwareIsUefi')
: _('templateHasBiosStrings')
}
>
{_copyHostBiosStrings}
</Tooltip>
) : (
_copyHostBiosStrings
)}
</Item>
</SectionContent>
),
]}
</Section>
)