Bug 4988: OF statistics & REST client
[groupbasedpolicy.git] / demos / gbpsfc-env / demo-gbp1 / rest.py
index 35fceb86581f65788556bdad4e62ddaf441bb48e..7c7f4993e9d11c3e64f5d891a24e1e14674d1546 100755 (executable)
@@ -53,7 +53,7 @@ def post(host, port, uri, data, debug=False):
     if debug == True:
         print r.text
     r.raise_for_status()
-    
+
 
 def get_tenant_data():
     return {
@@ -143,8 +143,14 @@ def get_tenant_data():
                       {
                         "classifier-ref": [
                           {
-                            "name": "icmp",
-                            "instance-name": "icmp"
+                            "name": "icmp-in",
+                            "instance-name": "icmp",
+                            "direction": "in"
+                          },
+                          {
+                            "name": "icmp-out",
+                            "instance-name": "icmp",
+                            "direction": "out"
                           }
                         ],
                         "action-ref": [
@@ -239,17 +245,17 @@ def get_tenant_data():
     }
 
 # Main definition - constants
+
 # =======================
 #     MENUS FUNCTIONS
 # =======================
+
 # Main menu
 
 # =======================
 #      MAIN PROGRAM
 # =======================
+
 # Main Program
 
 def get_tenant_uri():
@@ -311,11 +317,11 @@ def get_tunnel_data():
           }
         ]
       },
-             
+
     ]
   }
             }
-    
+
 def get_tunnel_uri():
     return "/restconf/config/opendaylight-inventory:nodes"
 
@@ -323,159 +329,159 @@ def get_endpoint_data():
     return [{
     "input": {
 
-        "endpoint-group": "clients", 
+        "endpoint-group": "clients",
 
         "network-containment" : "subnet-10.0.35.0/24",
 
-        "l2-context": "bridge-domain1", 
-        "mac-address": "00:00:00:00:35:02", 
+        "l2-context": "bridge-domain1",
+        "mac-address": "00:00:00:00:35:02",
 
         "l3-address": [
             {
-                "ip-address": "10.0.35.2", 
+                "ip-address": "10.0.35.2",
                 "l3-context": "l3-context-vrf-red"
             }
-        ], 
-        "port-name": "vethl-h35_2", 
+        ],
+        "port-name": "vethl-h35_2",
         "tenant": "tenant-red"
     }
 },
             {
     "input": {
 
-        "endpoint-group": "clients", 
+        "endpoint-group": "clients",
 
         "network-containment" : "subnet-10.0.35.0/24",
 
-        "l2-context": "bridge-domain1", 
-        "mac-address": "00:00:00:00:35:03", 
+        "l2-context": "bridge-domain1",
+        "mac-address": "00:00:00:00:35:03",
 
         "l3-address": [
             {
-                "ip-address": "10.0.35.3", 
+                "ip-address": "10.0.35.3",
                 "l3-context": "l3-context-vrf-red"
             }
-        ], 
-        "port-name": "vethl-h35_3", 
+        ],
+        "port-name": "vethl-h35_3",
         "tenant": "tenant-red"
     }
 },
             {
     "input": {
 
-        "endpoint-group": "clients", 
+        "endpoint-group": "clients",
 
         "network-containment" : "subnet-10.0.35.0/24",
 
-        "l2-context": "bridge-domain1", 
-        "mac-address": "00:00:00:00:35:04", 
+        "l2-context": "bridge-domain1",
+        "mac-address": "00:00:00:00:35:04",
 
         "l3-address": [
             {
-                "ip-address": "10.0.35.4", 
+                "ip-address": "10.0.35.4",
                 "l3-context": "l3-context-vrf-red"
             }
-        ], 
-        "port-name": "vethl-h35_4", 
+        ],
+        "port-name": "vethl-h35_4",
         "tenant": "tenant-red"
     }
 },
             {
     "input": {
 
-        "endpoint-group": "clients", 
+        "endpoint-group": "clients",
 
         "network-containment" : "subnet-10.0.35.0/24",
 
-        "l2-context": "bridge-domain1", 
-        "mac-address": "00:00:00:00:35:05", 
+        "l2-context": "bridge-domain1",
+        "mac-address": "00:00:00:00:35:05",
 
         "l3-address": [
             {
-                "ip-address": "10.0.35.5", 
+                "ip-address": "10.0.35.5",
                 "l3-context": "l3-context-vrf-red"
             }
-        ], 
-        "port-name": "vethl-h35_5", 
+        ],
+        "port-name": "vethl-h35_5",
         "tenant": "tenant-red"
     }
 },
             {
     "input": {
 
-        "endpoint-group": "webservers", 
+        "endpoint-group": "webservers",
 
         "network-containment" : "subnet-10.0.36.0/24",
 
-        "l2-context": "bridge-domain1", 
-        "mac-address": "00:00:00:00:36:02", 
+        "l2-context": "bridge-domain1",
+        "mac-address": "00:00:00:00:36:02",
 
         "l3-address": [
             {
-                "ip-address": "10.0.36.2", 
+                "ip-address": "10.0.36.2",
                 "l3-context": "l3-context-vrf-red"
             }
-        ], 
-        "port-name": "vethl-h36_2", 
+        ],
+        "port-name": "vethl-h36_2",
         "tenant": "tenant-red"
     }
 },
             {
     "input": {
 
-        "endpoint-group": "webservers", 
+        "endpoint-group": "webservers",
 
         "network-containment" : "subnet-10.0.36.0/24",
 
-        "l2-context": "bridge-domain1", 
-        "mac-address": "00:00:00:00:36:03", 
+        "l2-context": "bridge-domain1",
+        "mac-address": "00:00:00:00:36:03",
 
         "l3-address": [
             {
-                "ip-address": "10.0.36.3", 
+                "ip-address": "10.0.36.3",
                 "l3-context": "l3-context-vrf-red"
             }
-        ], 
-        "port-name": "vethl-h36_3", 
+        ],
+        "port-name": "vethl-h36_3",
         "tenant": "tenant-red"
     }
 },
             {
     "input": {
 
-        "endpoint-group": "webservers", 
+        "endpoint-group": "webservers",
 
         "network-containment" : "subnet-10.0.36.0/24",
 
-        "l2-context": "bridge-domain1", 
-        "mac-address": "00:00:00:00:36:04", 
+        "l2-context": "bridge-domain1",
+        "mac-address": "00:00:00:00:36:04",
 
         "l3-address": [
             {
-                "ip-address": "10.0.36.4", 
+                "ip-address": "10.0.36.4",
                 "l3-context": "l3-context-vrf-red"
             }
-        ], 
-        "port-name": "vethl-h36_4", 
+        ],
+        "port-name": "vethl-h36_4",
         "tenant": "tenant-red"
     }
 },{
     "input": {
 
-        "endpoint-group": "webservers", 
+        "endpoint-group": "webservers",
 
         "network-containment" : "subnet-10.0.36.0/24",
 
-        "l2-context": "bridge-domain1", 
-        "mac-address": "00:00:00:00:36:05", 
+        "l2-context": "bridge-domain1",
+        "mac-address": "00:00:00:00:36:05",
 
         "l3-address": [
             {
-                "ip-address": "10.0.36.5", 
+                "ip-address": "10.0.36.5",
                 "l3-context": "l3-context-vrf-red"
             }
-        ], 
-        "port-name": "vethl-h36_5", 
+        ],
+        "port-name": "vethl-h36_5",
         "tenant": "tenant-red"
     }
 }]
@@ -491,12 +497,12 @@ if __name__ == "__main__":
     controller=os.environ.get('ODL')
     if controller == None:
         sys.exit("No controller set.")
-    
+
 
     print "tenants"
     tenants=get(controller,DEFAULT_PORT,CONF_TENANT)
     print tenants
-    
+
     print "sending tenant"
     put(controller, DEFAULT_PORT, get_tenant_uri(), get_tenant_data(),True)
     print "sending tunnel"
@@ -504,7 +510,7 @@ if __name__ == "__main__":
     print "registering endpoints"
     for endpoint in get_endpoint_data():
         post(controller, DEFAULT_PORT, get_endpoint_uri(),endpoint,True)
-        
-        
-    
-    
+
+
+
+