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>
dockerregistry: {{ .Values.dockerTargetRegistry }}
dockeruser: {{ .Values.dockerUser }}
dockerpass: '@/run/pass/dpass'
dockerregistry: {{ .Values.dockerTargetRegistry }}
dockeruser: {{ .Values.dockerUser }}
dockerpass: '@/run/pass/dpass'
+http_proxy: {{ .Values.http_proxy }}
+https_proxy: {{ .Values.https_proxy }}
+no_proxy: {{ .Values.http_proxy }}
{{ $firstPort := index .Values.service.ports 0 -}}
port: {{ $firstPort.port }}
{{ $firstPort := index .Values.service.ports 0 -}}
port: {{ $firstPort.port }}
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
+
+## [1.0.5] - 5/05/2021
+ * Enhance adapter to also work behind proxy.
## [1.0.4] - 1/07/2021
* Select metadata.json with additional name search in case of multiple json artifacts (Fix for DCAEGEN2-2578)
## [1.0.3] - 7/28/2020
## [1.0.4] - 1/07/2021
* Select metadata.json with additional name search in case of multiple json artifacts (Fix for DCAEGEN2-2578)
## [1.0.3] - 7/28/2020
# =============================================================================
# Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
# =============================================================================
# =============================================================================
# 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
# 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
from aoconversion import exceptions, utils
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
"""
"""
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
RUN mkdir /app
WORKDIR /app
- ADD ./{MODELNAME} /app/{MODELNAME}
+ ADD ./{model_name} /app/{model_name}
ADD ./requirements.txt /app
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
RUN pip install -r /app/requirements.txt && \
pip install acumos_dcae_model_runner
EXPOSE $DCAEPORT
ENTRYPOINT ["acumos_dcae_model_runner"]
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
f.write("{0}=={1}\n".format(r["name"], r["version"]))
# generate the dockerfile
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:
# write the dockerfile, will be removed later
with open("{0}/Dockerfile".format(model_repo_path), "w") as f:
# =============================================================================
# Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved.
# =============================================================================
# =============================================================================
# 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
# 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
Configuration parameters as attributes, make sure the required ones are there,
populate defaults.
"""
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):
self.dcaeuser = dcaeuser
def x(fmt, *args, **kwargs):
self._dockerpass = dockerpass
self.interval = interval
self.tmpdir = tmpdir
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
if catalogs is not None and type(catalogs) is not list:
catalogs = [catalogs]
self.catalogs = catalogs
================================================================================
Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved.
================================================================================
================================================================================
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
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
<modelVersion>4.0.0</modelVersion>
<groupId>org.onap.dcaegen2.platform.adapter</groupId>
<artifactId>dcaegen2-platform-adapter-acumos</artifactId>
<modelVersion>4.0.0</modelVersion>
<groupId>org.onap.dcaegen2.platform.adapter</groupId>
<artifactId>dcaegen2-platform-adapter-acumos</artifactId>
- <version>1.0.4-SNAPSHOT</version>
+ <version>1.0.5-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sonar.sources>.</sonar.sources>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sonar.sources>.</sonar.sources>
# =============================================================================
# Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
# =============================================================================
# =============================================================================
# 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
# 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
setup(
name="aoconversion",
setup(
name="aoconversion",
- version="1.0.4-SNAPSHOT",
+ version="1.0.5-SNAPSHOT",
packages=find_packages(exclude=["tests.*", "tests"]),
author="Tommy Carpenter, Andrew Gauld",
author_email="tommy@research.att.com, agauld@att.com",
packages=find_packages(exclude=["tests.*", "tests"]),
author="Tommy Carpenter, Andrew Gauld",
author_email="tommy@research.att.com, agauld@att.com",
# =============================================================================
# Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved.
# =============================================================================
# =============================================================================
# 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
# 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
def test_gen_dcae_artifacts_for_model(monkeypatch):
model_repo_path = get_fixture_path('models')
model_name = 'example-model'
def test_gen_dcae_artifacts_for_model(monkeypatch):
model_repo_path = get_fixture_path('models')
model_name = 'example-model'
- config = aoconversion.scanner.Config(dcaeurl='http://dcaeurl', dcaeuser='dcaeuser', onboardingurl='https://onboarding', onboardinguser='obuser', onboardingpass='obpass', acumosurl='https://acumos', certfile=None, dockerregistry='dockerregistry', dockeruser='registryuser', dockerpass='registrypassword', tmpdir=model_repo_path)
+ config = aoconversion.scanner.Config(dcaeurl='http://dcaeurl', dcaeuser='dcaeuser', onboardingurl='https://onboarding', onboardinguser='obuser', onboardingpass='obpass', acumosurl='https://acumos', certfile=None, dockerregistry='dockerregistry', dockeruser='registryuser', dockerpass='registrypassword', http_proxy='', https_proxy='', no_proxy='', tmpdir=model_repo_path)
spec = {
"self": {
"version": "1.0.0",
spec = {
"self": {
"version": "1.0.0",
# =============================================================================
# Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
# =============================================================================
# =============================================================================
# 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
# 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
def test_generate_dockerfile():
assert (
def test_generate_dockerfile():
assert (
- docker_gen._generate_dockerfile(TEST_META, "example-model")
+ docker_gen._generate_dockerfile(TEST_META, "example-model", '', '', '')
ADD ./example-model /app/example-model
ADD ./requirements.txt /app
ADD ./example-model /app/example-model
ADD ./requirements.txt /app
+ ENV http_proxy=
+ ENV https_proxy=
+ ENV HTTP_PROXY=
+ ENV HTTPS_PROXY=
+ ENV no_proxy=
+ ENV NO_PROXY=
RUN pip install -r /app/requirements.txt && \
pip install acumos_dcae_model_runner
RUN pip install -r /app/requirements.txt && \
pip install acumos_dcae_model_runner
def test_build_and_push_docker(monkeypatch):
model_repo_path = get_fixture_path('models')
def test_build_and_push_docker(monkeypatch):
model_repo_path = get_fixture_path('models')
- config = scanner.Config(dcaeurl='http://dcaeurl', dcaeuser='dcaeuser', onboardingurl='https://onboarding', onboardinguser='obuser', onboardingpass='obpass', acumosurl='https://acumos', certfile=None, dockerregistry='dockerregistry', dockeruser='registryuser', dockerpass='registrypassword', tmpdir=model_repo_path)
+ config = scanner.Config(dcaeurl='http://dcaeurl', dcaeuser='dcaeuser', onboardingurl='https://onboarding', onboardinguser='obuser', onboardingpass='obpass', acumosurl='https://acumos', certfile=None, dockerregistry='dockerregistry', dockeruser='registryuser', dockerpass='registrypassword', http_proxy='', https_proxy='', no_proxy='', tmpdir=model_repo_path)
monkeypatch.setattr(docker_gen, 'APIClient', test_fed._mockdocker.APIClient)
assert(docker_gen.build_and_push_docker(config, 'example-model', model_version="latest") == 'dockerregistry/example-model:latest')
monkeypatch.setattr(docker_gen, 'APIClient', test_fed._mockdocker.APIClient)
assert(docker_gen.build_and_push_docker(config, 'example-model', model_version="latest") == 'dockerregistry/example-model:latest')
# =============================================================================
# Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved.
# =============================================================================
# =============================================================================
# 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
# 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
def test_aoconversion(mock_schemas, tmpdir, monkeypatch):
def test_aoconversion(mock_schemas, tmpdir, monkeypatch):
- config = aoc_scanner.Config(dcaeurl='http://dcaeurl', dcaeuser='dcaeuser', onboardingurl='https://onboarding', onboardinguser='obuser', onboardingpass='obpass', acumosurl='https://acumos', certfile=None, dockerregistry='dockerregistry', dockeruser='registryuser', dockerpass='registrypassword')
+ config = aoc_scanner.Config(dcaeurl='http://dcaeurl', dcaeuser='dcaeuser', onboardingurl='https://onboarding', onboardinguser='obuser', onboardingpass='obpass', acumosurl='https://acumos', certfile=None, dockerregistry='dockerregistry', dockeruser='registryuser', dockerpass='registrypassword', http_proxy='', https_proxy='', no_proxy='')
monkeypatch.setattr(aoc_docker_gen, 'APIClient', _mockdocker.APIClient)
monkeypatch.setattr(requests, 'get', _mockwww(_mockwebdata))
monkeypatch.setattr(requests, 'post', _mockwww(_mockpostdata))
monkeypatch.setattr(aoc_docker_gen, 'APIClient', _mockdocker.APIClient)
monkeypatch.setattr(requests, 'get', _mockwww(_mockwebdata))
monkeypatch.setattr(requests, 'post', _mockwww(_mockpostdata))