Modified start_topo.py to make MAC address and IP address of host configurable.
Change-Id: I2725b50e09dafd8c09c355cc794193c5781820b4
diff --git a/cluster-mgmt/mininet/start_topo.py b/cluster-mgmt/mininet/start_topo.py
index ccabeda..4313014 100755
--- a/cluster-mgmt/mininet/start_topo.py
+++ b/cluster-mgmt/mininet/start_topo.py
@@ -53,15 +53,17 @@
hostname = platform.node()
default_topo = 'topo.%s.py' % hostname
fallback_topo = 'topo.py'
- topofile = default_topo if os.path.exists(default_topo) else fallback_topo
+ if os.path.exists(default_topo):
+ topofile = default_topo
+ else:
+ topofile = fallback_topo
if not os.path.exists( topofile ):
- print( 'Config file %s not found' % default_topo )
+ print( 'Config file %s not found' % topofile )
exit( 1 )
execfile( topofile )
conf = createTopo()
-print conf
class ConfigTopo( Topo ):
"Topology created from config."
@@ -74,19 +76,27 @@
# Add hosts and switches
nmap = {}
for s, prop in conf[ 'switches' ].iteritems():
- # make sure encoding is ASCII (if not, virtual eth creation fails)
- s = s.strip().encode( 'ascii' )
- dpid = prop[ 'dpid' ].strip().encode( 'ascii' )
+ s = s.strip()
+ dpid = None
+ if 'dpid' in prop:
+ dpid = prop[ 'dpid' ].strip()
nmap[ s ] = self.addSwitch( s, dpid=dpid )
for h, prop in conf[ 'hosts' ].iteritems():
- h = h.strip().encode( 'ascii' )
- nmap[ h ] =self.addHost( h )
+ h = h.strip()
+ params = {}
+ if 'mac' in prop:
+ mac = prop[ 'mac' ].strip()
+ params[ 'mac' ] = mac
+ if 'ip' in prop:
+ ip = prop[ 'ip' ].strip()
+ params[ 'ip' ] = ip
+ nmap[ h ] = self.addHost( h, **params )
# Add links
for l in conf[ 'links' ]:
- node1 = nmap[ l[ 'node1' ] ].strip().encode( 'ascii' )
- node2 = nmap[ l[ 'node2' ] ].strip().encode( 'ascii' )
+ node1 = nmap[ l[ 'node1' ] ].strip()
+ node2 = nmap[ l[ 'node2' ] ].strip()
self.addLink( node1, node2 )
class ClusterConnectedSwitch( OVSSwitch ):
@@ -112,8 +122,8 @@
Controller.__init__( self, name, **params )
for cname, addr in conf[ 'controllers' ].iteritems():
- cname = cname.strip().encode( 'ascii' )
- addr = addr.strip().encode( 'ascii' )
+ cname = cname.strip()
+ addr = addr.strip()
ip, port = addr.split( ':' )
self.cmap[ cname ] = RemoteController( cname, ip=ip, port=int( port ) )
@@ -141,6 +151,7 @@
if __name__ == '__main__':
setLogLevel( 'info' )
+ info( "Topology file : %s\n" % topofile )
net = Mininet( topo=ConfigTopo(),
controller=ControllerCluster,
switch=ClusterConnectedSwitch )
diff --git a/cluster-mgmt/mininet/topo.py b/cluster-mgmt/mininet/topo.py
index 2bd8b22..d2a7c10 100644
--- a/cluster-mgmt/mininet/topo.py
+++ b/cluster-mgmt/mininet/topo.py
@@ -9,6 +9,8 @@
"onosdev2" : "192.168.56.12:6633"
},
"switches": {
+ # Note that dpid is optional.
+ # If omitted, sequential number will be assigned.
"sw01": { "dpid": "0000000000000101", "controllers": [ "onosdev1" ] },
"sw02": { "dpid": "0000000000000102", "controllers": [ "onosdev1" ] },
"sw03": { "dpid": "0000000000000103", "controllers": [ "onosdev1" ] },
@@ -16,13 +18,22 @@
"sw05": { "dpid": "0000000000000105", "controllers": [ "onosdev2", "onosdev1" ] }
},
"hosts": {
- "h01": {},
- "h02": {},
- "h03": {},
- "h04": {},
- "h05": {}
+ # Only default interface is configurable for now.
+ # mac and ip are optional and automatically assigned if omitted.
+ # To avoid collision of address, do not mix specified hosts and omitted hosts.
+ "h01": { "mac": "00:00:00:00:01:01", "ip": "10.0.0.1" },
+ "h02": { "mac": "00:00:00:00:02:02", "ip": "10.0.0.2" },
+ "h03": { "mac": "00:00:00:00:03:03", "ip": "10.0.0.3" },
+ "h04": { "mac": "00:00:00:00:04:04", "ip": "10.0.0.4" },
+ "h05": { "mac": "00:00:00:00:05:05", "ip": "10.0.0.5" }
+# "h01": {},
+# "h02": {},
+# "h03": {},
+# "h04": {},
+# "h05": {}
},
"links": [
+ # Note that multiple links between nodes are unsupported (if declared, single link will be created).
{
"node1": "sw01",
"node2": "sw02"
diff --git a/cluster-mgmt/onos-cluster.sh b/cluster-mgmt/onos-cluster.sh
index 6c23cdc..f49c07b 100755
--- a/cluster-mgmt/onos-cluster.sh
+++ b/cluster-mgmt/onos-cluster.sh
@@ -191,6 +191,10 @@
sed -i -e "s|__BACKEND__|${CLUSTER_BACKEND}|" ${tempfile}
sed -i -e "s|__ZK_HOSTS__|${zk_hosts}|" ${tempfile}
sed -i -e "s|__RAMCLOUD_PROTOCOL__|${CLUSTER_RC_PROTOCOL}|" ${tempfile}
+ sed -i -e "s|__RAMCLOUD_IP__|${rc_ip}|" ${tempfile}
+ sed -i -e "s|__RAMCLOUD_COORD_PORT__|${rc_coord_port}|" ${tempfile}
+ sed -i -e "s|__RAMCLOUD_SERVER_PORT__|${rc_server_port}|" ${tempfile}
+ sed -i -e "s|__RAMCLOUD_SERVER_REPLICAS__|${CLUSTER_RC_SERVER_REPLICAS}|" ${tempfile}
# Filling RAMCloud parameters
local host_role=$(read-conf ${CLUSTER_CONF} "cluster.${host}.role")