Skip to content

Commit

Permalink
Merge pull request #5743 from yaacov/remove-ga-selectors
Browse files Browse the repository at this point in the history
Remove guest agent selectors
  • Loading branch information
openshift-merge-robot committed Jun 16, 2020
2 parents d9e393e + 7ecc0ce commit 02200b7
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 168 deletions.
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');
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}>
{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.

0 comments on commit 02200b7

Please sign in to comment.