ADD ./xapp_onboarder /opt/xapp_onboarder
-RUN cd /opt/xapp_onboarder && pip3 install . && ln -s $(pip show xapp_onboarder | grep Location | awk '{printf $2 "/xapp_onboarder/xapp_onboarder"}') /usr/local/bin/xapp_onboarder && ln -s $(pip show xapp_onboarder | grep Location | awk '{printf $2 "/xapp_onboarder/cli"}') /usr/local/bin/cli && rm -r /opt/xapp_onboarder
+RUN cd /opt/xapp_onboarder && pip3 install . && rm -r /opt/xapp_onboarder
ARG HELM_VERSION="2.12.3"
],
python_requires='>=3.6',
install_requires=requirements,
+ entry_points={
+ 'console_scripts': [
+ 'xapp_onboarder = xapp_onboarder.server.server:main',
+ 'cli = xapp_onboarder.server.cli:run'
+ ]
+ },
)
+++ /dev/null
-#!/usr/bin/env python3
-################################################################################
-# Copyright (c) 2020 AT&T Intellectual Property. #
-# #
-# 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 #
-# #
-# http://www.apache.org/licenses/LICENSE-2.0 #
-# #
-# Unless required by applicable law or agreed to in writing, software #
-# distributed under the License is distributed on an "AS IS" BASIS, #
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
-# See the License for the specific language governing permissions and #
-# limitations under the License. #
-################################################################################
-import logging.config
-import pkg_resources
-from xapp_onboarder.server.cli import run
-
-if __name__ == "__main__":
-
- logger_config = pkg_resources.resource_filename("xapp_onboarder", 'logging.conf')
- logging.config.fileConfig(logger_config)
- run()
shutil.rmtree(self.chart_workspace_path)
os.makedirs(self.chart_workspace_path)
shutil.copytree(resource_filename( 'xapp_onboarder', 'resources/xapp-std'), self.chart_workspace_path + '/' + self.chart_name)
- self.helm_client_path = settings.CHART_WORKSPACE_PATH + '/helm'
self.setup_helm()
def setup_helm(self):
+ self.helm_client_path = 'helm'
+ try:
+ process = subprocess.run([self.helm_client_path], stdout=PIPE, stderr=PIPE, check=True)
+
+ except Exception as err:
+ print(err)
+ self.download_helm()
+ self.helm_client_path = settings.CHART_WORKSPACE_PATH + '/helm'
+
+ def download_helm(self):
if not os.path.isfile(settings.CHART_WORKSPACE_PATH + '/helm'):
log.info("Helm client missing. Trying to download it.")
helm_file_name = "helm-v{}-{}-amd64.tar.gz".format(settings.HELM_VERSION, platform.system().lower())
return json.dumps(message, indent=4, sort_keys=True)
def run():
+ logger_config = pkg_resources.resource_filename("xapp_onboarder", 'logging.conf')
+ logging.config.fileConfig(logger_config)
fire.Fire(cli(), name='xapp_onboarder')
if __name__ == "__main__":
- logger_config = pkg_resources.resource_filename("xapp_onboarder", 'logging.conf')
- logging.config.fileConfig(logger_config)
+
run()
class server(object):
def __init__(self):
self.app = Flask(__name__)
- self.app.config['SERVER_NAME'] = settings.FLASK_SERVER_NAME
self.app.config['SWAGGER_UI_DOC_EXPANSION'] = settings.RESTPLUS_SWAGGER_UI_DOC_EXPANSION
self.app.config['RESTPLUS_VALIDATE'] = settings.RESTPLUS_VALIDATE
self.app.config['RESTPLUS_MASK_SWAGGER'] = settings.RESTPLUS_MASK_SWAGGER
def run(self):
log.info('>>>>> Starting development xapp_onboarder at http://{}/api/v1/ <<<<<'.format(self.app.config['SERVER_NAME']))
- self.app.run(debug=settings.FLASK_DEBUG)
+ self.app.run(debug=settings.FLASK_DEBUG, host='0.0.0.0', port=settings.FLASK_PORT)
-if __name__ == "__main__":
+
+
+
+
+def main():
logger_config = pkg_resources.resource_filename("xapp_onboarder", 'logging.conf')
logging.config.fileConfig(logger_config)
server().run()
+
+if __name__ == "__main__":
+ main()
+
import os
# Flask settings
-FLASK_SERVER_NAME = os.environ.get('FLASK_SERVER_NAME') or '0.0.0.0:8888'
+FLASK_PORT = os.environ.get('FLASK_PORT') or '8888'
FLASK_DEBUG = os.environ.get('FLASK_DEBUG') or True # Do not use debug mode in production
# Flask-Restplus settings
# xapp_onboarder settings
CHART_WORKSPACE_PATH = os.environ.get('CHART_WORKSPACE_PATH') or '/tmp/xapp_onboarder'
CHART_REPO_URL = os.environ.get('CHART_REPO_URL') or 'http://0.0.0.0:8080'
-HTTP_TIME_OUT = os.environ.get('HTTP_TIME_OUT') or 10
+HTTP_TIME_OUT = int(os.environ.get('HTTP_TIME_OUT') or 10)
HELM_VERSION = os.environ.get('HELM_VERSION') or '2.12.3'
HTTP_RETRY = os.environ.get('HTTP_RETRY') or 3
ALLOW_REDEPLOY = os.environ.get('ALLOW_REDEPLOY') or True
+++ /dev/null
-#!/usr/bin/env python3
-################################################################################
-# Copyright (c) 2020 AT&T Intellectual Property. #
-# #
-# 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 #
-# #
-# http://www.apache.org/licenses/LICENSE-2.0 #
-# #
-# Unless required by applicable law or agreed to in writing, software #
-# distributed under the License is distributed on an "AS IS" BASIS, #
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
-# See the License for the specific language governing permissions and #
-# limitations under the License. #
-################################################################################
-import logging.config
-import pkg_resources
-from xapp_onboarder.server.server import server
-
-if __name__ == "__main__":
-
- logger_config = pkg_resources.resource_filename("xapp_onboarder", 'logging.conf')
- logging.config.fileConfig(logger_config)
- server().run()
-