El precompiler esta avanzado, ahora solo con crear el archivo data con el lenguaje...
authorFelix <felix.tejada08@gmail.com>
Tue, 22 Oct 2019 06:17:14 +0000 (07:17 +0100)
committerFelix <felix.tejada08@gmail.com>
Tue, 22 Oct 2019 06:17:14 +0000 (07:17 +0100)
cleaner.sh [changed mode: 0644->0755]
clusterGRE.py
precompiler.py [changed mode: 0644->0755]
topotest.py

old mode 100644 (file)
new mode 100755 (executable)
index f14e1407f66894ac3be35c7ba5de2102101fedd6..56b2a95ea9e8800adb2ead9e144c70080275b38f 100755 (executable)
@@ -6,7 +6,8 @@ from mininet.log import setLogLevel
 from mininet.examples.clustercli import ClusterCLI as CLI
 from mininet.node import RemoteController
 from topotest import MiTopo
-
+from precompiler import TopoFromCompiler
 def inicia():
     #IPs = '/home/pi/iplist'
     c = RemoteController('c1', ip='192.168.25.10', port=6633)
@@ -14,8 +15,8 @@ def inicia():
     servers = ['192.168.25.2', '192.168.25.3', '192.168.25.4','192.168.25.5','192.168.25.6']
     topo1 = TreeTopo(depth=2, fanout=2)
     topo2 = MiTopo()
-    #topo2.build()
-    net = MininetCluster(topo=topo2, servers=servers, link=RemoteGRELink, placement=SwitchBinPlacer, controller=c)
+    topo3 = TopoFromCompiler()
+    net = MininetCluster(topo=topo3, servers=servers, link=RemoteGRELink, placement=SwitchBinPlacer, controller=c)
     net.start()
     CLI(net)
     net.stop()
old mode 100644 (file)
new mode 100755 (executable)
index 2e2cf56..86bd4d4
@@ -1,26 +1,64 @@
-#!/usr/bin/env python3
+#!/usr/bin/python
 import sys
 import os
 import time
-cmd = './cleaner.sh '+sys.argv[1]
-os.system(cmd)
+from mininet.topo import Topo
+from mininet.log import setLogLevel, info
+
+"""
+Este precompilador transforma el lenguaje VSORC a la API de topologias de 
+Mininet
+"""
+links = []
+devices = []
+hosts = []
+switches = []
+#Lists
+
+#cmd = './cleaner.sh '+sys.argv[1]
+cmd2 = './cleaner.sh data'
+os.system(cmd2)
 time.sleep(.300)
-document = open(sys.argv[1] + "_clean" ,"r+")
+#document = open(sys.argv[1] + "_clean" ,"r+")
+document = open("data" + "_clean" ,"r+")
 links = document.readlines()
 document.close
 
+
 #clean the \n in the colected data
 a = 0
 for linkline in links:
        links[a] = linkline.rstrip()
        a+=1
 
+
 # get a list of non repeating devices
-devices = []
 for value in links:
        value_split = value.split(':')
        devices.append(value_split[0])
        devices.append(value_split[1])
 devices = list(dict.fromkeys(devices))
-print devices
-print links
+
+
+class TopoFromCompiler(Topo):
+#This class is for create the custom topology from the data collected.
+#Here we also process the data to make the topo
+       def build(self):
+               for device in devices:
+                       if device.startswith("h"):
+                               host = device
+                               host = self.addHost(host) #Create a host with the data collected from the list
+                               hosts.append(host)
+
+                       elif device.startswith("s"):
+                               switch = device
+                               switch = self.addSwitch(switch) #Create a switch
+                               switches.append(switch)
+
+               print ("Devices: " + str(devices) + "\n" + "Links: " + str(links) + "\n" + "Hosts: " + str(hosts) + "\n" + "Switches: " + str(switches) + "\n")
+               
+               #Create links
+               for pair in links:
+                       split = pair.split(":")
+                       self.addLink(split[0],split[1])
+
index 90612966652787f338236d3a4827e42a103a85c4..022207c3c59d9efa74a9ca486c806fea2fc3b3c9 100755 (executable)
@@ -29,7 +29,6 @@ class MiTopo(Topo):
         h7 = self.addHost('h7')
         h9 = self.addHost('h9')
 
-
         self.addLink(h1, s2)
         self.addLink(h9, s4)
         self.addLink(h2, s2)
@@ -42,7 +41,7 @@ class MiTopo(Topo):
         self.addLink(h6, s3)
         self.addLink(h7, s4)
         self.addLink(h8, s4)
-        info('llegue al final de mitopo\n')
+        #info('llegue al final de mitopo\n')
 
 
 #topos = { 'TopoMia': ( lambda: MiTopo() ) }