-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Identify Stargate nodes in the UI (#1179)
* Add parsing to gossipinfo content to identify the stargate nodes and return property via the NodeStatus object * Contextually set the visualization and tooltip on the nodes for Stargate nodes * Remove some stray console logging and bump a legitimate problem up to an error. * Change property to be more future proof in case there are ever other types of nodes to detect * Visually display stargate nodes differently and do not include stargate nodes in selection options for creating repairs/schedules * Cleanup node status modal when node is a stargate node * Refactor out some common functionality to a shared utils class * Add file header, cleanup imports and comments
- Loading branch information
Showing
6 changed files
with
159 additions
and
40 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,73 @@ | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/** | ||
* Utility method for digging through the endpointStates API response structure | ||
* to identify the possible nodes | ||
* | ||
* @param endpointStates - Array | ||
* @returns An array of node/endpoint objects | ||
*/ | ||
|
||
export const getNodesFromEndpointStates = function(endpointStates) { | ||
const nodes = []; | ||
if (!endpointStates || !endpointStates.length) { | ||
return nodes; | ||
} | ||
|
||
for(let endpointState of endpointStates) { | ||
if (!endpointState || !endpointState.endpoints) { | ||
continue; | ||
} | ||
for (let datacenterId in endpointState.endpoints) { | ||
const datacenter = endpointState.endpoints[datacenterId]; | ||
if (!datacenter) { | ||
continue; | ||
} | ||
for (let rackId in datacenter) { | ||
const rack = datacenter[rackId]; | ||
if (!rack) { | ||
continue; | ||
} | ||
for (let endpoint of rack) { | ||
if (endpoint) { | ||
nodes.push(endpoint); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return nodes; | ||
} | ||
|
||
/** | ||
* Utility function for generating a set of options for a select representing a drop down of nodes. | ||
* If excludeStargateNodes is true stargate nodes will not be included in the set of options generated. | ||
* | ||
* @param endpointStates - Array | ||
* @param excludeStargateNodes - Boolean | ||
* @returns An object suitable for passing to Select component | ||
*/ | ||
export const getNodeOptions = function(endpointStates, excludeStargateNodes) { | ||
let nodes = getNodesFromEndpointStates(endpointStates); | ||
if (!nodes) { | ||
return { | ||
nodeOptions: [] | ||
} | ||
} | ||
const includedNodes = excludeStargateNodes ? nodes.filter(node => node.type !== "STARGATE") : nodes; | ||
return { | ||
nodeOptions: includedNodes.map(node => node.endpoint).sort().map( | ||
obj => { return {value: obj, label: obj}; } | ||
) | ||
}; | ||
} |