Skip to content
This repository was archived by the owner on Apr 28, 2020. It is now read-only.

Add additional host, machine and node selectors #355

Merged
merged 4 commits into from
Apr 15, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/selectors/host/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ export const getHostRole = hostMachine =>
get(hostMachine, ['metadata', 'labels', 'machine.openshift.io/cluster-api-machine-role']);

export const getHostMachineName = host => get(host, 'spec.machineRef.name');
export const getHostBmcAddress = host => get(host, 'spec.bmc.address');
export const getHostErrorMessage = host => get(host, 'status.errorMessage');
export const getHostPoweredOn = host => _.get(host, 'status.poweredOn');
Copy link
Contributor

Choose a reason for hiding this comment

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

isHostPoweredOn ? maybe also good to indicate default as false?

Copy link
Author

Choose a reason for hiding this comment

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

Done

2 changes: 2 additions & 0 deletions src/selectors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ export * from './common';
export * from './dv';
export * from './host';
export * from './infrastructure';
export * from './machine';
export * from './migration';
export * from './node';
export * from './pod';
export * from './pvc';
export * from './vm';
Expand Down
1 change: 1 addition & 0 deletions src/selectors/machine/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './selectors';
4 changes: 4 additions & 0 deletions src/selectors/machine/selectors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { find, get } from 'lodash';

export const getMachineNode = (nodes, machine) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

can you please move this to combined.js? There is a convention for this name in other folders when the selector includes multiple entities.

Copy link
Author

Choose a reason for hiding this comment

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

Done

find(nodes, node => get(node, 'metadata.name') === get(machine, 'status.nodeRef.name'));
1 change: 1 addition & 0 deletions src/selectors/node/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './selectors';
3 changes: 3 additions & 0 deletions src/selectors/node/selectors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { get } from 'lodash';

export const getNodeUnschedulable = node => get(node, 'spec.unschedulable', false);
Copy link
Contributor

Choose a reason for hiding this comment

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

isNodeUnschedulable?

Copy link
Author

Choose a reason for hiding this comment

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

Done

9 changes: 8 additions & 1 deletion src/utils/status/host/hostStatus.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { getOperationalStatus, getProvisioningState, getHostErrorMessage } from '../../../selectors';
import {
getOperationalStatus,
getProvisioningState,
getHostErrorMessage,
getNodeUnschedulable,
} from '../../../selectors';

import { HOST_STATUS_TO_TEXT, HOST_STATUS_READY, HOST_STATUS_REGISTERING } from './constants';

Expand All @@ -18,3 +23,5 @@ export const getHostStatus = host => {
export const getSimpleHostStatus = host => getHostStatus(host).status;

export const canHostAddMachine = host => [HOST_STATUS_READY].includes(getSimpleHostStatus(host));
export const canHostStartMaintenance = hostNode => hostNode && !getNodeUnschedulable(hostNode);
export const canHostStopMaintenance = hostNode => hostNode && getNodeUnschedulable(hostNode);
Copy link
Contributor

Choose a reason for hiding this comment

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

no need for hostNode && in canHostStopMaintenance as getNodeUnschedulable returns false as default

Copy link
Author

Choose a reason for hiding this comment

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

Done