res.send(stdout);
});
});
-
+router.get('/sendcommand', (req, res) => {
+ var sys = require('sys')
+ var exec = require('child_process').exec;
+ var child;
+ request = JSON.parse(req.query.cmd); //recibiendo el comando
+ child = exec("cd /home/pi/scripts && echo \""+request+"\" > fifo", function(error, stdout, stderr) {
+ console.log("command received \n" + request+"\n");
+ res.send(stdout);
+ });
+});
+router.get('/cancel', (req, res) => {
+ var sys = require('sys')
+ var exec = require('child_process').exec;
+ var child;
+ child = exec("sudo kill -2 $(ps aux | grep GRE| grep sudo|awk {'print $2'})", function(error, stdout, stderr) {
+ console.log("cancelled");
+ res.send(stdout);
+ });
+});
router.get('/startvsorc', (req, res) => {
var sys = require('sys')
var exec = require('child_process').exec;
<button type="button" name="button" onclick="intfs()">Interfaces</button>
</div>
</div>
-
+ <div class="panel">
+ <textarea class="text" style="font-size: 12px;" rows="20" cols="7" id="vsorccommand" placeholder="Enviar comandos a la terminal"></textarea>
+ <div class="buttons">
+ <button type="button" name="button" onclick="sendcommand()">Send</button>
+ <!-- <button type="button" name="button" onclick="cancel()">Cancel</button> -->
+ </div>
+ </div>
</div>
<div class="side">
<div class="panel">
<textarea class="text" style="font-size: 12px;" disabled rows="20" cols="7" id="controllerout" placeholder="Salida del controlador"></textarea>
</div>
- <div class="panel">
- <textarea class="text" style="font-size: 12px;" disabled rows="20" cols="7" id="a" placeholder="Salida del controlador"></textarea>
- </div>
+
</div>
<script type="text/javascript">
- let topo = document.getElementById('comandos') //Donde van escrito el DSL
- let vsorcout = document.getElementById('vsorcout') //salida del vsorc
- let controllerout = document.getElementById('controllerout') //salida del controlador
+ let topo = document.getElementById('comandos'); //Donde van escrito el DSL
+ let comando = document.getElementById('vsorccommand'); //Donde va escrito el comando para la terminal
+ let vsorcout = document.getElementById('vsorcout'); //salida del vsorc
+ let controllerout = document.getElementById('controllerout'); //salida del controlador
let timeVsorc = 1000;
- let timeController = 1000;
+ let timeController = 2000;
//Estos time son para especificar cada cuantos ms se pedira leer la data de los archivos aichivo y controllerout
let intervalController = null;//Para tener el id del interval para obtener data del controller
}
xhr.send();
+ }
+ function cancel() {
+ let xhr = new XMLHttpRequest();
+ xhr.open('GET', '/cancel', true);
+ //console.log(xhr); //para ver en la consola
+ xhr.onload = function() {
+ if (xhr.status == 200) { //can use this.status instead
+ console.log("cancelled");
+ }
+ }
+ xhr.send();
+
}
function stopcontroller() {
controllerout.scrollTop = controllerout.scrollHeight;
}
+ function sendcommand() {
+ let xhr = new XMLHttpRequest();
+ cmd = JSON.stringify(comando.value);
+ xhr.open('GET', '/sendcommand?cmd=' + cmd, true);
+ xhr.onload = function() {
+ if (xhr.status == 200) { //can use this.status instead
+ //console.log(xhr.responseText);// para ver en la consola
+ console.log("command sended is "+cmd);
+ }
+ }
+ xhr.send();
+
+ }
function startvsorc() {
let xhr = new XMLHttpRequest();
vsorcout.scrollTop = vsorcout.scrollHeight;
}
+
+
function pingall() {
let xhr = new XMLHttpRequest();
xhr.open('GET', '/pingall', true);
if (xhr.status == 200) { //can use this.status instead
//console.log(xhr.responseText);// para ver en la consola
vsorcout.value+=xhr.response;
- console.log("pingall");
+ console.log("iperf");
}
}
xhr.send();
}
+
function placement() {
let xhr = new XMLHttpRequest();
xhr.open('GET', '/placement', true);
if (xhr.status == 200) { //can use this.status instead
//console.log(xhr.responseText);// para ver en la consola
vsorcout.value+=xhr.response;
- console.log("placement");
+ console.log("statusnodes");
}
if (xhr.status == 200) { //can use this.status instead
//console.log(xhr.responseText);// para ver en la consola
vsorcout.value+=xhr.response;
- console.log("placement");
+ console.log("interfaces");
}