Skip to content

Commit

Permalink
Merge pull request #79 from grycap/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
micafer authored Nov 11, 2020
2 parents d0e58d8 + 0e36d9f commit 1f6af73
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 21 deletions.
5 changes: 3 additions & 2 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import io
import os
import logging
from werkzeug.contrib.fixers import ProxyFix
from werkzeug.middleware.proxy_fix import ProxyFix
from flask_dance.consumer import OAuth2ConsumerBlueprint
from app.settings import Settings
from app.cred import Credentials
Expand Down Expand Up @@ -446,7 +446,8 @@ def getsites(vo=None):
@authorized_with_valid_token
def getimages(site=None, vo=None):
res = ""
if vo == "local":
local = request.args.get('local', None)
if local:
access_token = oidc_blueprint.session.token['access_token']
for image_name, image_id in utils.get_site_images(site, vo, access_token, cred, session["userid"]):
res += '<option name="selectedSiteImage" value=%s>%s</option>' % (image_id, image_name)
Expand Down
3 changes: 1 addition & 2 deletions app/appdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ def get_project_ids(service_id):
projects = {}
# Until it is on the prod instance use the Devel one

deb_url = "https://appdb-dev.marie.hellasgrid.gr"
data = appdb_call('/rest/1.0/va_providers/%s' % service_id, url=deb_url)
data = appdb_call('/rest/1.0/va_providers/%s' % service_id)
if (data and 'virtualization:provider' in data and data['virtualization:provider'] and
'provider:shares' in data['virtualization:provider'] and
data['virtualization:provider']['provider:shares'] and
Expand Down
2 changes: 1 addition & 1 deletion app/templates/advanced_config.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ <h5>Configure scheduling:</h5>
$('#selectedSiteImage').append("<option value=''>Loading Images ...</option>");
$.ajax({
method: "GET",
url: "{{ url_for('home') }}images/" + $("#selectedSite").val() + "/local",
url: "{{ url_for('home') }}images/" + $("#selectedSite").val() + "/" + $('#selectedVO').val() + "?local=1",
success : function(text)
{
$('#selectedSiteImage').empty();
Expand Down
2 changes: 1 addition & 1 deletion app/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def test_images(self, get_images, get_site_images, avatar):
self.login(avatar)
get_images.return_value = ["IMAGE"]
get_site_images.return_value = [("IMAGE_NAME", "IMAGE_ID")]
res = self.client.get('/images/sitename/local')
res = self.client.get('/images/sitename/vo?local=1')
self.assertEqual(200, res.status_code)
self.assertIn(b'<option name="selectedSiteImage" value=IMAGE_ID>IMAGE_NAME</option>', res.data)
res = self.client.get('/images/sitename/vo')
Expand Down
4 changes: 2 additions & 2 deletions app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import ast
import time
import sys
from flask import flash, g
from flask import flash, g, escape
from app import appdb
from fnmatch import fnmatch
from hashlib import md5
Expand Down Expand Up @@ -147,7 +147,7 @@ def get_site_images(site_name, vo, access_token, cred, userid):
return [(image.name, image.id) for image in images]
except Exception as ex:
msg = "Error loading site images: %s!" % str(ex)
return [(msg, msg)]
return [(escape(msg), escape(msg))]


def get_site_usage(site_name, vo, access_token, cred, userid):
Expand Down
13 changes: 9 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM python:3.7
FROM python:3.8.6-alpine3.12

RUN apk add --no-cache git

COPY . /app
WORKDIR /app/
Expand All @@ -7,17 +9,20 @@ COPY ./tosca-templates /opt/tosca-templates

ENV PYTHONPATH=/app

RUN pip3 install gunicorn==20.0.4 && pip install -r /app/requirements.txt
RUN apk add --no-cache --virtual .build-deps gcc libc-dev git \
&& pip3 install meinheld==1.0.2 gunicorn==20.0.4 && pip3 install -r /app/requirements.txt \
&& apk del .build-deps gcc libc-dev git

EXPOSE 5001

ENV WORKER_TYPE "egg:meinheld#gunicorn_worker"
ENV TIMEOUT 180
ENV ENABLE_HTTPS False
ENV WORKERS 1
ENV WORKERS 4

COPY ./docker/start.sh /start.sh

CMD ["/bin/bash","/start.sh"]
CMD ["/bin/sh","/start.sh"]



4 changes: 2 additions & 2 deletions docker/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

if [ "${ENABLE_HTTPS}" == "True" ]; then
if test -e /certs/cert.pem && test -f /certs/key.pem ; then
exec gunicorn --bind 0.0.0.0:5001 -w "$WORKERS" --certfile /certs/cert.pem --keyfile /certs/key.pem --timeout "$TIMEOUT" imdashboard:app
exec gunicorn --bind 0.0.0.0:5001 -k "$WORKER_TYPE" -w "$WORKERS" --certfile /certs/cert.pem --keyfile /certs/key.pem --timeout "$TIMEOUT" imdashboard:app
else
echo "[ERROR] File /certs/cert.pem or /certs/key.pem NOT FOUND!"
exit 1
fi
else
exec gunicorn --bind 0.0.0.0:5001 -w "$WORKERS" --timeout "$TIMEOUT" imdashboard:app
exec gunicorn --bind 0.0.0.0:5001 -k "$WORKER_TYPE" -w "$WORKERS" --timeout "$TIMEOUT" imdashboard:app
fi
15 changes: 8 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
Flask_Dance==2.2.0
Werkzeug==0.15.6
Flask==1.1.1
requests==2.22.0
PyYAML==5.1.2
packaging==19.2
Flask_Dance==3.1.0
Werkzeug==1.0.1
Flask==1.1.2
requests==2.24.0
PyYAML==5.3.1
packaging==20.4
xmltodict==0.12.0
radl==1.1.3
apache-libcloud==3.0.0
#apache-libcloud==3.0.0
git+git://github.com/apache/libcloud
5 changes: 5 additions & 0 deletions tosca-templates/oscar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,18 @@ topology_template:
type: string
description: Access Token for the Kubernetes admin user
default: not_very_secret_token
oscar_password:
type: string
description: OSCAR password
default: oscar123

node_templates:

oscar:
type: tosca.nodes.indigo.OSCAR
properties:
minio_secretkey: minio123
password: { get_input: oscar_password }
capabilities:
endpoint:
properties:
Expand Down
5 changes: 5 additions & 0 deletions tosca-templates/oscar_elastic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ topology_template:
type: string
description: Access Token for the Kubernetes admin user
default: not_very_secret_token
oscar_password:
type: string
description: OSCAR password
default: oscar123

node_templates:

Expand Down Expand Up @@ -88,6 +92,7 @@ topology_template:
type: tosca.nodes.indigo.OSCAR
properties:
minio_secretkey: minio123
password: { get_input: oscar_password }
capabilities:
endpoint:
properties:
Expand Down

0 comments on commit 1f6af73

Please sign in to comment.