summaryrefslogtreecommitdiffstats
path: root/adapter/acumos/aoconversion
diff options
context:
space:
mode:
authorshabs2020 <shabnam.sultana@highstreet-technologies.com>2021-05-05 13:20:45 +0200
committershabs2020 <shabnam.sultana@highstreet-technologies.com>2021-05-06 15:18:43 +0200
commit4a02e289d08e2a9d6203b6e72e2a7c8bd3228070 (patch)
treede60ac89bb63103eb8034c0844cad8bb3563c126 /adapter/acumos/aoconversion
parentfdbd89ed0c57f370f6ba3e6390f4b523c965fb9c (diff)
Enable Adapter to work behind proxy
Adapter is now capable of metadata installation during docker image generation both with and without proxy. Issue-ID: DCAEGEN2-2755 Signed-off-by: shabs2020 <shabnam.sultana@highstreet-technologies.com> Change-Id: Icc428db4afcf71103828683f3ac3b4b6d22ec1d0 Signed-off-by: shabs2020 <shabnam.sultana@highstreet-technologies.com>
Diffstat (limited to 'adapter/acumos/aoconversion')
-rw-r--r--adapter/acumos/aoconversion/docker_gen.py31
-rw-r--r--adapter/acumos/aoconversion/scanner.py7
2 files changed, 26 insertions, 12 deletions
diff --git a/adapter/acumos/aoconversion/docker_gen.py b/adapter/acumos/aoconversion/docker_gen.py
index bf54cfc..07cc9d7 100644
--- a/adapter/acumos/aoconversion/docker_gen.py
+++ b/adapter/acumos/aoconversion/docker_gen.py
@@ -3,6 +3,8 @@
# =============================================================================
# Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
# =============================================================================
+# Copyright (c) 2021 highstreet technologies GmbH. All rights reserved.
+# =============================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@@ -21,20 +23,26 @@ from docker import APIClient
from aoconversion import exceptions, utils
-def _generate_dockerfile(meta, model_name):
+def _generate_dockerfile(meta, model_name, http_proxy, https_proxy, no_proxy):
"""
bind the templated docker string
"""
- docker_template = """
- FROM python:{VERSION}
+ python_version = meta["runtime"]["version"]
+ docker_template = f'''
+ FROM python:{python_version}
- ENV MODELNAME {MODELNAME}
+ ENV MODELNAME {model_name}
RUN mkdir /app
WORKDIR /app
- ADD ./{MODELNAME} /app/{MODELNAME}
+ ADD ./{model_name} /app/{model_name}
ADD ./requirements.txt /app
-
+ ENV http_proxy={http_proxy}
+ ENV https_proxy={https_proxy}
+ ENV HTTP_PROXY={http_proxy}
+ ENV HTTPS_PROXY={https_proxy}
+ ENV no_proxy={no_proxy}
+ ENV NO_PROXY={no_proxy}
RUN pip install -r /app/requirements.txt && \
pip install acumos_dcae_model_runner
@@ -42,10 +50,10 @@ def _generate_dockerfile(meta, model_name):
EXPOSE $DCAEPORT
ENTRYPOINT ["acumos_dcae_model_runner"]
- CMD ["/app/{MODELNAME}"]
- """
- python_version = meta["runtime"]["version"]
- return docker_template.format(VERSION=python_version, MODELNAME=model_name)
+ CMD ["/app/{model_name}"]
+ '''
+
+ return docker_template
# Public
@@ -70,7 +78,8 @@ def build_and_push_docker(config, model_name, model_version="latest"):
f.write("{0}=={1}\n".format(r["name"], r["version"]))
# generate the dockerfile
- dockerfile = _generate_dockerfile(meta, model_name)
+ print("Http_Proxy: {} & Https_Proxy: {}".format(config.http_proxy, config.https_proxy))
+ dockerfile = _generate_dockerfile(meta, model_name, config.http_proxy, config.https_proxy, config.no_proxy)
# write the dockerfile, will be removed later
with open("{0}/Dockerfile".format(model_repo_path), "w") as f:
diff --git a/adapter/acumos/aoconversion/scanner.py b/adapter/acumos/aoconversion/scanner.py
index cefcc3d..18dd701 100644
--- a/adapter/acumos/aoconversion/scanner.py
+++ b/adapter/acumos/aoconversion/scanner.py
@@ -3,6 +3,8 @@
# =============================================================================
# Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved.
# =============================================================================
+# Copyright (c) 2021 highstreet technologies GmbH. All rights reserved.
+# =============================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@@ -47,7 +49,7 @@ class Config(object):
Configuration parameters as attributes, make sure the required ones are there,
populate defaults.
"""
- def __init__(self, dcaeuser, onboardingurl, onboardinguser, onboardingpass, certfile, dockerregistry, dockeruser, dockerpass, acumosurl=None, interval=900, dockerhost='tcp://localhost:2375', tmpdir='/var/tmp/aoadapter', certverify=True, catalogs=None, port=None, **extras):
+ def __init__(self, dcaeuser, onboardingurl, onboardinguser, onboardingpass, certfile, dockerregistry, dockeruser, dockerpass, http_proxy, https_proxy, no_proxy, acumosurl=None, interval=900, dockerhost='tcp://localhost:2375', tmpdir='/var/tmp/aoadapter', certverify=True, catalogs=None, port=None, **extras):
self.dcaeuser = dcaeuser
def x(fmt, *args, **kwargs):
@@ -64,6 +66,9 @@ class Config(object):
self._dockerpass = dockerpass
self.interval = interval
self.tmpdir = tmpdir
+ self.http_proxy = http_proxy if http_proxy is not None else ""
+ self.https_proxy = https_proxy if http_proxy is not None else ""
+ self.no_proxy = no_proxy if no_proxy is not None else ""
if catalogs is not None and type(catalogs) is not list:
catalogs = [catalogs]
self.catalogs = catalogs