Commented testOfOverlay scripts. 79/11979/3
authorKeith Burns (alagalah) <alagalah@gmail.com>
Wed, 15 Oct 2014 14:24:54 +0000 (07:24 -0700)
committerKeith Burns (alagalah) <alagalah@gmail.com>
Wed, 15 Oct 2014 15:38:11 +0000 (08:38 -0700)
Change-Id: I1681fa94b4f1d3c7f6bb491b01514f36753fbc8f
Signed-off-by: Keith Burns (alagalah) <alagalah@gmail.com>
util/testOfOverlay/config.py
util/testOfOverlay/odl_gbp.py
util/testOfOverlay/testOfOverlay.py

index 4f6875ddcc0421c5bb3cb4662f7ea1fdfe1bad8a..ea27ea8213792e20eb24e3df484ddb573ff5fcd4 100644 (file)
@@ -11,11 +11,12 @@ EG2="e593f05d-96be-47ad-acd5-ba81465680d5"
 
 CONTRACT="22282cca-9a13-4d0c-a67e-a933ebb0b0ae"
 
+# Config for switches, tunnelIP is the local IP address.
 switches = [{'name': 's1',
-             'tunnelIp': '10.160.9.20',
+             'tunnelIp': '192.168.56.30',
              'dpid': '1'},
             {'name': 's2',
-             'tunnelIp': '10.160.9.21',
+             'tunnelIp': '192.168.56.21',
              'dpid': '2'}]
 
 hosts = [{'name': 'h35_2',
index 2b71060928b8ff7e26160d86c189e60d808da9f8..7de93d48e4d20bfad27e529aaea8e93dbaea32a8 100644 (file)
@@ -26,6 +26,7 @@ def get_epg(tenantId, epgId):
 
 tenants = {}
 
+# This is where some of the policy is set, subject and classifiers
 def get_tenant(tenantId):
     if tenantId in tenants: 
         return tenants[tenantId]
@@ -127,6 +128,7 @@ def get_node_config(sw, tun_ip):
     nodes.append(data)
     return data
 
+# This is where specifics of the contract are defined. Note: Classifiers are SET in the get_tenant procedure.
 def get_contract(tenantId, pgroupId, cgroupId, contractId):
     tenant = get_tenant(tenantId)
     pgroup = get_epg(tenantId, pgroupId)
index e2f54dcf116a31ab0eb8d304ffcd2334d16a7dc0..b1f96c897dd65df3bd23492ea37a187020e432aa 100755 (executable)
@@ -14,6 +14,8 @@ def getSubnet(ip):
     return "{}/{}".format(nw.network + 1, nw.prefixlen)
 
 if __name__ == '__main__':
+
+    # Validate all parameters are present
     parser = argparse.ArgumentParser()
     parser.add_argument('--local',
                         help='Set up distributed mininet on local host with the specified switch')
@@ -27,44 +29,62 @@ if __name__ == '__main__':
         parser.print_help()
         sys.exit(3)
 
+    # switches is a list from config.py, when this script is called with --local (switch) and its present in config, it is added to the conf_switches
     conf_switches = []
     if args.local:
         for switch in switches:
             if switch['name'] == args.local:
                 conf_switches = [switch]
                 break
+
+    # Assuming we have switches defined (and hence conf_switches), start mininet with the "hosts" list also from config.py
     net = None
     if len(conf_switches) > 0:
         net = mininet_gbp.startMininet(conf_switches, hosts, args.controller)
     try :
         if args.policy:
             for switch in switches:
+                # This leverages a global from odl_gbp called "nodes", which appends "data" from this for loop
                 odl_gbp.get_node_config(switch['dpid'], switch['tunnelIp'])
-                
+            #This also uses the global "nodes" from odl_gbp
             odl_gbp.register_nodes(args.controller)
 
+        # TENANT, L3CTX, L2BD are imported from config.py
+        # get_tenant looks for the TENANT UUID in a global tenant dictionary in odl_gbp.
+        # If TENANT doesn't already exist in that dict. then a bunch of 'default' tenant data is defined, inluding
+        # subjects and classifiers (at writing specific to HTTP source/dest and ICMP)
         tenant = odl_gbp.get_tenant(TENANT)
+
+        # Layer3 context and Layer BridgeDomain are SET into the tenant{} structure in odl_gbp 
+        # TODO: (maybe call these set???)
         odl_gbp.get_l3c(TENANT, L3CTX)
         odl_gbp.get_bd(TENANT, L2BD, L3CTX)
-       
+
+       # subnets and fds (flood domains)
         subnets = {}
         fds = {}
+        # hosts comes from config.py, which contains target switch, IP Address, MAC address, tenant and EPG
         for host in hosts:
+            # ??????
             if args.local and host['switch'] != args.local:
                 continue
             nw = ipaddr.IPv4Network(host['ip'])
             snet = "{}/{}".format(nw.network + 1, nw.prefixlen)
             router = "{}".format(nw.network + 1)
-        
+
             if snet not in subnets:
                  snid = str(uuid.uuid4())
                  fdid = str(uuid.uuid4())
+                 # Sets flood domain where parent is L2BD from config.py
                  fds[fdid] = odl_gbp.get_fd(TENANT, fdid, L2BD)
-        
+
+                 # sets subnet from tenant, which also includes the flood domain
                  subnets[snet] = odl_gbp.get_subnet(TENANT, snid, fdid, snet, router)
+
+                 # Sets the "network-domain" in global endpointGroups dict in odl_gbp.py
                  odl_gbp.get_epg(TENANT, host['endpointGroup'])["network-domain"] = snid
-        
+
+            # Creates EP information and appends to endpoint list, a global
             odl_gbp.get_ep(TENANT, 
                            host['endpointGroup'], 
                            L3CTX, 
@@ -72,15 +92,21 @@ if __name__ == '__main__':
                            L2BD,
                            host['mac'], 
                            int(net.get(host['switch']).dpid), host['port'])
-        
+
+        # contracts is a global list from config.py.
+        # get_contract creates the specific subject, classifiers, rules etc for the contract
+        #     and appends this to the global tenant list.
         for contract in contracts:
              odl_gbp.get_contract(TENANT, 
                           contract['provider'], contract['consumer'], 
                           contract['id'])
         
+        # POST to the controller to register tenants
         if args.policy:
             odl_gbp.register_tenants(args.controller)
 
+        # POST to controller to register EPS
+        # TODO: Should this be done on a per Tenant basis
         odl_gbp.register_eps(args.controller)
 
         if net is not None: