summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vesagent/docker/Dockerfile23
-rwxr-xr-xvesagent/docker/opt/start-manager.sh2
-rw-r--r--vio/docker/Dockerfile11
-rwxr-xr-xvio/run.sh4
-rw-r--r--vio/vio/swagger/views/workload/views.py41
5 files changed, 54 insertions, 27 deletions
diff --git a/vesagent/docker/Dockerfile b/vesagent/docker/Dockerfile
index 290333b..0d8c106 100644
--- a/vesagent/docker/Dockerfile
+++ b/vesagent/docker/Dockerfile
@@ -1,30 +1,21 @@
# Use an official Python runtime as a parent image
-FROM python:2.7.14
+FROM python:2-alpine
# Make port <Port Num> available to the world outside this container
#EXPOSE <Port Num>
-RUN echo "deb http://http.debian.net/debian jessie-backports main" > /etc/apt/sources.list.d/jessie-backports.list && \
- apt-get update && \
- apt-get install -y vim && \
- apt-get install -y zip && \
- apt-get install -y unzip && \
- apt-get install -y curl && \
- apt-get install -y wget && \
- apt-get install -y -t jessie-backports openjdk-8-jre-headless ca-certificates-java
-
# Set the working directory to /opt
WORKDIR /opt
# Copy the local opt directory contents into the container at /opt
ADD opt /opt
-#Download vesagent jar from nexus repo and place in /opt
-RUN cd /opt/ && \
- wget -O /opt/vesagent-1.0.0.jar 'https://nexus.onap.org/service/local/artifact/maven/redirect?r=snapshots&g=org.onap.multicloud.openstack.vmware&a=vesagent&v=LATEST&e=jar'
-
-# Install any needed packages specified in requirements.txt
-RUN pip install -r requirements.txt
+RUN apk update && \
+ apk add zip unzip curl wget openjdk8 && \
+ cd /opt/ && \
+ wget -O /opt/vesagent-1.0.0.jar 'https://nexus.onap.org/service/local/artifact/maven/redirect?r=snapshots&g=org.onap.multicloud.openstack.vmware&a=vesagent&v=LATEST&e=jar' && \
+ pip install -r requirements.txt && \
+ apk del zip unzip
# Run application when the container launches
CMD [ "/opt/start-manager.sh" ]
diff --git a/vesagent/docker/opt/start-manager.sh b/vesagent/docker/opt/start-manager.sh
index e70dc19..0c6f09b 100755
--- a/vesagent/docker/opt/start-manager.sh
+++ b/vesagent/docker/opt/start-manager.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Copyright (c) 2017-2018 VMware, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/vio/docker/Dockerfile b/vio/docker/Dockerfile
index b035fc6..1fd4eca 100644
--- a/vio/docker/Dockerfile
+++ b/vio/docker/Dockerfile
@@ -1,4 +1,4 @@
-FROM python:2-slim
+FROM python:2-alpine
ENV MSB_ADDR "127.0.0.1"
ENV MSB_PORT "80"
@@ -12,10 +12,10 @@ ENV MR_PORT "3904"
EXPOSE 9004
-RUN groupadd -r onap && useradd -r -g onap onap
+RUN addgroup -S onap && adduser -S -G onap onap
-RUN apt-get update && \
- apt-get install -y unzip wget curl gcc libssl-dev && \
+RUN apk update && \
+ apk add uwsgi unzip wget curl gcc make libc-dev libffi-dev openssl-dev && \
cd /opt/ && \
wget -q -O multicloud-vio.zip 'https://nexus.onap.org/service/local/artifact/maven/redirect?r=snapshots&g=org.onap.multicloud.openstack.vmware&a=multicloud-openstack-vmware&v=1.3.0-SNAPSHOT&e=zip' && \
unzip multicloud-vio.zip && \
@@ -24,8 +24,7 @@ RUN apt-get update && \
mkdir -p /var/log/onap/multicloud/vio && \
chmod a+rw /var/log/onap/multicloud/vio && \
chown onap:onap -R /opt/vio/ && \
- apt-get --purge remove -y unzip gcc && \
- apt-get -y autoremove
+ apk del -y unzip gcc make libc-dev libffi-dev openssl-dev
USER onap
diff --git a/vio/run.sh b/vio/run.sh
index 0a19cd5..1f08d71 100755
--- a/vio/run.sh
+++ b/vio/run.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Copyright (c) 2017-2018 VMware, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -32,7 +32,7 @@ then
python multivimbroker/scripts/api.py
else
# nohup python manage.py runserver 0.0.0.0:9004 2>&1 &
- if [ ${SSL_ENABLED} = "true" ]; then
+ if [ "${SSL_ENABLED}" == "true" ]; then
nohup uwsgi --https :9004,/opt/vio/cert.crt,/opt/vio/cert.key --module vio.wsgi --master --processes 4 &
else
diff --git a/vio/vio/swagger/views/workload/views.py b/vio/vio/swagger/views/workload/views.py
index efcc2f7..a1669c2 100644
--- a/vio/vio/swagger/views/workload/views.py
+++ b/vio/vio/swagger/views/workload/views.py
@@ -18,7 +18,9 @@ from rest_framework import status
from rest_framework.response import Response
from rest_framework.views import APIView
+from vio import heatbridge
from vio.pub.msapi import extsys
+from vio.pub.utils.restcall import AAIClient
from vio.pub.vim.vimapi.heat import OperateStack
from vio.pub.exceptions import VimDriverVioException
@@ -56,7 +58,7 @@ class CreateStackViewV1(APIView):
body = json.loads(request.body)
logger.debug("infra_workload post body: %s" % body)
template_type = body['template_type']
- if template_type != "heat":
+ if template_type.lower() != "heat":
return Response(
data={
"error": "invalid template type %s" % template_type
@@ -74,7 +76,9 @@ class CreateStackViewV1(APIView):
stack = stack_op.create_vim_stack(**stack_body)
rsp = {
"template_type": "heat",
- "workload_id": stack.id
+ "workload_id": stack.id,
+ "workload_status": stack.status,
+ "workload_status_reason": stack.status_reason,
}
return Response(data=rsp, status=status.HTTP_201_CREATED)
except Exception as e:
@@ -87,6 +91,7 @@ class CreateStackViewV1(APIView):
class GetDelStackViewV1(APIView):
def get(self, request, cloud_owner, cloud_region, workload_id):
+ # import ipdb; ipdb.set_trace()
try:
vim_info = extsys.get_vim_by_id(cloud_owner + "_" + cloud_region)
# vim_info['tenant'] = tenantid
@@ -95,10 +100,12 @@ class GetDelStackViewV1(APIView):
try:
stack_op = OperateStack.OperateStack(vim_info)
stack = stack_op.get_vim_stack(workload_id)
+ # import ipdb; ipdb.set_trace()
rsp = {
"template_type": "heat",
"workload_id": stack.id,
"workload_status": stack.status,
+ "workload_status_reason": stack.status_reason,
}
return Response(data=rsp, status=status.HTTP_200_OK)
except Exception as e:
@@ -108,6 +115,36 @@ class GetDelStackViewV1(APIView):
return Response(data={'error': str(e)},
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+ def post(self, request, cloud_owner, cloud_region, workload_id):
+ # import ipdb; ipdb.set_trace()
+ try:
+ vim_info = extsys.get_vim_by_id(cloud_owner + "_" + cloud_region)
+ # vim_info['tenant'] = tenantid
+ except VimDriverVioException as e:
+ return Response(data={'error': str(e)}, status=e.status_code)
+ try:
+ body = json.loads(request.body)
+ vf_module_id = body.get("vf-module-id")
+ generic_vnf_id = body.get("generic-vnf-id")
+ contents = heatbridge.heat_bridge(vim_info, workload_id)
+ contents['vf-module-id'] = vf_module_id
+ contents['generic-vnf-id'] = generic_vnf_id
+ aai_adapter = AAIClient(cloud_owner, cloud_region)
+ aai_adapter.add_vservers(contents)
+ rsp = {
+ "template_type": "heat",
+ "workload_id": workload_id,
+ "workload_status": "AAI_IN_PROGRESS",
+ "workload_status_reason": "Updating AAI relationship",
+ }
+ return Response(data=rsp, status=status.HTTP_202_ACCEPTED)
+ except Exception as e:
+ if hasattr(e, "http_status"):
+ return Response(data={'error': str(e)}, status=e.http_status)
+ else:
+ return Response(data={'error': str(e)},
+ status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+
def delete(self, request, cloud_owner, cloud_region, workload_id):
try:
vim_info = extsys.get_vim_by_id(cloud_owner + "_" + cloud_region)