Fixed bugs while getting demo.py to work.
[affinity.git] / scripts / affinity.py
index edfd32de6d9a4ce245cf0bedaa59caad6309bf61..67ebdc348020ddbcf82d51fab3c435a92a5b77c4 100644 (file)
@@ -85,17 +85,40 @@ def get_affinity_group(groupname):
     get_url = 'http://localhost:8080/affinity/nb/v2/affinity/default/group/' + groupname
     rest_method(get_url, "GET")
 
+def get_affinity_link(linkname):
+    get_url = 'http://localhost:8080/affinity/nb/v2/affinity/default/link/' + linkname
+    rest_method(get_url, "GET")
+
 def set_waypoint_address():
     wp = "10.0.0.2"
-    put_url = 'http://localhost:8080/affinity/nb/v2/affinity/default/link/inflows/setwaypoint/' + wp
+    al = 'inflows'
+    put_url = 'http://localhost:8080/affinity/nb/v2/affinity/default/link/' + al + '/setwaypoint/' + wp
+    rest_method(put_url, "PUT")
+
+def unset_waypoint_address():
+    al = 'inflows'
+    put_url = 'http://localhost:8080/affinity/nb/v2/affinity/default/link/' + al + '/unsetwaypoint'
+    rest_method(put_url, "PUT")
+
+def set_deny(setflag='deny'):
+    al = 'inflows'
+    put_url = 'http://localhost:8080/affinity/nb/v2/affinity/default/link/' + al + '/' + setflag + '/'
     rest_method(put_url, "PUT")
 
-def enable_waypoint():
-    put_url = 'http://localhost:8080/affinity/nb/v2/affinity/default/link/inflows/enable/' 
+#def enable_waypoint():
+#    put_url = 'http://localhost:8080/affinity/nb/v2/affinity/default/link/inflows/enable/' 
+#    rest_method(put_url, "PUT")
+
+#def disable_waypoint():
+#    put_url = 'http://localhost:8080/affinity/nb/v2/affinity/default/link/inflows/disable/'
+#    rest_method(put_url, "PUT")
+
+def enable_affinity():
+    put_url = 'http://localhost:8080/affinity/nb/v2/flatl2/default/enableaffinity/'
     rest_method(put_url, "PUT")
 
-def disable_waypoint():
-    put_url = 'http://localhost:8080/affinity/nb/v2/affinity/default/link/inflows/disable/'
+def disable_affinity():
+    put_url = 'http://localhost:8080/affinity/nb/v2/flatl2/default/disableaffinity/'
     rest_method(put_url, "PUT")
 
 # Add waypoint IP to an affinity link.
@@ -106,13 +129,22 @@ def main():
 
     get_affinity_group('webservers')
     get_affinity_group('clients')
+    get_affinity_link('inflows')
 
     get_all_affinity_groups()
     list_all_hosts()
 
+    # Set affinity attributes and make sure they are associated with the affinity link. 
     set_waypoint_address()
-    enable_waypoint()
-    disable_waypoint()
+    set_deny('deny')
+    set_deny('permit')
+    get_affinity_link('inflows')
+
+    enable_affinity()
+    disable_affinity()
+
+#    enable_waypoint()
+#    disable_waypoint()
 
 #if __name__ == "__main__":
 #    main()