-
Notifications
You must be signed in to change notification settings - Fork 592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug 1829542: Add mount guest agent tools to vm wizard #5490
Changes from 6 commits
7b54b96
d046361
2ec411c
6750c7a
37cd478
9341363
eac892b
7ab0ad2
51130d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import { FLAGS } from '@console/shared'; | ||
import { isWinToolsImage, getVolumeContainerImage } from '../../../../selectors/vm'; | ||
import { | ||
hasVmSettingsChanged, | ||
hasVMSettingsValueChanged, | ||
|
@@ -20,8 +19,6 @@ import { | |
import { iGetRelevantTemplate } from '../../../../selectors/immutable/template/combined'; | ||
import { CUSTOM_FLAVOR, TEMPLATE_DATAVOLUME_ANNOTATION } from '../../../../constants/vm'; | ||
import { ProvisionSource } from '../../../../constants/vm/provision-source'; | ||
import { windowsToolsStorage } from '../initial-state/storage-tab-initial-state'; | ||
import { getStorages } from '../../selectors/selectors'; | ||
import { prefillVmTemplateUpdater } from './prefill-vm-template-state-update'; | ||
import { iGetAnnotation } from '../../../../selectors/immutable/common'; | ||
|
||
|
@@ -159,16 +156,14 @@ const osUpdater = ({ id, prevState, dispatch, getState }: UpdateOptions) => { | |
|
||
const os = iGetVmSettingValue(state, id, VMSettingsField.OPERATING_SYSTEM); | ||
const isWindows = os?.startsWith('win'); | ||
const windowsTools = getStorages(state, id).find( | ||
(storage) => !!isWinToolsImage(getVolumeContainerImage(storage.volume)), | ||
); | ||
|
||
if (isWindows && !windowsTools) { | ||
dispatch(vmWizardInternalActions[InternalActionType.UpdateStorage](id, windowsToolsStorage)); | ||
} | ||
if (!isWindows && windowsTools) { | ||
dispatch(vmWizardInternalActions[InternalActionType.RemoveStorage](id, windowsTools.id)); | ||
} | ||
dispatch( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO, we should also consider the vm import part here. can we change the value to false when isProviderImport? But keep it visible in case some import providers (possibly vmWare) wish to use it. In case of ovirt provider it is actually impossible to use this field so can we hide it in We should also register field reset for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't have an env to test and check this scenarios ... @suomiy can you take it as a follow up PR ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be few lines, just use vmFieldUpdate in the same way like for other VM fields and also register isHidden in ovirt provider in the same spot/update. I can test your PR, once you have it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added a gate to not mount when in import view |
||
vmWizardInternalActions[InternalActionType.UpdateVmSettingsField]( | ||
id, | ||
VMSettingsField.MOUNT_WINDOWS_GUEST_TOOLS, | ||
{ isHidden: asHidden(!isWindows, VMSettingsField.OPERATING_SYSTEM), value: isWindows }, | ||
), | ||
); | ||
}; | ||
|
||
const baseImageUpdater = ({ id, prevState, dispatch, getState }: UpdateOptions) => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import { | |
Button, | ||
ButtonVariant, | ||
} from '@patternfly/react-core'; | ||
import { pluralize } from '@console/internal/components/utils'; | ||
import { ValidationErrorType, asValidationObject } from '@console/shared/src/utils/validation'; | ||
import { | ||
concatImmutableLists, | ||
|
@@ -48,6 +49,7 @@ export const OSFlavor: React.FC<OSFlavorProps> = React.memo( | |
userTemplate, | ||
operatinSystemField, | ||
cloneBaseDiskImageField, | ||
mountWindowsGuestToolsField, | ||
flavorField, | ||
workloadProfile, | ||
cnvBaseImages, | ||
|
@@ -60,6 +62,7 @@ export const OSFlavor: React.FC<OSFlavorProps> = React.memo( | |
const display = iGet(operatinSystemField, 'display'); | ||
const displayOnly = !!display; | ||
const cloneBaseDiskImage = iGetFieldValue(cloneBaseDiskImageField); | ||
const mountWindowsGuestTools = iGetFieldValue(mountWindowsGuestToolsField); | ||
|
||
const params = { | ||
userTemplate, | ||
|
@@ -145,6 +148,22 @@ export const OSFlavor: React.FC<OSFlavorProps> = React.memo( | |
); | ||
const baseImage = operatingSystemBaseImages.find((image) => image.id === os); | ||
|
||
const numOfMountedDisks = cloneBaseDiskImage + mountWindowsGuestTools; // using boolean addition operator to count true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wow, this seems so hacky :) |
||
const mountedDisksHelpMsg = numOfMountedDisks > 0 && ( | ||
<Text className="kv-create-vm__input-text-help-msg"> | ||
View the mounted {pluralize(numOfMountedDisks, 'disk', 'disks', false)} in the{' '} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we also have pluralize function in our package which is easier to use and does not depend on details-page file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. using our own pluralize :-) |
||
<Button | ||
isDisabled={!goToStorageStep} | ||
isInline | ||
onClick={goToStorageStep} | ||
variant={ButtonVariant.link} | ||
> | ||
<strong>storage</strong> | ||
</Button>{' '} | ||
step | ||
</Text> | ||
); | ||
|
||
return ( | ||
<> | ||
<FormFieldRow | ||
|
@@ -184,21 +203,21 @@ export const OSFlavor: React.FC<OSFlavorProps> = React.memo( | |
onChange={(v) => onChange(VMSettingsField.CLONE_COMMON_BASE_DISK_IMAGE, v)} | ||
/> | ||
</FormField> | ||
{cloneBaseDiskImage && ( | ||
<Text> | ||
View the cloned disk in the{' '} | ||
<Button | ||
isDisabled={!goToStorageStep} | ||
isInline | ||
onClick={goToStorageStep} | ||
variant={ButtonVariant.link} | ||
> | ||
<strong>storage</strong> | ||
</Button>{' '} | ||
step | ||
</Text> | ||
)} | ||
</FormFieldRow> | ||
<FormFieldRow | ||
field={mountWindowsGuestToolsField} | ||
fieldType={FormFieldType.INLINE_CHECKBOX} | ||
loadingResources={loadingResources} | ||
> | ||
<FormField> | ||
<Checkbox | ||
className="kv-create-vm__input-checkbox" | ||
id={getFieldId(VMSettingsField.MOUNT_WINDOWS_GUEST_TOOLS)} | ||
onChange={(v) => onChange(VMSettingsField.MOUNT_WINDOWS_GUEST_TOOLS, v)} | ||
/> | ||
</FormField> | ||
</FormFieldRow> | ||
{mountedDisksHelpMsg} | ||
<FormFieldRow | ||
field={flavorField} | ||
fieldType={FormFieldType.SELECT} | ||
|
@@ -228,6 +247,7 @@ type OSFlavorProps = { | |
flavorField: any; | ||
operatinSystemField: any; | ||
cloneBaseDiskImageField: any; | ||
mountWindowsGuestToolsField: any; | ||
userTemplate: string; | ||
workloadProfile: string; | ||
cnvBaseImages: any; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be declared/called before the internalStorageDiskBusUpdater so the validation to it applies as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to before internalStorageDiskBusUpdater
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move the code block as well. We are striving for our updaters to be declared in the same order they are executed in. It is much easier to read the file from top to the bottom to asses what is happening in sequence, than jumping across different sections of the file.
There are few exceptions (eg prefillVmTemplateUpdater) where the updater would get too long and such updaters are moved to new files.