summaryrefslogtreecommitdiffstats
path: root/dcae-cli/dcae_cli/catalog/mock/schema.py
diff options
context:
space:
mode:
authorMichael Hwang <mhwang@research.att.com>2017-09-15 13:41:58 -0400
committerMichael Hwang <mhwang@research.att.com>2017-09-18 13:00:59 -0400
commit4188380fb7b806640103f557afec344455787a34 (patch)
treec5bbe244980f567012f6dbbcd1b3bb5ddc5ed37c /dcae-cli/dcae_cli/catalog/mock/schema.py
parent5a7ecc5f553c6416beb7327a55967287b0645d14 (diff)
Make server url into a user inputted config param
Change-Id: I90e94445fe0f3c003307355cade493e97d0a202d Issue-Id: DCAEGEN2-110 Signed-off-by: Michael Hwang <mhwang@research.att.com>
Diffstat (limited to 'dcae-cli/dcae_cli/catalog/mock/schema.py')
-rw-r--r--dcae-cli/dcae_cli/catalog/mock/schema.py18
1 files changed, 6 insertions, 12 deletions
diff --git a/dcae-cli/dcae_cli/catalog/mock/schema.py b/dcae-cli/dcae_cli/catalog/mock/schema.py
index a85d11f..a27346b 100644
--- a/dcae-cli/dcae_cli/catalog/mock/schema.py
+++ b/dcae-cli/dcae_cli/catalog/mock/schema.py
@@ -29,7 +29,7 @@ import six
from jsonschema import validate, ValidationError
import requests
-from dcae_cli.util import reraise_with_msg
+from dcae_cli.util import reraise_with_msg, fetch_file_from_web
from dcae_cli.util import config as cli_config
from dcae_cli.util.exc import DcaeException
from dcae_cli.util.logger import get_logger
@@ -61,25 +61,19 @@ log = get_logger('Schema')
# c) Both
#
-# TODO: Source this from app's configuration [ONAP URL TBD]
-_nexus_uri = "http://make-me-valid"
class FetchSchemaError(RuntimeError):
pass
-def _fetch_schema_from_web(server_uri, schema_path):
+def _fetch_schema(schema_path):
try:
- schema_url = "{0}/{1}".format(server_uri, schema_path)
- r = requests.get(schema_url)
- r.raise_for_status()
- return json.loads(r.text)
+ server_url = cli_config.get_server_url()
+ return fetch_file_from_web(server_url, schema_path)
except requests.HTTPError as e:
raise FetchSchemaError("HTTP error from fetching schema", e)
except Exception as e:
raise FetchSchemaError("Unexpected error from fetching schema", e)
-_fetch_schema_from_nexus = partial(_fetch_schema_from_web, _nexus_uri)
-
def _safe_dict(obj):
'''Returns a dict from a dict or json string'''
@@ -113,7 +107,7 @@ def _validate(fetch_schema_func, schema_path, spec):
except FetchSchemaError as e:
reraise_with_msg(e, as_dcae=True)
-_validate_using_nexus = partial(_validate, _fetch_schema_from_nexus)
+_validate_using_nexus = partial(_validate, _fetch_schema)
_path_component_spec = cli_config.get_path_component_spec()
@@ -165,7 +159,7 @@ def apply_defaults_docker_config(config):
"""
# Apply health check defaults
healthcheck_type = config["healthcheck"]["type"]
- component_spec = _fetch_schema_from_nexus(_path_component_spec)
+ component_spec = _fetch_schema(_path_component_spec)
if healthcheck_type in ["http", "https"]:
apply_defaults_func = partial(apply_defaults,