From: armando-migliaccio Date: Tue, 11 Jun 2013 01:23:29 +0000 (-0700) Subject: Improve readability for nvplib error messages. X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=7920bd9f882d99d12379a47d6c5569fdf15f7074;p=openstack-build%2Fneutron-build.git Improve readability for nvplib error messages. Fixes bug #1189683 Change-Id: Idaf8e072291af2f08df6a502f1d87ee350aab0af --- diff --git a/quantum/plugins/nicira/nvplib.py b/quantum/plugins/nicira/nvplib.py index 58054882b..1fab480a7 100644 --- a/quantum/plugins/nicira/nvplib.py +++ b/quantum/plugins/nicira/nvplib.py @@ -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)