Skip to content
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

Remove guest agent selectors #5743

Merged
merged 1 commit into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import { VMResourceSummary, VMDetailsList, VMSchedulingList } from './vm-resourc
import { VMUsersList } from './vm-users';
import { VMTabProps } from './types';
import { useGuestAgentInfo } from '../../hooks/use-guest-agent-info';
import { getGuestAgentInfoOS } from '../../selectors/vmi-guest-agent-info/guest-agent-info';
import { getGuestOSID } from '../../selectors/vmi-guest-agent-info/guest-os-info';
import { GuestAgentInfoWrapper } from '../../k8s/wrapper/vm/guest-agent-info/guest-agent-info-wrapper';
import { getVMStatus } from '../../statuses/vm/vm-status';
import { VMStatusBundle } from '../../statuses/vm/types';
import { isWindows } from '../../selectors/vm/combined';
Expand Down Expand Up @@ -83,13 +82,13 @@ export const VMDetails: React.FC<VMDetailsProps> = (props) => {
const vmiLike = kindObj === VirtualMachineModel ? vm : vmi;
const vmServicesData = getServicesForVmi(getLoadedData(props.services, []), vmi);
const canUpdate = useAccessReview(asAccessReview(kindObj, vmiLike || {}, 'patch')) && !!vmiLike;
const [guestAgentInfo] = useGuestAgentInfo({ vmi });
const guestAgentInfoOS = getGuestAgentInfoOS(guestAgentInfo);

const [guestAgentInfoRaw] = useGuestAgentInfo({ vmi });
const guestAgentInfo = new GuestAgentInfoWrapper(guestAgentInfoRaw);
const operatingSystemID = guestAgentInfo.getOSInfo().getId();

const OSMismatchExists =
vmi &&
guestAgentInfo &&
isWindows(vmiLike) !== (getGuestOSID(guestAgentInfoOS) === 'mswindows');
vmi && guestAgentInfoRaw && isWindows(vmiLike) !== (operatingSystemID === 'mswindows');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can leave this here for now, but can add it to the GuestAgentOSInfoWrapper if you want.

const OSMismatchAlert = OSMismatchExists && (
<Alert className="co-alert" variant="warning" title="Operating system mismatch" isInline>
The operating system defined for this virtual machine does not match what is being reported by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,7 @@ import {
AFFINITY_MODAL_TITLE,
} from '../modals/scheduling-modals/shared/consts';
import { useGuestAgentInfo } from '../../hooks/use-guest-agent-info';
import {
getGuestAgentInfoOS,
getGuestAgentInfoHostname,
getGuestAgentInfoTimezoneName,
} from '../../selectors/vmi-guest-agent-info/guest-agent-info';
import { getGuestOSPrettyName } from '../../selectors/vmi-guest-agent-info/guest-os-info';
import { GuestAgentInfoWrapper } from '../../k8s/wrapper/vm/guest-agent-info/guest-agent-info-wrapper';
import { VMStatusBundle } from '../../statuses/vm/types';

import './vm-resource.scss';
Expand Down Expand Up @@ -89,8 +84,9 @@ export const VMResourceSummary: React.FC<VMResourceSummaryProps> = ({
const description = getDescription(vmiLike);
const os = getOperatingSystemName(vmiLike) || getOperatingSystem(vmiLike);

const [guestAgentInfo] = useGuestAgentInfo({ vmi });
const guestAgentInfoOS = getGuestAgentInfoOS(guestAgentInfo);
const [guestAgentInfoRaw] = useGuestAgentInfo({ vmi });
const guestAgentInfo = new GuestAgentInfoWrapper(guestAgentInfoRaw);
const operatingSystem = guestAgentInfo.getOSInfo().getPrettyName();

return (
<ResourceSummary resource={vmiLike}>
Expand All @@ -111,9 +107,9 @@ export const VMResourceSummary: React.FC<VMResourceSummaryProps> = ({
<VMDetailsItem
title="Operating System"
idValue={prefixedID(id, 'os')}
isNotAvail={!(getGuestOSPrettyName(guestAgentInfoOS) || os)}
isNotAvail={!(operatingSystem || os)}
>
{getGuestOSPrettyName(guestAgentInfoOS) || os}
{operatingSystem || os}
</VMDetailsItem>

{isVM && (
Expand All @@ -135,7 +131,11 @@ export const VMDetailsList: React.FC<VMResourceListProps> = ({
canUpdateVM,
kindObj,
}) => {
const [guestAgentInfo] = useGuestAgentInfo({ vmi });
const [guestAgentInfoRaw] = useGuestAgentInfo({ vmi });
const guestAgentInfo = new GuestAgentInfoWrapper(guestAgentInfoRaw);
const hostname = guestAgentInfo.getHostname();
const timeZone = guestAgentInfo.getTimezoneName();

const [isBootOrderModalOpen, setBootOrderModalOpen] = React.useState<boolean>(false);
const isVM = kindObj === VirtualMachineModel;
const vmiLike = isVM ? vm : vmi;
Expand Down Expand Up @@ -214,20 +214,12 @@ export const VMDetailsList: React.FC<VMResourceListProps> = ({
{launcherPod && ipAddrs}
</VMDetailsItem>

<VMDetailsItem
title="Hostname"
idValue={prefixedID(id, 'hostname')}
isNotAvail={!getGuestAgentInfoHostname(guestAgentInfo)}
>
{getGuestAgentInfoHostname(guestAgentInfo)}
<VMDetailsItem title="Hostname" idValue={prefixedID(id, 'hostname')} isNotAvail={!hostname}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may change based on @matthewcarleton's input on #5741 (comment), but we'll go with this for now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

{hostname}
</VMDetailsItem>

<VMDetailsItem
title="Time Zone"
idValue={prefixedID(id, 'timezone')}
isNotAvail={!getGuestAgentInfoTimezoneName(guestAgentInfo)}
>
{getGuestAgentInfoTimezoneName(guestAgentInfo)}
<VMDetailsItem title="Time Zone" idValue={prefixedID(id, 'timezone')} isNotAvail={!timeZone}>
{timeZone}
</VMDetailsItem>

<VMDetailsItem
Expand Down
23 changes: 10 additions & 13 deletions frontend/packages/kubevirt-plugin/src/components/vms/vm-users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ import {
import { VMStatus } from '../../constants/vm/vm-status';
import { isGuestAgentInstalled } from '../dashboards-page/vm-dashboard/vm-alerts';
import { useGuestAgentInfo } from '../../hooks/use-guest-agent-info';
import { getGuestAgentInfoUserList } from '../../selectors/vmi-guest-agent-info/guest-agent-info';
import {
getGuestOSUserUserName,
getGuestOSUserLoginTimeSec,
getGuestOSUserDomain,
} from '../../selectors/vmi-guest-agent-info/guest-os-user-list';
import { GuestAgentInfoWrapper } from '../../k8s/wrapper/vm/guest-agent-info/guest-agent-info-wrapper';
import { VMStatusBundle } from '../../statuses/vm/types';
import { VMIKind } from '../../types';

Expand Down Expand Up @@ -73,7 +68,9 @@ const UsersTableRow = ({ obj: user, index, key, style }) => {
};

export const VMUsersList: React.FC<VMUsersListProps> = ({ vmi, vmStatusBundle, delay }) => {
const [response, error, loading] = useGuestAgentInfo({ vmi, delay });
const [guestAgentInfoRaw, error, loading] = useGuestAgentInfo({ vmi, delay });
const guestAgentInfo = new GuestAgentInfoWrapper(guestAgentInfoRaw);
const userList = guestAgentInfo.getUserList();

if (vmStatusBundle.status !== VMStatus.RUNNING) {
return <div className="text-center">{VIRTUAL_MACHINE_IS_NOT_RUNNING}</div>;
Expand All @@ -84,14 +81,14 @@ export const VMUsersList: React.FC<VMUsersListProps> = ({ vmi, vmStatusBundle, d
}

const data =
response &&
getGuestAgentInfoUserList(response) &&
getGuestAgentInfoUserList(response).map((user, uid) => ({
guestAgentInfoRaw &&
userList &&
userList.map((user, uid) => ({
metadata: {
uid,
userName: getGuestOSUserUserName(user),
domain: getGuestOSUserDomain(user),
loginTime: getGuestOSUserLoginTimeSec(user),
userName: user.getUserName(),
domain: user.getDomain(),
loginTime: user.getLoginTimeInMilliSec(),
},
}));

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.