-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* First version of OSCAR manager
- Loading branch information
Alfonso Pérez
authored
Oct 1, 2018
1 parent
5353fc6
commit f5fbc20
Showing
26 changed files
with
1,911 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ test/*.zip | |
.p* | ||
*.pyc | ||
*.zip* | ||
.settings/ | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM python:3-alpine | ||
|
||
RUN mkdir -p /usr/src/app | ||
WORKDIR /usr/src/app | ||
|
||
COPY requirements.txt /usr/src/app/ | ||
|
||
RUN pip3 install --no-cache-dir -r requirements.txt | ||
|
||
COPY . /usr/src/app | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["python3"] | ||
|
||
CMD ["-m", "swagger_server"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
connexion == 1.1.15 | ||
python_dateutil == 2.6.0 | ||
setuptools >= 21.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# coding: utf-8 | ||
|
||
import sys | ||
from setuptools import setup, find_packages | ||
|
||
NAME = "swagger_server" | ||
VERSION = "1.0.0" | ||
|
||
# To install the library, run the following | ||
# | ||
# python setup.py install | ||
# | ||
# prerequisite: setuptools | ||
# http://pypi.python.org/pypi/setuptools | ||
|
||
REQUIRES = ["connexion"] | ||
|
||
setup( | ||
name=NAME, | ||
version=VERSION, | ||
description="On-premises Serverless Container-aware ARchitectures API Gateway", | ||
author_email="", | ||
url="", | ||
keywords=["Swagger", "On-premises Serverless Container-aware ARchitectures API Gateway"], | ||
install_requires=REQUIRES, | ||
packages=find_packages(), | ||
package_data={'': ['swagger/swagger.yaml']}, | ||
include_package_data=True, | ||
entry_points={ | ||
'console_scripts': ['swagger_server=__main__:main']}, | ||
long_description="""\ | ||
OSCAR API documentation | ||
""" | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# SCAR - Serverless Container-aware ARchitectures | ||
# Copyright (C) 2011 - GRyCAP - Universitat Politecnica de Valencia | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
|
||
__all__ = ['cmdtemplate','request','utils'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# SCAR - Serverless Container-aware ARchitectures | ||
# Copyright (C) 2011 - GRyCAP - Universitat Politecnica de Valencia | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import abc | ||
from enum import Enum | ||
|
||
class CallType(Enum): | ||
INIT = "init" | ||
INVOKE = "invoke" | ||
RUN = "run" | ||
UPDATE = "update" | ||
LS = "ls" | ||
RM = "rm" | ||
LOG = "log" | ||
PUT = "put" | ||
GET = "get" | ||
|
||
class Commands(metaclass=abc.ABCMeta): | ||
''' All the different cloud provider controllers must inherit | ||
from this class to ensure that the commands are defined consistently''' | ||
|
||
@abc.abstractmethod | ||
def init(self): | ||
pass | ||
|
||
@abc.abstractmethod | ||
def invoke(self): | ||
pass | ||
|
||
@abc.abstractmethod | ||
def run(self): | ||
pass | ||
|
||
@abc.abstractmethod | ||
def update(self): | ||
pass | ||
|
||
@abc.abstractmethod | ||
def ls(self): | ||
pass | ||
|
||
@abc.abstractmethod | ||
def rm(self): | ||
pass | ||
|
||
@abc.abstractmethod | ||
def log(self): | ||
pass | ||
|
||
@abc.abstractmethod | ||
def put(self): | ||
pass | ||
|
||
@abc.abstractmethod | ||
def get(self): | ||
pass | ||
|
||
@abc.abstractmethod | ||
def parse_arguments(self, args): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# SCAR - Serverless Container-aware ARchitectures | ||
# Copyright (C) 2011 - GRyCAP - Universitat Politecnica de Valencia | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
|
||
__all__ = ['controller'] |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,5 +93,3 @@ def launch_user_script(): | |
os.makedirs(output_folder, exist_ok=True) | ||
launch_user_script() | ||
upload_output() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# SCAR - Serverless Container-aware ARchitectures | ||
# Copyright (C) 2011 - GRyCAP - Universitat Politecnica de Valencia | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
from src.cmdtemplate import Commands | ||
import src.utils as utils | ||
import requests | ||
from flask import Response | ||
|
||
def flask_response(func): | ||
''' | ||
Decorator used to create a flask Response | ||
''' | ||
def wrapper(*args, **kwargs): | ||
r = func(*args, **kwargs) | ||
kwargs = {'response' : r.content, 'status' : str(r.status_code), 'headers' : r.headers.items()} | ||
return Response(**kwargs) | ||
return wrapper | ||
|
||
class OpenFaas(Commands): | ||
|
||
functions_path = '/system/functions' | ||
function_info = '/system/function/' | ||
invoke_req_response_function = '/function/' | ||
invoke_async_function = '/async-function/' | ||
system_info = '/system/info' | ||
|
||
def __init__(self): | ||
self.endpoint = utils.get_environment_variable("OPENFAAS_URL") | ||
|
||
@flask_response | ||
def ls(self, function_name=None): | ||
path = self.functions_path | ||
if function_name: | ||
path = self.function_info + function_name | ||
return requests.get(self.endpoint + path) | ||
|
||
@flask_response | ||
def init(self, **kwargs): | ||
print(kwargs) | ||
path = self.functions_path | ||
r = requests.post(self.endpoint + path, json=kwargs) | ||
return r | ||
|
||
@flask_response | ||
def invoke(self, function_name, body, asynch=False): | ||
path = self.invoke_req_response_function | ||
if asynch: | ||
path = self.invoke_async_function | ||
return requests.post(self.endpoint + path + function_name, data=body) | ||
|
||
def run(self): | ||
pass | ||
|
||
def update(self): | ||
pass | ||
|
||
@flask_response | ||
def rm(self, function_name): | ||
payload = { 'functionName' : function_name } | ||
return requests.delete(self.endpoint + self.functions_path, json=payload) | ||
|
||
def log(self): | ||
pass | ||
|
||
def put(self): | ||
pass | ||
|
||
def get(self): | ||
pass | ||
|
||
def parse_arguments(self, args): | ||
pass | ||
|
Oops, something went wrong.