]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Improve readability for nvplib error messages.
authorarmando-migliaccio <amigliaccio@nicira.com>
Tue, 11 Jun 2013 01:23:29 +0000 (18:23 -0700)
committerarmando-migliaccio <amigliaccio@nicira.com>
Tue, 11 Jun 2013 06:03:20 +0000 (23:03 -0700)
Fixes bug #1189683

Change-Id: Idaf8e072291af2f08df6a502f1d87ee350aab0af

quantum/plugins/nicira/nvplib.py

index 58054882b969377b53b5ca8edc7789463da8b125..1fab480a7fbb044aa4c6aea79eb9dc0a986cff17 100644 (file)
@@ -1402,34 +1402,32 @@ def delete_lqueue(cluster, id):
 # -----------------------------------------------------------------------------
 # NVP API Calls for check_nvp_config utility
 # -----------------------------------------------------------------------------
-def check_cluster_connectivity(cluster):
-    """Make sure that we can issue a request to each of the cluster nodes."""
+def config_helper(http_method, http_uri, cluster):
     try:
-        resp = do_single_request(HTTP_GET, "/ws.v1/control-cluster",
+        resp = do_single_request(http_method,
+                                 http_uri,
                                  cluster=cluster)
     except Exception as e:
-        msg = "Failed to connect to cluster %s: %s" % (cluster, str(e))
+        msg = ("Error '%s' when connecting to controller(s): %s."
+               % (str(e), ', '.join(cluster.nvp_controllers)))
         raise Exception(msg)
     return json.loads(resp)
 
 
+def check_cluster_connectivity(cluster):
+    """Make sure that we can issue a request to each of the cluster nodes."""
+    return config_helper(HTTP_GET,
+                         "/ws.v1/control-cluster",
+                         cluster)
+
+
 def get_gateway_services(cluster):
-    try:
-        resp = do_single_request(HTTP_GET,
-                                 "/ws.v1/gateway-service?fields=uuid",
-                                 cluster=cluster)
-    except Exception as e:
-        msg = "Failed to connect to cluster %s: %s" % (cluster, str(e))
-        raise Exception(msg)
-    return json.loads(resp)
+    return config_helper(HTTP_GET,
+                         "/ws.v1/gateway-service?fields=uuid",
+                         cluster)
 
 
 def get_transport_zones(cluster):
-    try:
-        resp = do_single_request(HTTP_GET,
-                                 "/ws.v1/transport-zone?fields=uuid",
-                                 cluster=cluster)
-    except Exception as e:
-        msg = "Failed to connect to cluster %s: %s" % (cluster, str(e))
-        raise Exception(msg)
-    return json.loads(resp)
+    return config_helper(HTTP_GET,
+                         "/ws.v1/transport-zone?fields=uuid",
+                         cluster)