-
Notifications
You must be signed in to change notification settings - Fork 155
feat(topology): show vm node details in the sidepanel #2084
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d555510
feat(topology-vm-sidebar) : show details in sidebar
its-mitesh-kumar 7d81f39
feat(topology-vm-sidepanel) : showing pod in resource
its-mitesh-kumar 9da1295
feat(topology-vm-sidebar): adding apis of kubevirt
its-mitesh-kumar 557c756
feat(topology-vm-sidebar) : adding services
its-mitesh-kumar fc25183
feat(toplogy-vm-sidebar) : address code quality issue
its-mitesh-kumar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
plugins/topology/src/components/Topology/TopologySideBar/TopologyVirtualMachineDetails.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
import React from 'react'; | ||
|
||
import { ResourceIcon } from '../../../common/components/ResourceName'; | ||
import { LABEL_USED_TEMPLATE_NAME } from '../../../const'; | ||
import { K8sResourcesContext } from '../../../hooks/K8sResourcesContext'; | ||
import { VMKind } from '../../../types/vm'; | ||
import { | ||
findPodFromVMI, | ||
findVMI, | ||
getDescription, | ||
getGPUDevices, | ||
getHostDevices, | ||
getLabel, | ||
getLabeledDevices, | ||
getNodeName, | ||
getOperatingSystem, | ||
getOperatingSystemName, | ||
getVmiIpAddresses, | ||
getVMINodeName, | ||
getWorkloadProfile, | ||
isV1Pod, | ||
isVMIKind, | ||
} from '../../../utils/vm-utils'; | ||
import { BootOrderSummary } from '../boot-order/boot-order-summary'; | ||
import TopologySideBarDetailsItem from './TopologySideBarDetailsItem'; | ||
import TopologyWorkloadDetails from './TopologyWorkloadDetails'; | ||
|
||
type TopologyVirtualMachineDetailsProps = { | ||
vm: VMKind; | ||
}; | ||
|
||
const TopologyVirtualMachineDetails = ({ | ||
vm, | ||
}: TopologyVirtualMachineDetailsProps) => { | ||
const resources = React.useContext(K8sResourcesContext); | ||
const allPods = resources?.watchResourcesData?.pods?.data?.filter(isV1Pod); | ||
const allVMIs = | ||
resources?.watchResourcesData?.virtualmachineinstances?.data?.filter( | ||
isVMIKind, | ||
); | ||
const vmi = findVMI(vm, allVMIs); | ||
const pods = findPodFromVMI(vmi, allPods); | ||
const devices = getLabeledDevices(vm) || []; | ||
const ipAddrs = getVmiIpAddresses(vmi); // Need data to test | ||
const description = getDescription(vm); | ||
const templateName = getLabel(vm, LABEL_USED_TEMPLATE_NAME); | ||
const nodeName = getVMINodeName(vmi) || getNodeName(pods); | ||
const os = getOperatingSystemName(vm) || getOperatingSystem(vm); | ||
const workloadProfile = getWorkloadProfile(vm); | ||
|
||
return ( | ||
<> | ||
<div className="topology-workload-details"> | ||
<TopologyWorkloadDetails resource={vm}> | ||
<TopologySideBarDetailsItem label="Status"> | ||
{vm?.status?.printableStatus} | ||
</TopologySideBarDetailsItem> | ||
</TopologyWorkloadDetails> | ||
</div> | ||
<div | ||
className="topology-workload-details" | ||
data-testid="virtualmachine-details" | ||
> | ||
<TopologySideBarDetailsItem | ||
label="Description" | ||
emptyText="Not available" | ||
> | ||
{description} | ||
</TopologySideBarDetailsItem> | ||
<TopologySideBarDetailsItem | ||
label="Operating System" | ||
emptyText="Not available" | ||
> | ||
{os} | ||
</TopologySideBarDetailsItem> | ||
<TopologySideBarDetailsItem label="Template"> | ||
<ResourceIcon kind="Template" /> | ||
{templateName} | ||
</TopologySideBarDetailsItem> | ||
<TopologySideBarDetailsItem label="Pod"> | ||
{pods?.map(pod => ( | ||
<label key={pod?.metadata?.uid}>{pod?.metadata?.name}</label> | ||
))} | ||
</TopologySideBarDetailsItem> | ||
<TopologySideBarDetailsItem label="Boot order"> | ||
<BootOrderSummary devices={devices} /> | ||
</TopologySideBarDetailsItem> | ||
<TopologySideBarDetailsItem label="IP address"> | ||
{ipAddrs} | ||
</TopologySideBarDetailsItem> | ||
{/* <TopologySideBarDetailsItem label="Hostname"> | ||
{vm.spec?.strategy?.type} | ||
</TopologySideBarDetailsItem> | ||
<TopologySideBarDetailsItem label="Time zone"> | ||
{vm.spec?.strategy?.type} | ||
</TopologySideBarDetailsItem> */} | ||
<TopologySideBarDetailsItem label="Node" emptyText="Not available"> | ||
{nodeName} | ||
</TopologySideBarDetailsItem> | ||
<TopologySideBarDetailsItem | ||
label="Workload profile" | ||
emptyText="Not available" | ||
> | ||
{workloadProfile} | ||
</TopologySideBarDetailsItem> | ||
{/* <TopologySideBarDetailsItem label="User credentials"> | ||
{vm.spec?.strategy?.type} | ||
</TopologySideBarDetailsItem> | ||
<TopologySideBarDetailsItem label="SSH access"> | ||
<span data-test="details-item-ssh-access-port"> | ||
{vmiReady ? | ||
sshServicesRunning ? `Port: ${sshServicePort}` | ||
: 'SSH service disabled' | ||
|
||
: | ||
'Virtual machine not running') | ||
} | ||
</span> | ||
</TopologySideBarDetailsItem> */} | ||
<TopologySideBarDetailsItem label="Hardware devices"> | ||
<div>GPU devices: {getGPUDevices(vm).length}</div> | ||
<div>Host devices: {getHostDevices(vm).length}</div> | ||
</TopologySideBarDetailsItem> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default TopologyVirtualMachineDetails; |
56 changes: 56 additions & 0 deletions
56
plugins/topology/src/components/Topology/boot-order/boot-order-empty-summary.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import * as React from 'react'; | ||
|
||
import { ExpandableSection, Text, TextVariants } from '@patternfly/react-core'; | ||
|
||
import { BootableDeviceType } from '../../../types/vm'; | ||
import { deviceKey, deviceLabel } from '../../../utils/vm-utils'; | ||
|
||
import './boot-order.css'; | ||
|
||
export const BootOrderEmptySummary: React.FC<BootOrderEmptySummaryProps> = ({ | ||
devices, | ||
}) => { | ||
const [isExpanded, setIsExpanded] = React.useState<boolean>(false); | ||
const options = devices.filter(device => !device.value.bootOrder); | ||
const onToggle = React.useCallback( | ||
() => setIsExpanded(!isExpanded), | ||
[isExpanded], | ||
); | ||
|
||
// Note(Yaacov): | ||
// className='text-secondary' is a hack to fix TextVariants being overriden. | ||
// Using <ol> because '@patternfly/react-core' <List> currently miss isOrder parameter. | ||
return ( | ||
<> | ||
<Text | ||
component={TextVariants.p} | ||
className="kubevirt-boot-order-summary__empty-text" | ||
> | ||
No resource selected | ||
</Text> | ||
<Text component={TextVariants.small} className="text-secondary"> | ||
VM will attempt to boot from disks by order of apearance in YAML file | ||
</Text> | ||
{options.length > 0 && ( | ||
<ExpandableSection | ||
toggleText={ | ||
isExpanded ? 'Hide default boot disks' : 'Show default boot disks' | ||
} | ||
onToggle={onToggle} | ||
isExpanded={isExpanded} | ||
className="kubevirt-boot-order-summary__expandable" | ||
> | ||
<ol className="kubevirt-boot-order-summary__ol"> | ||
{options.map(option => ( | ||
<li key={deviceKey(option)}>{deviceLabel(option)}</li> | ||
))} | ||
</ol> | ||
</ExpandableSection> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export type BootOrderEmptySummaryProps = { | ||
devices: BootableDeviceType[]; | ||
}; |
35 changes: 35 additions & 0 deletions
35
plugins/topology/src/components/Topology/boot-order/boot-order-summary.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import * as React from 'react'; | ||
|
||
import * as _ from 'lodash'; | ||
|
||
import { BootableDeviceType } from '../../../types/vm'; | ||
import { deviceKey, deviceLabel } from '../../../utils/vm-utils'; | ||
import { BootOrderEmptySummary } from './boot-order-empty-summary'; | ||
|
||
// NOTE(yaacov): using <ol> because '@patternfly/react-core' <List> currently miss isOrder parameter. | ||
export const BootOrderSummary: React.FC<BootOrderSummaryProps> = ({ | ||
devices, | ||
}) => { | ||
const sources = _.sortBy( | ||
devices.filter(device => device.value.bootOrder), | ||
'value.bootOrder', | ||
); | ||
|
||
return ( | ||
<> | ||
{sources.length === 0 ? ( | ||
<BootOrderEmptySummary devices={devices} /> | ||
) : ( | ||
<ol> | ||
{sources.map(source => ( | ||
<li key={deviceKey(source)}>{deviceLabel(source)}</li> | ||
))} | ||
</ol> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export type BootOrderSummaryProps = { | ||
devices: BootableDeviceType[]; | ||
}; |
10 changes: 10 additions & 0 deletions
10
plugins/topology/src/components/Topology/boot-order/boot-order.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.kubevirt-boot-order-summary__empty-text { | ||
margin-bottom: 0; | ||
} | ||
.kubevirt-boot-order-summary__expandable { | ||
margin-top: 0; | ||
} | ||
.kubevirt-boot-order-summary__ol { | ||
margin-left: 1.5rem; | ||
margin-top: -1rem; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.