From ea20f018c05bcc4e56b2dfa3eee30af0d6ffabf3 Mon Sep 17 00:00:00 2001 From: Felix Date: Fri, 29 Nov 2019 01:50:49 +0000 Subject: [PATCH] cambios camacho v1 --- fifo | 0 js/topology/topology.js | 9 +++++- npm-debug.log | 2 +- src/routes/index.js | 63 ++++++++++++++++++++++++++++++----------- src/views/index.ejs | 2 +- src/views/starter.ejs | 58 +++++++++++++++++++++++++++++++------ styles/starter.css | 10 +++++++ 7 files changed, 115 insertions(+), 29 deletions(-) delete mode 100644 fifo diff --git a/fifo b/fifo deleted file mode 100644 index e69de29..0000000 diff --git a/js/topology/topology.js b/js/topology/topology.js index 0f6e1f1..45040e1 100644 --- a/js/topology/topology.js +++ b/js/topology/topology.js @@ -74,8 +74,9 @@ $(function () { } lst = top.hosts; + console.log(top.hosts); for (var i = 0; i < lst.length; i++) { - nodes.push({ "id": lst[i].mac, "type": "host" }); + nodes.push({ "id": lst[i].mac, "type": "host","ip": lst[i].ipv4}); links.push({ "source": lst[i].port.dpid, "target": lst[i].mac, "value": 2, "port": { "source": lst[i].port.port_no, "target": 0 } @@ -153,6 +154,12 @@ $(function () { .attr("class", "label") .attr("dy", size + 14) .text(function (d) { return d.id; }); + + + node.append("text") + .attr("class", "label") + .attr("dy", size + 26) + .text(function (d) { if (d.type === "host")return (d.ip); }); // .text(function (d) { return d.id.replace(/^0+/, ''); }); diff --git a/npm-debug.log b/npm-debug.log index a2cfa34..54b150b 100644 --- a/npm-debug.log +++ b/npm-debug.log @@ -8,7 +8,7 @@ 7 verbose unsafe-perm in lifecycle true 8 info web@1.0.0 Failed to exec start script 9 error web@1.0.0 start: `node src/index.js` -9 error Exit status 1 +9 error Exit status 143 10 error Failed at the web@1.0.0 start script. 10 error This is most likely a problem with the web package, 10 error not with npm itself. diff --git a/src/routes/index.js b/src/routes/index.js index f65c4ef..0084754 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -24,7 +24,8 @@ router.get("/stats", (req, res) => { router.get("/topology", (req, res) => { res.render("topology") }); - +let isVsorcUP = false; +let isControllerUP = false; router.get("/topologyMaker", (req, res) => { res.render("topologyMaker") }); @@ -90,6 +91,16 @@ router.get('/net', (req, res) => { }); }); +router.get('/rpiping', (req, res) => { + var sys = require('sys') + var exec = require('child_process').exec; + var child; + child = exec("cd /home/pi/scripts && ./rpiping.sh", function(error, stdout, stderr) { + console.log("rpiping"); + res.send(stdout); + }); +}); + router.get('/nodes', (req, res) => { var sys = require('sys') var exec = require('child_process').exec; @@ -150,21 +161,32 @@ router.get('/placement', (req, res) => { }); router.get('/getvsorcdata', (req, res) => { + var sys = require('sys') var exec = require('child_process').exec; var child; - child = exec("cd /home/pi/scripts && cat aichivo 2>&1", function(error, stdout, stderr) { + var child2; + child2 = exec("ps aux | grep GRE| grep sudo | grep -v tail| awk {'print $2'}", function(error, stdout, stderr) { + console.log("view status vsorc"); + if (stdout === ""){ + isVsorcUP = false; + }else { + isVsorcUP = true; + } + }); + child = exec("cd /home/pi/scripts && cat aichivo 2>/dev/null", function(error, stdout, stderr) { console.log("getting vsorc data"); - res.send(stdout); + res.send(stdout+"^"+isVsorcUP); }); + }); router.get('/getcontrollerdata', (req, res) => { var sys = require('sys') var exec = require('child_process').exec; var child; - child = exec("cd /home/pi/scripts && cat controllerout 2>&1", function(error, stdout, stderr) { + child = exec("cd /home/pi/scripts && cat controllerout 2>/dev/null", function(error, stdout, stderr) { console.log("getting controller data"); - res.send(stdout); + res.send(stdout+"^"+isControllerUP); }); }); router.get('/listswitch', (req, res) => { @@ -205,6 +227,7 @@ router.get('/status', (req, res) => { router.get('/startcontroller', (req, res) => { + isControllerUP = true; var sys = require('sys') var exec = require('child_process').exec; var child; @@ -217,6 +240,7 @@ router.get('/startcontroller', (req, res) => { }); router.get('/stopcontroller', (req, res) => { + isControllerUP = false; var sys = require('sys') var exec = require('child_process').exec; var child; @@ -245,12 +269,14 @@ router.get('/cancel', (req, res) => { }); }); router.get('/startvsorc', (req, res) => { + var sys = require('sys') var exec = require('child_process').exec; var child0;//needs a mkfifo named fifo to exist var child1; var child2; var child3; + var child4; var answer; request = JSON.parse(req.query.topology) console.log("Topology is : \n"+ request); @@ -259,7 +285,7 @@ router.get('/startvsorc', (req, res) => { console.log(stdout + stderr); answer+=stdout; }); - child1 = exec("cd /home/pi/scripts && mkfifo fifo && touch aichivo", function(error, stdout, stderr) { + child1 = exec("cd /home/pi/scripts && mkfifo fifo && rm aichivo && touch aichivo", function(error, stdout, stderr) { console.log(stdout + stderr); answer+=stdout; }); @@ -267,6 +293,8 @@ router.get('/startvsorc', (req, res) => { console.log(stdout + stderr); answer+=stdout; }); + + //child3 uses tail so it can read from fifo even after a EOF child3 = exec("cd /home/pi/scripts && tail -n +1 -f fifo | sudo ./clusterGRE.py > aichivo 2>&1 &", function(error, stdout, stderr) { console.log(stdout + stderr); @@ -276,6 +304,7 @@ router.get('/startvsorc', (req, res) => { }); router.get('/stopvsorc', (req,res) =>{ + var sys = require('sys') var exec = require('child_process').exec; var child1; @@ -283,25 +312,25 @@ router.get('/stopvsorc', (req,res) =>{ var child3; var payload console.log("erasing..."); - child1 = exec("cd /home/pi/scripts && exec 3>&- && rm fifo && rm aichivo", function(error, stdout, stderr) { + child1 = exec("cd /home/pi/scripts && exec 3>&- ", function(error, stdout, stderr) { console.log(stdout); payload+="rm done\n\n"+stdout; });//esto cierra el fifo, lo cual cierra el programa - //sudo kill $(ps aux | grep GRE| grep sudo|awk {'print $2'}) && cd /home/pi && ./multissh.sh sudo -E mn -c; sudo -E mn -c - console.log("killing all..."); - child2 = exec("sudo kill $(ps aux | grep GRE| grep sudo|awk {'print $2'})", function(error, stdout, stderr) { + //antes, en ves de echo exit > fifo, estaba sudo kill $(ps aux | grep GRE| grep sudo|awk {'print $2'}) + console.log("Exiting..."); + child2 = exec("cd /home/pi/scripts && echo exit > fifo && rm fifo", function(error, stdout, stderr) { console.log(stdout); payload+="killed\n\n"+stdout; }); - console.log("Multisshing and cleaning..."); - child3 = exec("cd /home/pi/scripts && ./multissh.sh sudo -E mn -c; sudo -E mn -c", function(error, stdout, stderr) { - console.log(stdout); - console.log("multisshed"); - payload+="Multisshed\n\n"+stdout; - - }); + // console.log("Multisshing and cleaning..."); + // child3 = exec("cd /home/pi/scripts && ./multissh.sh sudo -E mn -c; sudo -E mn -c", function(error, stdout, stderr) { + // console.log(stdout); + // console.log("multisshed"); + // payload+="Multisshed\n\n"+stdout; + // + // }); res.send(payload); }); module.exports = router; diff --git a/src/views/index.ejs b/src/views/index.ejs index 9999db8..0d3b5f0 100644 --- a/src/views/index.ejs +++ b/src/views/index.ejs @@ -165,7 +165,7 @@
- +