Fix get_all_affinity_links example in script. 01/4501/1 affinity-bulk-release-dryrun-1 affinity-bulk-release-dryrun-2 affinity-bulk-release-dryrun-3 affinity-bulk-release-prepare-only-1 jenkins-affinity-bulk-release-dryrun-1 jenkins-affinity-bulk-release-dryrun-2 jenkins-affinity-bulk-release-dryrun-3 jenkins-affinity-bulk-release-prepare-only-1
authorSuchi Raman <suchi.raman@plexxi.com>
Tue, 21 Jan 2014 13:51:42 +0000 (08:51 -0500)
committerSuchi Raman <suchi.raman@plexxi.com>
Tue, 21 Jan 2014 13:51:42 +0000 (08:51 -0500)
Signed-off-by: Suchi Raman <suchi.raman@plexxi.com>
scripts/affinity.py
scripts/affinity_control.py

index b1cb9aba2980e634c8f88da818dd93bbd01a0504..af77a179255a2319e32c416dee308472fee31d5d 100644 (file)
@@ -14,23 +14,22 @@ def rest_method(url, verb):
     print "REST call " + url
     resp, content = h.request(url, verb)
 
-    print content
+#    print content
     print "return code %d" % (resp.status)
-    print "done"
     return content
 
 
 def list_all_hosts(): 
     print "list active hosts"
-    put_url = 'http://localhost:8080/controller/nb/v2/hosttracker/default/hosts/active'
-    content = rest_method(put_url, "GET")
+    get_url = 'http://localhost:8080/controller/nb/v2/hosttracker/default/hosts/active'
+    content = rest_method(get_url, "GET")
     hostCfg = json.loads(content)
     for host in hostCfg['hostConfig']:
         print host
 
     print "list inactive hosts"
-    put_url = 'http://localhost:8080/controller/nb/v2/hosttracker/default/hosts/inactive'
-    rest_method(put_url, "GET")
+    get_url = 'http://localhost:8080/controller/nb/v2/hosttracker/default/hosts/inactive'
+    rest_method(get_url, "GET")
     content = rest_method(put_url, "GET")
     hostCfg = json.loads(content)
     for host in hostCfg['hostConfig']:
@@ -45,7 +44,11 @@ def get_all_affinity_groups():
 def get_all_affinity_links(): 
     print "get all affinity links"
     get_url = 'http://localhost:8080/affinity/nb/v2/affinity/default/affinity-links'
-    rest_method(get_url, "GET")
+    content = rest_method(get_url, "GET")
+    affylinks = json.loads(content)
+    for link in affylinks['affinityLinks']: 
+        print "Affinity link: %s" % link
+        get_affinity_link(link['name'])
 
 def get_affinity_group(groupname): 
     get_url = 'http://localhost:8080/affinity/nb/v2/affinity/default/group/' + groupname
@@ -55,7 +58,7 @@ def get_affinity_link(linkname):
     get_url = 'http://localhost:8080/affinity/nb/v2/affinity/default/link/' + linkname
     content = rest_method(get_url, "GET")
     affyLinkCfg = json.loads(content)
-    for key in affyLinkCfg:
+    for key in sorted(affyLinkCfg):
         print "%10s : %s" % (key, affyLinkCfg[key])
 
 def client_ws_example():
index b5b1662f8368bb39a7b7604c029c21e0d83ca6c3..68c95e6153520eef713fc786e1660c7f753fdf4b 100644 (file)
@@ -91,3 +91,4 @@ class AffinityControl:
             print "Affinity rules could not be disabled" 
             return
         print "Affinity rules disabled"
+