+ child = exec(
+ "cd $(echo $HOME/vsorcdistro)/scripts && echo nodes > fifo",
+ function (error, stdout, stderr) {
+ console.log("nodes");
+ res.send(stdout);
+ }
+ );
+});
+
+router.get("/statusnodes", (req, res) => {
+ var sys = require("sys");
+ var exec = require("child_process").exec;
+ var child;
+ child = exec(
+ "cd $(echo $HOME/vsorcdistro)/scripts && echo status > fifo",
+ function (error, stdout, stderr) {
+ console.log("status");
+ res.send(stdout);
+ }
+ );
+});
+
+router.get("/intfs", (req, res) => {
+ var sys = require("sys");
+ var exec = require("child_process").exec;
+ var child;
+ child = exec(
+ "cd $(echo $HOME/vsorcdistro)/scripts && echo intfs > fifo",
+ function (error, stdout, stderr) {
+ console.log("interfaces");
+ res.send(stdout);
+ }
+ );
+});
+
+router.get("/iperf", (req, res) => {
+ var sys = require("sys");
+ var exec = require("child_process").exec;
+ var child;
+ child = exec(
+ "cd $(echo $HOME/vsorcdistro)/scripts && echo iperf > fifo",
+ function (error, stdout, stderr) {
+ console.log("pingall");
+ res.send(stdout);
+ }
+ );
+});
+
+router.get("/pingall", (req, res) => {
+ var sys = require("sys");
+ var exec = require("child_process").exec;
+ var child;
+ child = exec(
+ "cd $(echo $HOME/vsorcdistro)/scripts && echo pingall > fifo",
+ function (error, stdout, stderr) {
+ console.log("pingall");
+ res.send(stdout);
+ }
+ );
+});
+router.get("/placement", (req, res) => {
+ var sys = require("sys");
+ var exec = require("child_process").exec;
+ var child;
+ child = exec(
+ "cd $(echo $HOME/vsorcdistro)/scripts && echo placement > fifo",
+ function (error, stdout, stderr) {
+ console.log("placement");
+ res.send(stdout);
+ }
+ );
+});
+
+router.get("/getvsorcdata", (req, res) => {
+ var sys = require("sys");
+ var exec = require("child_process").exec;
+ var child;
+ var child2;
+ var child3;
+ child2 = exec(
+ "ps aux | grep GRE| grep sudo | grep -v tail| awk {'print $2'}",
+ function (error, stdout, stderr) {
+ console.log("view status vsorc"); //Cambia el valor de isVsorcUP revisando el ID proceso
+ if (stdout === "") {
+ isVsorcUP = false;
+ } else {
+ isVsorcUP = true;
+ }
+ }
+ );
+ child = exec(
+ "cd $(echo $HOME/vsorcdistro)/scripts && cat aichivo 2>/dev/null",
+ function (error, stdout, stderr) {
+ console.log("getting vsorc data");
+ res.send(stdout + "^" + isVsorcUP);
+ }
+ );
+});
+router.get("/getcontrollerdata", (req, res) => {
+ var sys = require("sys");
+ var exec = require("child_process").exec;
+ var child;
+ var child2;
+ child2 = exec(
+ "ps aux | grep python | grep ryu | grep -v grep |awk {'print $2'}",
+ function (error, stdout, stderr) {
+ console.log(stdout);
+ console.log("view status controller");
+ if (stdout === "") {
+ isControllerUP = false;
+ } else {
+ isControllerUP = true;
+ }
+ }
+ );
+ child = exec(
+ "cd $(echo $HOME/vsorcdistro)/scripts && cat controllerout 2>/dev/null",
+ function (error, stdout, stderr) {
+ console.log("getting controller data");
+ res.send(stdout + "^" + isControllerUP); //Send controller data and UP or DOWN separate by ^
+ }
+ );
+});
+
+router.get("/resetflows", (req, res) => {
+ var sys = require("sys");
+ var exec = require("child_process").exec;
+ var child;
+ var child2;
+ let salida;
+ child = exec("curl localhost:8080/data?list=switches", function (
+ error,
+ stdout,
+ stderr
+ ) {
+ let value = "";
+ try {
+ value = JSON.parse(stdout);
+ for (key in value) {
+ child2 = exec(
+ "cd $(echo $HOME/vsorcdistro)/scripts && ./resetflows.sh " + key,
+ function (err, out, stder) {
+ console.log(out);
+ salida = out;
+ }
+ );
+ }
+
+ if (stdout === undifined) {
+ res.send("Switches not found");
+ } else {
+ res.send(salida);
+ }
+ } catch (error) {
+ //console.error(error);
+ console.log("no response from server");
+ // expected output: ReferenceError: nonExistentFunction is not def$
+ // Note - error messages will vary depending on browser
+ }