Skip to content

Commit

Permalink
Added getShortestPath functionality (not tested)
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitrisGan committed Aug 12, 2019
1 parent 434f680 commit 7d7c4e9
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 6 deletions.
52 changes: 48 additions & 4 deletions net-man-app/src/containers/ApplicationMenu/applicationMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Link } from 'react-router-dom';

import styles from './applicationMenu.module.css';
import { openDaylightApi } from '../../services/openDaylightApi';
import { networkApi } from '../../services/networkApi';
import { getODLnodes, getODLlinks } from '../../utilities/ODL_utilities';


class CreateNetwork extends Component {
Expand All @@ -27,6 +29,48 @@ class CreateNetwork extends Component {

}

getODLinfo = () => {
openDaylightApi.getTopology()
.then(data => {
console.log('openDaylight data:');
console.log(data['network-topology'].topology);

const topologies = data['network-topology'].topology;

const nodes = getODLnodes(topologies);
const links = getODLlinks(topologies);

const node_source = nodes[0];
const node_dest = nodes[1];

console.log("nodes: ", nodes);
console.log("--------------");
console.log("links: ", links);
console.log("--------------");
console.log("node source: ", node_source);
console.log("node dest: ", node_dest);
console.log("--------------");

const requestData = {
nodes: nodes,
links: links,
node_source: node_source,
node_dest: node_dest
}

console.log(requestData);
// return;

networkApi.getShortestPath(requestData)
.then(data => {
alert("Shortest path calculated");
console.log("shortest path: ", data.shortest_path)
});


});
}

render() {
return (
<Container fluid className={styles.MenuContainer}>
Expand All @@ -53,9 +97,9 @@ class CreateNetwork extends Component {
{/* <Col sm={1}/> */}

<Col sm={6}>
<Link to="/topology" className={styles.MenuLink}>
{/* <Jumbotron onClick={this.testODLAPI}> */}
<Jumbotron>
{/* <Link to="/topology" className={styles.MenuLink}> */}
<Jumbotron onClick={this.getODLinfo}>
{/* <Jumbotron> */}
<h1 className="display-5">Application 2</h1>
<p
className="lead"
Expand All @@ -69,7 +113,7 @@ class CreateNetwork extends Component {
out within the larger container.
</p>
</Jumbotron>
</Link>
{/* </Link> */}
</Col>
</Row>
{/* <Row>
Expand Down
16 changes: 15 additions & 1 deletion net-man-app/src/services/networkApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import handleError from './handleError';
export const networkApi = {
createNetwork,
deleteNetwork,
networkExists
networkExists,
getShortestPath
};

function createNetwork(jsonRequest) {
Expand Down Expand Up @@ -47,4 +48,17 @@ function networkExists() {
handleError(error)
}
);
}

function getShortestPath(jsonRequest) {
return axios.post('/shortest_path', jsonRequest)
.then(
response => {
return response.data;
},
error => {
console.log('Error in network creation');
handleError(error)
}
);
}
2 changes: 1 addition & 1 deletion net-man-app/src/utilities/ODL_utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const getODLnodes = (topologies) => {
export const getODLlinks = (topologies) => {
const topo = topologies[0];
let retLinks = [];
for (let link of topo.links)
for (let link of topo.link)
{
retLinks.push([link.source['source-node'], link.destination['dest-node']]);
}
Expand Down

0 comments on commit 7d7c4e9

Please sign in to comment.