diff options
author | 2019-04-23 10:24:08 -0400 | |
---|---|---|
committer | 2019-04-23 10:43:11 -0400 | |
commit | 908088a44ecd1bd364ab73cac073b89c92b187f0 (patch) | |
tree | 13fcf3a533638d9755e62688041cd8ebbe74da2a /onap-dcae-cbs-docker-client/onap_dcae_cbs_docker_client | |
parent | 3774d36e76ec5cca17ae2588e65e2a990a32ad87 (diff) |
Do not hardcode CBS name4.0.0-ONAPdublin
Change-Id: I80dd0d74368528b161a37a597d07c3de242b1e3e
Issue-ID: DCAEGEN2-1450
Signed-off-by: Tommy Carpenter <tommy@research.att.com>
Diffstat (limited to 'onap-dcae-cbs-docker-client/onap_dcae_cbs_docker_client')
-rw-r--r-- | onap-dcae-cbs-docker-client/onap_dcae_cbs_docker_client/client.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/onap-dcae-cbs-docker-client/onap_dcae_cbs_docker_client/client.py b/onap-dcae-cbs-docker-client/onap_dcae_cbs_docker_client/client.py index 3f2fcf2..80c9f75 100644 --- a/onap-dcae-cbs-docker-client/onap_dcae_cbs_docker_client/client.py +++ b/onap-dcae-cbs-docker-client/onap_dcae_cbs_docker_client/client.py @@ -53,11 +53,13 @@ def _get_envs(): Returns hostname, consul_host. If the necessary ENVs are not found, this is fatal, and raises an exception. """ - if "HOSTNAME" not in os.environ or "CONSUL_HOST" not in os.environ: - raise ENVsMissing("HOSTNAME or CONSUL_HOST missing") - hostname = os.environ["HOSTNAME"] - consul_host = os.environ["CONSUL_HOST"] - return hostname, consul_host + try: + hostname = os.environ["HOSTNAME"] # this is the name of the component itself + consul_host = os.environ["CONSUL_HOST"] # this is the host of consul itself + cbs_name = os.environ["CONFIG_BINDING_SERVICE"] # this is the name under which the CBS is registered in Consul. + except KeyError as e: + raise ENVsMissing("Required ENV Variable {0} missing".format(e)) + return hostname, consul_host, cbs_name def _get_path(path): @@ -72,14 +74,14 @@ def _get_path(path): config = {} - hostname, consul_host = _get_envs() + hostname, consul_host, cbs_name = _get_envs() # not sure how I as the component developer is supposed to know consul port consul_url = "http://{0}:8500".format(consul_host) try: # get my config - cbs_url = _get_uri_from_consul(consul_url, "config_binding_service") + cbs_url = _get_uri_from_consul(consul_url, cbs_name) my_config_endpoint = "{0}/{1}/{2}".format(cbs_url, path, hostname) res = requests.get(my_config_endpoint) |