Skip to content

Commit

Permalink
#309: added fpga/ switch options in slice builder
Browse files Browse the repository at this point in the history
  • Loading branch information
yaxue1123 committed Jan 17, 2024
1 parent bc20fff commit 32ed6f5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/components/SliceViewer/SideNodes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ class SideNodes extends React.Component {
bandwidth: 0,
vlan: ""
})
} else if (this.state.nodeType === "Switch") {
const { selectedSite, nodeName } = this.state;
this.props.onSwitchAdd(selectedSite.name, nodeName);
this.setState({
nodeName: ""
})
}
}

Expand Down Expand Up @@ -385,10 +391,11 @@ class SideNodes extends React.Component {
>
<option value="VM">VM</option>
<option value="Facility">Facility Port</option>
<option value="Switch">Switch</option>
</select>
</div>
{
nodeType === "VM" && <div className="form-group slice-builder-form-group col-md-6">
["VM", "Switch"].includes(nodeType) && <div className="form-group slice-builder-form-group col-md-6">
<label htmlFor="inputNodeName" className="slice-builder-label">
Node Name
<OverlayTrigger
Expand Down
2 changes: 1 addition & 1 deletion src/components/SliceViewer/SingleComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default class SingleComponent extends Component {
<option value="GPU">GPU</option>
<option value="SmartNIC">SmartNIC</option>
<option value="SharedNIC">SharedNIC</option>
{/* <option value="FPGA">FPGA</option> */}
<option value="FPGA">FPGA</option>
<option value="NVME">NVME</option>
<option value="Storage">Storage</option>
</select>
Expand Down
13 changes: 13 additions & 0 deletions src/pages/NewSliceForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,18 @@ class NewSliceForm extends React.Component {
this.setState({ sliceNodes: newSliceNodes, sliceLinks: newSliceLinks});
}

handleSwitchAdd = (site, name) => {
const { graphID, sliceNodes, sliceLinks } = this.state;
const node = {
"type": "Switch",
"site": site,
"name": name,
};
// TODO: add switch function in slice builder
const { newSliceNodes, newSliceLinks } = builder.addSwitch(node, graphID, sliceNodes, sliceLinks);
this.setState({ sliceNodes: newSliceNodes, sliceLinks: newSliceLinks});
}

handleLinkAdd = (type, name) => {
const { selectedCPs, graphID, sliceNodes, sliceLinks } = this.state;
const { newSliceNodes, newSliceLinks} = builder.addLink(type, name, selectedCPs, graphID, sliceNodes, sliceLinks);
Expand Down Expand Up @@ -494,6 +506,7 @@ class NewSliceForm extends React.Component {
nodes={sliceNodes}
onVMAdd={this.handleVMAdd}
onFacilityAdd={this.handleFacilityAdd}
onSwitchAdd={this.handleSwitchAdd}
projectTags={projectTags}
/>
}
Expand Down
6 changes: 3 additions & 3 deletions src/services/parser/sliceParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export default function parseSlice(slice, sliceType) {
let parentId = -1;
for (let i = 0; i < links.length; i++) {
// EXCEPTION status: OVS has SmartNIC (usually SmartNIC has OVS)
if (links[i].label === "has" && ["SmartNIC", "SharedNIC"].includes(objNodes[links[i].target].Type) &&
if (links[i].label === "has" && ["SmartNIC", "SharedNIC", "FPGA"].includes(objNodes[links[i].target].Type) &&
objNodes[links[i].source].Type === "OVS" && links[i].source === id) {
parentId = parseInt(objNodes[links[i].target].id);
break;
Expand Down Expand Up @@ -239,15 +239,15 @@ export default function parseSlice(slice, sliceType) {
if (link.label === "has") {
// Three main categories for "has"
// 1. VM node has NIC/ GPU/ NVME/ Storage or vice versa
if (["SmartNIC", "SharedNIC", "GPU", "NVME", "Storage"].includes(objNodes[link.target].Type) &&
if (["SmartNIC", "SharedNIC", "GPU", "NVME", "Storage", "FPGA"].includes(objNodes[link.target].Type) &&
objNodes[link.source].Type === "VM") {
if (!parentNodeIds.includes(link.source)) {
parentNodeIds.push(link.source);
}
data.parent = link.source;
generateDataElement(data, link.target);
elements.push(data);
} else if (["SmartNIC", "SharedNIC", "GPU", "NVME", "Storage"].includes(objNodes[link.source].Type) &&
} else if (["SmartNIC", "SharedNIC", "GPU", "NVME", "Storage", "FPGA"].includes(objNodes[link.source].Type) &&
objNodes[link.target].Type === "VM") {
// EXCEPTION: NIC/ GPU/ NVME/ Storage has VM
if (!parentNodeIds.includes(link.target)) {
Expand Down

0 comments on commit 32ed6f5

Please sign in to comment.