diff options
| -rw-r--r-- | .github/workflows/api.yml (renamed from .github/workflows/web-server.yml) | 6 | ||||
| -rw-r--r-- | Dockerfile | 25 | ||||
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | api/.gitignore (renamed from web-server/.gitignore) | 0 | ||||
| -rw-r--r-- | api/.gitlab-ci.yml (renamed from web-server/.gitlab-ci.yml) | 0 | ||||
| -rw-r--r-- | api/.pylintrc (renamed from web-server/.pylintrc) | 0 | ||||
| -rw-r--r-- | api/.style.yapf (renamed from web-server/.style.yapf) | 0 | ||||
| -rw-r--r-- | api/Dockerfile | 17 | ||||
| -rw-r--r-- | api/README.md (renamed from web-server/README.md) | 4 | ||||
| -rwxr-xr-x | api/check.sh (renamed from web-server/check.sh) | 0 | ||||
| -rw-r--r-- | api/conftest.py (renamed from web-server/conftest.py) | 0 | ||||
| -rwxr-xr-x | api/format.sh (renamed from web-server/format.sh) | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | api/main.py (renamed from web-server/main.py) | 1 | ||||
| -rw-r--r-- | api/misc/artwork/opendc-web-server-component-diagram.png (renamed from web-server/misc/artwork/opendc-web-server-component-diagram.png) | bin | 90161 -> 90161 bytes | |||
| -rw-r--r-- | api/opendc/__init__.py (renamed from web-server/opendc/__init__.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/__init__.py (renamed from web-server/opendc/api/__init__.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/__init__.py (renamed from web-server/opendc/api/v2/__init__.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/paths.json (renamed from web-server/opendc/api/v2/paths.json) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/portfolios/__init__.py (renamed from web-server/opendc/api/v2/portfolios/__init__.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/portfolios/portfolioId/__init__.py (renamed from web-server/opendc/api/v2/portfolios/portfolioId/__init__.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/portfolios/portfolioId/endpoint.py (renamed from web-server/opendc/api/v2/portfolios/portfolioId/endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/portfolios/portfolioId/scenarios/__init__.py (renamed from web-server/opendc/api/v2/portfolios/portfolioId/scenarios/__init__.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/portfolios/portfolioId/scenarios/endpoint.py (renamed from web-server/opendc/api/v2/portfolios/portfolioId/scenarios/endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/portfolios/portfolioId/scenarios/test_endpoint.py (renamed from web-server/opendc/api/v2/portfolios/portfolioId/scenarios/test_endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/portfolios/portfolioId/test_endpoint.py (renamed from web-server/opendc/api/v2/portfolios/portfolioId/test_endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/prefabs/__init__.py (renamed from web-server/opendc/api/v2/prefabs/__init__.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/prefabs/endpoint.py (renamed from web-server/opendc/api/v2/prefabs/endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/prefabs/prefabId/__init__.py (renamed from web-server/opendc/api/v2/prefabs/prefabId/__init__.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/prefabs/prefabId/endpoint.py (renamed from web-server/opendc/api/v2/projects/__init__.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/prefabs/prefabId/test_endpoint.py (renamed from web-server/opendc/api/v2/projects/projectId/__init__.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/prefabs/test_endpoint.py (renamed from web-server/opendc/api/v2/prefabs/test_endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/projects/__init__.py (renamed from web-server/opendc/api/v2/projects/projectId/authorizations/__init__.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/projects/endpoint.py (renamed from web-server/opendc/api/v2/projects/endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/projects/projectId/__init__.py (renamed from web-server/opendc/api/v2/projects/projectId/portfolios/__init__.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/projects/projectId/authorizations/__init__.py (renamed from web-server/opendc/api/v2/projects/projectId/topologies/__init__.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/projects/projectId/authorizations/endpoint.py (renamed from web-server/opendc/api/v2/projects/projectId/authorizations/endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/projects/projectId/authorizations/test_endpoint.py (renamed from web-server/opendc/api/v2/projects/projectId/authorizations/test_endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/projects/projectId/endpoint.py (renamed from web-server/opendc/api/v2/projects/projectId/endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/projects/projectId/portfolios/__init__.py (renamed from web-server/opendc/api/v2/scenarios/__init__.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/projects/projectId/portfolios/endpoint.py (renamed from web-server/opendc/api/v2/projects/projectId/portfolios/endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/projects/projectId/portfolios/test_endpoint.py (renamed from web-server/opendc/api/v2/projects/projectId/portfolios/test_endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/projects/projectId/test_endpoint.py (renamed from web-server/opendc/api/v2/projects/projectId/test_endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/projects/projectId/topologies/__init__.py (renamed from web-server/opendc/api/v2/scenarios/scenarioId/__init__.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/projects/projectId/topologies/endpoint.py (renamed from web-server/opendc/api/v2/projects/projectId/topologies/endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/projects/projectId/topologies/test_endpoint.py (renamed from web-server/opendc/api/v2/projects/projectId/topologies/test_endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/projects/test_endpoint.py (renamed from web-server/opendc/api/v2/projects/test_endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/scenarios/__init__.py (renamed from web-server/opendc/api/v2/schedulers/__init__.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/scenarios/scenarioId/__init__.py (renamed from web-server/opendc/api/v2/topologies/__init__.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/scenarios/scenarioId/endpoint.py (renamed from web-server/opendc/api/v2/scenarios/scenarioId/endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/scenarios/scenarioId/test_endpoint.py (renamed from web-server/opendc/api/v2/scenarios/scenarioId/test_endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/schedulers/__init__.py (renamed from web-server/opendc/api/v2/topologies/topologyId/__init__.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/schedulers/endpoint.py (renamed from web-server/opendc/api/v2/schedulers/endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/schedulers/test_endpoint.py (renamed from web-server/opendc/api/v2/schedulers/test_endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/topologies/__init__.py (renamed from web-server/opendc/api/v2/traces/__init__.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/topologies/topologyId/__init__.py (renamed from web-server/opendc/api/v2/traces/traceId/__init__.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/topologies/topologyId/endpoint.py (renamed from web-server/opendc/api/v2/topologies/topologyId/endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/topologies/topologyId/test_endpoint.py (renamed from web-server/opendc/api/v2/topologies/topologyId/test_endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/traces/__init__.py (renamed from web-server/opendc/api/v2/users/__init__.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/traces/endpoint.py (renamed from web-server/opendc/api/v2/traces/endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/traces/test_endpoint.py (renamed from web-server/opendc/api/v2/traces/test_endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/traces/traceId/__init__.py (renamed from web-server/opendc/api/v2/users/userId/__init__.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/traces/traceId/endpoint.py (renamed from web-server/opendc/api/v2/traces/traceId/endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/traces/traceId/test_endpoint.py (renamed from web-server/opendc/api/v2/traces/traceId/test_endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/users/__init__.py (renamed from web-server/opendc/models/__init__.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/users/endpoint.py (renamed from web-server/opendc/api/v2/users/endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/users/test_endpoint.py (renamed from web-server/opendc/api/v2/users/test_endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/users/userId/__init__.py (renamed from web-server/opendc/util/__init__.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/users/userId/endpoint.py (renamed from web-server/opendc/api/v2/users/userId/endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/api/v2/users/userId/test_endpoint.py (renamed from web-server/opendc/api/v2/users/userId/test_endpoint.py) | 0 | ||||
| -rw-r--r-- | api/opendc/models/__init__.py | 0 | ||||
| -rw-r--r-- | api/opendc/models/model.py (renamed from web-server/opendc/models/model.py) | 0 | ||||
| -rw-r--r-- | api/opendc/models/portfolio.py (renamed from web-server/opendc/models/portfolio.py) | 0 | ||||
| -rw-r--r-- | api/opendc/models/prefab.py (renamed from web-server/opendc/models/prefab.py) | 0 | ||||
| -rw-r--r-- | api/opendc/models/project.py (renamed from web-server/opendc/models/project.py) | 0 | ||||
| -rw-r--r-- | api/opendc/models/scenario.py (renamed from web-server/opendc/models/scenario.py) | 0 | ||||
| -rw-r--r-- | api/opendc/models/topology.py (renamed from web-server/opendc/models/topology.py) | 0 | ||||
| -rw-r--r-- | api/opendc/models/trace.py (renamed from web-server/opendc/models/trace.py) | 0 | ||||
| -rw-r--r-- | api/opendc/models/user.py (renamed from web-server/opendc/models/user.py) | 0 | ||||
| -rw-r--r-- | api/opendc/util/__init__.py | 0 | ||||
| -rw-r--r-- | api/opendc/util/database.py (renamed from web-server/opendc/util/database.py) | 0 | ||||
| -rw-r--r-- | api/opendc/util/exceptions.py (renamed from web-server/opendc/util/exceptions.py) | 0 | ||||
| -rw-r--r-- | api/opendc/util/parameter_checker.py (renamed from web-server/opendc/util/parameter_checker.py) | 0 | ||||
| -rw-r--r-- | api/opendc/util/path_parser.py (renamed from web-server/opendc/util/path_parser.py) | 0 | ||||
| -rw-r--r-- | api/opendc/util/rest.py (renamed from web-server/opendc/util/rest.py) | 0 | ||||
| -rw-r--r-- | api/pytest.ini (renamed from web-server/pytest.ini) | 0 | ||||
| -rw-r--r-- | api/requirements.txt (renamed from web-server/requirements.txt) | 0 | ||||
| -rw-r--r-- | api/static/index.html (renamed from web-server/static/index.html) | 0 | ||||
| -rw-r--r-- | docker-compose.yml | 6 | ||||
| -rw-r--r-- | web-server/opendc/api/v2/prefabs/prefabId/endpoint.py | 53 | ||||
| -rw-r--r-- | web-server/opendc/api/v2/prefabs/prefabId/test_endpoint.py | 140 |
90 files changed, 27 insertions, 227 deletions
diff --git a/.github/workflows/web-server.yml b/.github/workflows/api.yml index 6f14f97b..7335c737 100644 --- a/.github/workflows/web-server.yml +++ b/.github/workflows/api.yml @@ -1,13 +1,13 @@ -name: Web server +name: REST API on: push: paths: - - 'web-server/*' + - 'api/*' defaults: run: - working-directory: web-server + working-directory: api jobs: build: diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 50af30b1..00000000 --- a/Dockerfile +++ /dev/null @@ -1,25 +0,0 @@ -FROM nikolaik/python-nodejs:python3.8-nodejs14 -MAINTAINER OpenDC Maintainers <opendc@atlarge-research.com> - -## Dockerfile for the frontend/server part of the deployment - -# Installing packages -RUN apt-get update \ - && apt-get install -y yarn git sed - -# Copy OpenDC directory -COPY ./ /opendc - -# Fetch web server dependencies -RUN pip install -r /opendc/web-server/requirements.txt - -# Build frontend -RUN cd /opendc/frontend \ - && rm -rf ./build \ - && yarn \ - && yarn build - -# Set working directory -WORKDIR /opendc - -CMD ["sh", "-c", "python web-server/main.py"] @@ -23,7 +23,7 @@ OpenDC is a project by the [@Large Research Group](http://atlarge-research.com). ## Architecture -OpenDC consists of four components: a Kotlin [simulator](/simulator), a MongoDB database, a Python Flask [web server](/web-server), and a React.js [frontend](/frontend), each in their own subdirectories. +OpenDC consists of four components: a Kotlin [simulator](/simulator), a MongoDB database, a Python Flask [web server](/api), and a React.js [frontend](/frontend), each in their own subdirectories. <p align="center"> <img src="misc/artwork/opendc-component-diagram.png" alt="OpenDC Component Diagram"> diff --git a/web-server/.gitignore b/api/.gitignore index fef0da65..fef0da65 100644 --- a/web-server/.gitignore +++ b/api/.gitignore diff --git a/web-server/.gitlab-ci.yml b/api/.gitlab-ci.yml index d80ba836..d80ba836 100644 --- a/web-server/.gitlab-ci.yml +++ b/api/.gitlab-ci.yml diff --git a/web-server/.pylintrc b/api/.pylintrc index f25e4fc2..f25e4fc2 100644 --- a/web-server/.pylintrc +++ b/api/.pylintrc diff --git a/web-server/.style.yapf b/api/.style.yapf index f5c26c57..f5c26c57 100644 --- a/web-server/.style.yapf +++ b/api/.style.yapf diff --git a/api/Dockerfile b/api/Dockerfile new file mode 100644 index 00000000..49702c90 --- /dev/null +++ b/api/Dockerfile @@ -0,0 +1,17 @@ +FROM python:3.8 +MAINTAINER OpenDC Maintainers <opendc@atlarge-research.com> + +# Ensure the STDOUT is not buffered by Python so that our logs become visible +# See https://stackoverflow.com/q/29663459/10213073 +ENV PYTHONUNBUFFERED 1 + +# Copy OpenDC directory +COPY ./ /opendc + +# Fetch web server dependencies +RUN pip install -r /opendc/requirements.txt + +# Set working directory +WORKDIR /opendc + +CMD ["python3", "main.py"] diff --git a/web-server/README.md b/api/README.md index 84fd09cc..4e8110d0 100644 --- a/web-server/README.md +++ b/api/README.md @@ -66,7 +66,7 @@ Clone OpenDC and follow the [instructions in the main repository](../) to set up **Important:** Be sure to set up environment variables according to those instructions, in a `.env` file. -In `opendc-web-server/static/index.html`, add your own `OAUTH_CLIENT_ID` in `content=` on line `2`. +In `api/static/index.html`, add your own `OAUTH_CLIENT_ID` in `content=` on line `2`. #### Set up the database @@ -84,7 +84,7 @@ This will set you up with a running MongoDB instance and a visual inspection too Run the server. ```bash -cd web-server +cd api python main.py ``` diff --git a/web-server/check.sh b/api/check.sh index abe2c596..abe2c596 100755 --- a/web-server/check.sh +++ b/api/check.sh diff --git a/web-server/conftest.py b/api/conftest.py index 1f4831b8..1f4831b8 100644 --- a/web-server/conftest.py +++ b/api/conftest.py diff --git a/web-server/format.sh b/api/format.sh index 18cba452..18cba452 100755 --- a/web-server/format.sh +++ b/api/format.sh diff --git a/web-server/main.py b/api/main.py index c466c0f2..a2481269 100644..100755 --- a/web-server/main.py +++ b/api/main.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import flask_socketio import json import os diff --git a/web-server/misc/artwork/opendc-web-server-component-diagram.png b/api/misc/artwork/opendc-web-server-component-diagram.png Binary files differindex 91b26006..91b26006 100644 --- a/web-server/misc/artwork/opendc-web-server-component-diagram.png +++ b/api/misc/artwork/opendc-web-server-component-diagram.png diff --git a/web-server/opendc/__init__.py b/api/opendc/__init__.py index e69de29b..e69de29b 100644 --- a/web-server/opendc/__init__.py +++ b/api/opendc/__init__.py diff --git a/web-server/opendc/api/__init__.py b/api/opendc/api/__init__.py index e69de29b..e69de29b 100644 --- a/web-server/opendc/api/__init__.py +++ b/api/opendc/api/__init__.py diff --git a/web-server/opendc/api/v2/__init__.py b/api/opendc/api/v2/__init__.py index e69de29b..e69de29b 100644 --- a/web-server/opendc/api/v2/__init__.py +++ b/api/opendc/api/v2/__init__.py diff --git a/web-server/opendc/api/v2/paths.json b/api/opendc/api/v2/paths.json index 90d5a2e6..90d5a2e6 100644 --- a/web-server/opendc/api/v2/paths.json +++ b/api/opendc/api/v2/paths.json diff --git a/web-server/opendc/api/v2/portfolios/__init__.py b/api/opendc/api/v2/portfolios/__init__.py index e69de29b..e69de29b 100644 --- a/web-server/opendc/api/v2/portfolios/__init__.py +++ b/api/opendc/api/v2/portfolios/__init__.py diff --git a/web-server/opendc/api/v2/portfolios/portfolioId/__init__.py b/api/opendc/api/v2/portfolios/portfolioId/__init__.py index e69de29b..e69de29b 100644 --- a/web-server/opendc/api/v2/portfolios/portfolioId/__init__.py +++ b/api/opendc/api/v2/portfolios/portfolioId/__init__.py diff --git a/web-server/opendc/api/v2/portfolios/portfolioId/endpoint.py b/api/opendc/api/v2/portfolios/portfolioId/endpoint.py index c0ca64e0..c0ca64e0 100644 --- a/web-server/opendc/api/v2/portfolios/portfolioId/endpoint.py +++ b/api/opendc/api/v2/portfolios/portfolioId/endpoint.py diff --git a/web-server/opendc/api/v2/portfolios/portfolioId/scenarios/__init__.py b/api/opendc/api/v2/portfolios/portfolioId/scenarios/__init__.py index e69de29b..e69de29b 100644 --- a/web-server/opendc/api/v2/portfolios/portfolioId/scenarios/__init__.py +++ b/api/opendc/api/v2/portfolios/portfolioId/scenarios/__init__.py diff --git a/web-server/opendc/api/v2/portfolios/portfolioId/scenarios/endpoint.py b/api/opendc/api/v2/portfolios/portfolioId/scenarios/endpoint.py index 1c5e0ab6..1c5e0ab6 100644 --- a/web-server/opendc/api/v2/portfolios/portfolioId/scenarios/endpoint.py +++ b/api/opendc/api/v2/portfolios/portfolioId/scenarios/endpoint.py diff --git a/web-server/opendc/api/v2/portfolios/portfolioId/scenarios/test_endpoint.py b/api/opendc/api/v2/portfolios/portfolioId/scenarios/test_endpoint.py index 8b55bab0..8b55bab0 100644 --- a/web-server/opendc/api/v2/portfolios/portfolioId/scenarios/test_endpoint.py +++ b/api/opendc/api/v2/portfolios/portfolioId/scenarios/test_endpoint.py diff --git a/web-server/opendc/api/v2/portfolios/portfolioId/test_endpoint.py b/api/opendc/api/v2/portfolios/portfolioId/test_endpoint.py index 7ac346d4..7ac346d4 100644 --- a/web-server/opendc/api/v2/portfolios/portfolioId/test_endpoint.py +++ b/api/opendc/api/v2/portfolios/portfolioId/test_endpoint.py diff --git a/web-server/opendc/api/v2/prefabs/__init__.py b/api/opendc/api/v2/prefabs/__init__.py index e69de29b..e69de29b 100644 --- a/web-server/opendc/api/v2/prefabs/__init__.py +++ b/api/opendc/api/v2/prefabs/__init__.py diff --git a/web-server/opendc/api/v2/prefabs/endpoint.py b/api/opendc/api/v2/prefabs/endpoint.py index 723a2f0d..723a2f0d 100644 --- a/web-server/opendc/api/v2/prefabs/endpoint.py +++ b/api/opendc/api/v2/prefabs/endpoint.py diff --git a/web-server/opendc/api/v2/prefabs/prefabId/__init__.py b/api/opendc/api/v2/prefabs/prefabId/__init__.py index e69de29b..e69de29b 100644 --- a/web-server/opendc/api/v2/prefabs/prefabId/__init__.py +++ b/api/opendc/api/v2/prefabs/prefabId/__init__.py diff --git a/web-server/opendc/api/v2/projects/__init__.py b/api/opendc/api/v2/prefabs/prefabId/endpoint.py index e69de29b..e69de29b 100644 --- a/web-server/opendc/api/v2/projects/__init__.py +++ b/api/opendc/api/v2/prefabs/prefabId/endpoint.py diff --git a/web-server/opendc/api/v2/projects/projectId/__init__.py b/api/opendc/api/v2/prefabs/prefabId/test_endpoint.py index e69de29b..e69de29b 100644 --- a/web-server/opendc/api/v2/projects/projectId/__init__.py +++ b/api/opendc/api/v2/prefabs/prefabId/test_endpoint.py diff --git a/web-server/opendc/api/v2/prefabs/test_endpoint.py b/api/opendc/api/v2/prefabs/test_endpoint.py index 47029579..47029579 100644 --- a/web-server/opendc/api/v2/prefabs/test_endpoint.py +++ b/api/opendc/api/v2/prefabs/test_endpoint.py diff --git a/web-server/opendc/api/v2/projects/projectId/authorizations/__init__.py b/api/opendc/api/v2/projects/__init__.py index e69de29b..e69de29b 100644 --- a/web-server/opendc/api/v2/projects/projectId/authorizations/__init__.py +++ b/api/opendc/api/v2/projects/__init__.py diff --git a/web-server/opendc/api/v2/projects/endpoint.py b/api/opendc/api/v2/projects/endpoint.py index bf031382..bf031382 100644 --- a/web-server/opendc/api/v2/projects/endpoint.py +++ b/api/opendc/api/v2/projects/endpoint.py diff --git a/web-server/opendc/api/v2/projects/projectId/portfolios/__init__.py b/api/opendc/api/v2/projects/projectId/__init__.py index e69de29b..e69de29b 100644 --- a/web-server/opendc/api/v2/projects/projectId/portfolios/__init__.py +++ b/api/opendc/api/v2/projects/projectId/__init__.py diff --git a/web-server/opendc/api/v2/projects/projectId/topologies/__init__.py b/api/opendc/api/v2/projects/projectId/authorizations/__init__.py index e69de29b..e69de29b 100644 --- a/web-server/opendc/api/v2/projects/projectId/topologies/__init__.py +++ b/api/opendc/api/v2/projects/projectId/authorizations/__init__.py diff --git a/web-server/opendc/api/v2/projects/projectId/authorizations/endpoint.py b/api/opendc/api/v2/projects/projectId/authorizations/endpoint.py index 9f6a60ec..9f6a60ec 100644 --- a/web-server/opendc/api/v2/projects/projectId/authorizations/endpoint.py +++ b/api/opendc/api/v2/projects/projectId/authorizations/endpoint.py diff --git a/web-server/opendc/api/v2/projects/projectId/authorizations/test_endpoint.py b/api/opendc/api/v2/projects/projectId/authorizations/test_endpoint.py index c3bbc093..c3bbc093 100644 --- a/web-server/opendc/api/v2/projects/projectId/authorizations/test_endpoint.py +++ b/api/opendc/api/v2/projects/projectId/authorizations/test_endpoint.py diff --git a/web-server/opendc/api/v2/projects/projectId/endpoint.py b/api/opendc/api/v2/projects/projectId/endpoint.py index 77b66d75..77b66d75 100644 --- a/web-server/opendc/api/v2/projects/projectId/endpoint.py +++ b/api/opendc/api/v2/projects/projectId/endpoint.py diff --git a/web-server/opendc/api/v2/scenarios/__init__.py b/api/opendc/api/v2/projects/projectId/portfolios/__init__.py index e69de29b..e69de29b 100644 --- a/web-server/opendc/api/v2/scenarios/__init__.py +++ b/api/opendc/api/v2/projects/projectId/portfolios/__init__.py diff --git a/web-server/opendc/api/v2/projects/projectId/portfolios/endpoint.py b/api/opendc/api/v2/projects/projectId/portfolios/endpoint.py index 0bc65565..0bc65565 100644 --- a/web-server/opendc/api/v2/projects/projectId/portfolios/endpoint.py +++ b/api/opendc/api/v2/projects/projectId/portfolios/endpoint.py diff --git a/web-server/opendc/api/v2/projects/projectId/portfolios/test_endpoint.py b/api/opendc/api/v2/projects/projectId/portfolios/test_endpoint.py index 24416cc3..24416cc3 100644 --- a/web-server/opendc/api/v2/projects/projectId/portfolios/test_endpoint.py +++ b/api/opendc/api/v2/projects/projectId/portfolios/test_endpoint.py diff --git a/web-server/opendc/api/v2/projects/projectId/test_endpoint.py b/api/opendc/api/v2/projects/projectId/test_endpoint.py index 7a862e8d..7a862e8d 100644 --- a/web-server/opendc/api/v2/projects/projectId/test_endpoint.py +++ b/api/opendc/api/v2/projects/projectId/test_endpoint.py diff --git a/web-server/opendc/api/v2/scenarios/scenarioId/__init__.py b/api/opendc/api/v2/projects/projectId/topologies/__init__.py index e69de29b..e69de29b 100644 --- a/web-server/opendc/api/v2/scenarios/scenarioId/__init__.py +++ b/api/opendc/api/v2/projects/projectId/topologies/__init__.py diff --git a/web-server/opendc/api/v2/projects/projectId/topologies/endpoint.py b/api/opendc/api/v2/projects/projectId/topologies/endpoint.py index 211dc15d..211dc15d 100644 --- a/web-server/opendc/api/v2/projects/projectId/topologies/endpoint.py +++ b/api/opendc/api/v2/projects/projectId/topologies/endpoint.py diff --git a/web-server/opendc/api/v2/projects/projectId/topologies/test_endpoint.py b/api/opendc/api/v2/projects/projectId/topologies/test_endpoint.py index ca123a73..ca123a73 100644 --- a/web-server/opendc/api/v2/projects/projectId/topologies/test_endpoint.py +++ b/api/opendc/api/v2/projects/projectId/topologies/test_endpoint.py diff --git a/web-server/opendc/api/v2/projects/test_endpoint.py b/api/opendc/api/v2/projects/test_endpoint.py index a50735b0..a50735b0 100644 --- a/web-server/opendc/api/v2/projects/test_endpoint.py +++ b/api/opendc/api/v2/projects/test_endpoint.py diff --git a/web-server/opendc/api/v2/schedulers/__init__.py b/api/opendc/api/v2/scenarios/__init__.py index e69de29b..e69de29b 100644 --- a/web-server/opendc/api/v2/schedulers/__init__.py +++ b/api/opendc/api/v2/scenarios/__init__.py diff --git a/web-server/opendc/api/v2/topologies/__init__.py b/api/opendc/api/v2/scenarios/scenarioId/__init__.py index e69de29b..e69de29b 100644 --- a/web-server/opendc/api/v2/topologies/__init__.py +++ b/api/opendc/api/v2/scenarios/scenarioId/__init__.py diff --git a/web-server/opendc/api/v2/scenarios/scenarioId/endpoint.py b/api/opendc/api/v2/scenarios/scenarioId/endpoint.py index 02d39063..02d39063 100644 --- a/web-server/opendc/api/v2/scenarios/scenarioId/endpoint.py +++ b/api/opendc/api/v2/scenarios/scenarioId/endpoint.py diff --git a/web-server/opendc/api/v2/scenarios/scenarioId/test_endpoint.py b/api/opendc/api/v2/scenarios/scenarioId/test_endpoint.py index 09b7d0c0..09b7d0c0 100644 --- a/web-server/opendc/api/v2/scenarios/scenarioId/test_endpoint.py +++ b/api/opendc/api/v2/scenarios/scenarioId/test_endpoint.py diff --git a/web-server/opendc/api/v2/topologies/topologyId/__init__.py b/api/opendc/api/v2/schedulers/__init__.py index e69de29b..e69de29b 100644 --- a/web-server/opendc/api/v2/topologies/topologyId/__init__.py +++ b/api/opendc/api/v2/schedulers/__init__.py diff --git a/web-server/opendc/api/v2/schedulers/endpoint.py b/api/opendc/api/v2/schedulers/endpoint.py index a96fdd88..a96fdd88 100644 --- a/web-server/opendc/api/v2/schedulers/endpoint.py +++ b/api/opendc/api/v2/schedulers/endpoint.py diff --git a/web-server/opendc/api/v2/schedulers/test_endpoint.py b/api/opendc/api/v2/schedulers/test_endpoint.py index a0bd8758..a0bd8758 100644 --- a/web-server/opendc/api/v2/schedulers/test_endpoint.py +++ b/api/opendc/api/v2/schedulers/test_endpoint.py diff --git a/web-server/opendc/api/v2/traces/__init__.py b/api/opendc/api/v2/topologies/__init__.py index e69de29b..e69de29b 100644 --- a/web-server/opendc/api/v2/traces/__init__.py +++ b/api/opendc/api/v2/topologies/__init__.py diff --git a/web-server/opendc/api/v2/traces/traceId/__init__.py b/api/opendc/api/v2/topologies/topologyId/__init__.py index e69de29b..e69de29b 100644 --- a/web-server/opendc/api/v2/traces/traceId/__init__.py +++ b/api/opendc/api/v2/topologies/topologyId/__init__.py diff --git a/web-server/opendc/api/v2/topologies/topologyId/endpoint.py b/api/opendc/api/v2/topologies/topologyId/endpoint.py index 512b050a..512b050a 100644 --- a/web-server/opendc/api/v2/topologies/topologyId/endpoint.py +++ b/api/opendc/api/v2/topologies/topologyId/endpoint.py diff --git a/web-server/opendc/api/v2/topologies/topologyId/test_endpoint.py b/api/opendc/api/v2/topologies/topologyId/test_endpoint.py index b25cb798..b25cb798 100644 --- a/web-server/opendc/api/v2/topologies/topologyId/test_endpoint.py +++ b/api/opendc/api/v2/topologies/topologyId/test_endpoint.py diff --git a/web-server/opendc/api/v2/users/__init__.py b/api/opendc/api/v2/traces/__init__.py index e69de29b..e69de29b 100644 --- a/web-server/opendc/api/v2/users/__init__.py +++ b/api/opendc/api/v2/traces/__init__.py diff --git a/web-server/opendc/api/v2/traces/endpoint.py b/api/opendc/api/v2/traces/endpoint.py index ee699e02..ee699e02 100644 --- a/web-server/opendc/api/v2/traces/endpoint.py +++ b/api/opendc/api/v2/traces/endpoint.py diff --git a/web-server/opendc/api/v2/traces/test_endpoint.py b/api/opendc/api/v2/traces/test_endpoint.py index 9f806085..9f806085 100644 --- a/web-server/opendc/api/v2/traces/test_endpoint.py +++ b/api/opendc/api/v2/traces/test_endpoint.py diff --git a/web-server/opendc/api/v2/users/userId/__init__.py b/api/opendc/api/v2/traces/traceId/__init__.py index e69de29b..e69de29b 100644 --- a/web-server/opendc/api/v2/users/userId/__init__.py +++ b/api/opendc/api/v2/traces/traceId/__init__.py diff --git a/web-server/opendc/api/v2/traces/traceId/endpoint.py b/api/opendc/api/v2/traces/traceId/endpoint.py index 670f88d1..670f88d1 100644 --- a/web-server/opendc/api/v2/traces/traceId/endpoint.py +++ b/api/opendc/api/v2/traces/traceId/endpoint.py diff --git a/web-server/opendc/api/v2/traces/traceId/test_endpoint.py b/api/opendc/api/v2/traces/traceId/test_endpoint.py index 56792ca9..56792ca9 100644 --- a/web-server/opendc/api/v2/traces/traceId/test_endpoint.py +++ b/api/opendc/api/v2/traces/traceId/test_endpoint.py diff --git a/web-server/opendc/models/__init__.py b/api/opendc/api/v2/users/__init__.py index e69de29b..e69de29b 100644 --- a/web-server/opendc/models/__init__.py +++ b/api/opendc/api/v2/users/__init__.py diff --git a/web-server/opendc/api/v2/users/endpoint.py b/api/opendc/api/v2/users/endpoint.py index 0dcf2463..0dcf2463 100644 --- a/web-server/opendc/api/v2/users/endpoint.py +++ b/api/opendc/api/v2/users/endpoint.py diff --git a/web-server/opendc/api/v2/users/test_endpoint.py b/api/opendc/api/v2/users/test_endpoint.py index d60429b3..d60429b3 100644 --- a/web-server/opendc/api/v2/users/test_endpoint.py +++ b/api/opendc/api/v2/users/test_endpoint.py diff --git a/web-server/opendc/util/__init__.py b/api/opendc/api/v2/users/userId/__init__.py index e69de29b..e69de29b 100644 --- a/web-server/opendc/util/__init__.py +++ b/api/opendc/api/v2/users/userId/__init__.py diff --git a/web-server/opendc/api/v2/users/userId/endpoint.py b/api/opendc/api/v2/users/userId/endpoint.py index be3462c0..be3462c0 100644 --- a/web-server/opendc/api/v2/users/userId/endpoint.py +++ b/api/opendc/api/v2/users/userId/endpoint.py diff --git a/web-server/opendc/api/v2/users/userId/test_endpoint.py b/api/opendc/api/v2/users/userId/test_endpoint.py index cdff2229..cdff2229 100644 --- a/web-server/opendc/api/v2/users/userId/test_endpoint.py +++ b/api/opendc/api/v2/users/userId/test_endpoint.py diff --git a/api/opendc/models/__init__.py b/api/opendc/models/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/api/opendc/models/__init__.py diff --git a/web-server/opendc/models/model.py b/api/opendc/models/model.py index bcb833ae..bcb833ae 100644 --- a/web-server/opendc/models/model.py +++ b/api/opendc/models/model.py diff --git a/web-server/opendc/models/portfolio.py b/api/opendc/models/portfolio.py index 32961b63..32961b63 100644 --- a/web-server/opendc/models/portfolio.py +++ b/api/opendc/models/portfolio.py diff --git a/web-server/opendc/models/prefab.py b/api/opendc/models/prefab.py index 70910c4a..70910c4a 100644 --- a/web-server/opendc/models/prefab.py +++ b/api/opendc/models/prefab.py diff --git a/web-server/opendc/models/project.py b/api/opendc/models/project.py index b57e9f77..b57e9f77 100644 --- a/web-server/opendc/models/project.py +++ b/api/opendc/models/project.py diff --git a/web-server/opendc/models/scenario.py b/api/opendc/models/scenario.py index 8d53e408..8d53e408 100644 --- a/web-server/opendc/models/scenario.py +++ b/api/opendc/models/scenario.py diff --git a/web-server/opendc/models/topology.py b/api/opendc/models/topology.py index cb4c4bab..cb4c4bab 100644 --- a/web-server/opendc/models/topology.py +++ b/api/opendc/models/topology.py diff --git a/web-server/opendc/models/trace.py b/api/opendc/models/trace.py index 2f6e4926..2f6e4926 100644 --- a/web-server/opendc/models/trace.py +++ b/api/opendc/models/trace.py diff --git a/web-server/opendc/models/user.py b/api/opendc/models/user.py index 8e8ff945..8e8ff945 100644 --- a/web-server/opendc/models/user.py +++ b/api/opendc/models/user.py diff --git a/api/opendc/util/__init__.py b/api/opendc/util/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/api/opendc/util/__init__.py diff --git a/web-server/opendc/util/database.py b/api/opendc/util/database.py index 80cdcbab..80cdcbab 100644 --- a/web-server/opendc/util/database.py +++ b/api/opendc/util/database.py diff --git a/web-server/opendc/util/exceptions.py b/api/opendc/util/exceptions.py index 7724a407..7724a407 100644 --- a/web-server/opendc/util/exceptions.py +++ b/api/opendc/util/exceptions.py diff --git a/web-server/opendc/util/parameter_checker.py b/api/opendc/util/parameter_checker.py index 14dd1dc0..14dd1dc0 100644 --- a/web-server/opendc/util/parameter_checker.py +++ b/api/opendc/util/parameter_checker.py diff --git a/web-server/opendc/util/path_parser.py b/api/opendc/util/path_parser.py index a8bbdeba..a8bbdeba 100644 --- a/web-server/opendc/util/path_parser.py +++ b/api/opendc/util/path_parser.py diff --git a/web-server/opendc/util/rest.py b/api/opendc/util/rest.py index abd2f3de..abd2f3de 100644 --- a/web-server/opendc/util/rest.py +++ b/api/opendc/util/rest.py diff --git a/web-server/pytest.ini b/api/pytest.ini index 775a8ff4..775a8ff4 100644 --- a/web-server/pytest.ini +++ b/api/pytest.ini diff --git a/web-server/requirements.txt b/api/requirements.txt index 140a046f..140a046f 100644 --- a/web-server/requirements.txt +++ b/api/requirements.txt diff --git a/web-server/static/index.html b/api/static/index.html index ac78cbfb..ac78cbfb 100644 --- a/web-server/static/index.html +++ b/api/static/index.html diff --git a/docker-compose.yml b/docker-compose.yml index b2072be9..6dc01f67 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,8 @@ version: "3" services: - frontend: - build: ./ - image: frontend + api: + build: ./api + image: api restart: on-failure ports: - "8081:8081" diff --git a/web-server/opendc/api/v2/prefabs/prefabId/endpoint.py b/web-server/opendc/api/v2/prefabs/prefabId/endpoint.py deleted file mode 100644 index e8508ee0..00000000 --- a/web-server/opendc/api/v2/prefabs/prefabId/endpoint.py +++ /dev/null @@ -1,53 +0,0 @@ -from datetime import datetime - -from opendc.models.prefab import Prefab -from opendc.util.database import Database -from opendc.util.rest import Response - - -def GET(request): - """Get this Prefab.""" - - request.check_required_parameters(path={'prefabId': 'string'}) - - prefab = Prefab.from_id(request.params_path['prefabId']) - print(prefab.obj) - prefab.check_exists() - print("before cua") - prefab.check_user_access(request.google_id) - print("after cua") - - return Response(200, 'Successfully retrieved prefab', prefab.obj) - - -def PUT(request): - """Update a prefab's name and/or contents.""" - - request.check_required_parameters(body={'prefab': {'name': 'name'}}, path={'prefabId': 'string'}) - - prefab = Prefab.from_id(request.params_path['prefabId']) - - prefab.check_exists() - prefab.check_user_access(request.google_id) - - prefab.set_property('name', request.params_body['prefab']['name']) - prefab.set_property('rack', request.params_body['prefab']['rack']) - prefab.set_property('datetime_last_edited', Database.datetime_to_string(datetime.now())) - prefab.update() - - return Response(200, 'Successfully updated prefab.', prefab.obj) - - -def DELETE(request): - """Delete this Prefab.""" - - request.check_required_parameters(path={'prefabId': 'string'}) - - prefab = Prefab.from_id(request.params_path['prefabId']) - - prefab.check_exists() - prefab.check_user_access(request.google_id) - - old_object = prefab.delete() - - return Response(200, 'Successfully deleted prefab.', old_object) diff --git a/web-server/opendc/api/v2/prefabs/prefabId/test_endpoint.py b/web-server/opendc/api/v2/prefabs/prefabId/test_endpoint.py deleted file mode 100644 index b25c881d..00000000 --- a/web-server/opendc/api/v2/prefabs/prefabId/test_endpoint.py +++ /dev/null @@ -1,140 +0,0 @@ -from opendc.util.database import DB -from unittest.mock import Mock - - -def test_get_prefab_non_existing(client, mocker): - mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.get('/api/v2/prefabs/1').status - -def test_get_private_prefab_not_authorized(client, mocker): - DB.fetch_one = Mock() - DB.fetch_one.side_effect = [{ - '_id': '1', - 'name': 'test prefab', - 'authorId': '2', - 'visibility': 'private', - 'rack': {} - }, - { - '_id': '1' - } - ] - res = client.get('/api/v2/prefabs/1') - assert '403' in res.status - - -def test_get_private_prefab(client, mocker): - DB.fetch_one = Mock() - DB.fetch_one.side_effect = [{ - '_id': '1', - 'name': 'test prefab', - 'authorId': '1', - 'visibility': 'private', - 'rack': {} - }, - { - '_id': '1' - } - ] - res = client.get('/api/v2/prefabs/1') - assert '200' in res.status - -def test_get_public_prefab(client, mocker): - DB.fetch_one = Mock() - DB.fetch_one.side_effect = [{ - '_id': '1', - 'name': 'test prefab', - 'authorId': '2', - 'visibility': 'public', - 'rack': {} - }, - { - '_id': '1' - } - ] - res = client.get('/api/v2/prefabs/1') - assert '200' in res.status - - -def test_update_prefab_missing_parameter(client): - assert '400' in client.put('/api/v2/prefabs/1').status - - -def test_update_prefab_non_existing(client, mocker): - mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.put('/api/v2/prefabs/1', json={'prefab': {'name': 'S'}}).status - - -def test_update_prefab_not_authorized(client, mocker): - DB.fetch_one = Mock() - DB.fetch_one.side_effect = [{ - '_id': '1', - 'name': 'test prefab', - 'authorId': '2', - 'visibility': 'private', - 'rack': {} - }, - { - '_id': '1' - } - ] - mocker.patch.object(DB, 'update', return_value={}) - assert '403' in client.put('/api/v2/prefabs/1', json={'prefab': {'name': 'test prefab', 'rack' : {}}}).status - - -def test_update_prefab(client, mocker): - DB.fetch_one = Mock() - DB.fetch_one.side_effect = [{ - '_id': '1', - 'name': 'test prefab', - 'authorId': '1', - 'visibility': 'private', - 'rack': {} - }, - { - '_id': '1' - } - ] - mocker.patch.object(DB, 'update', return_value={}) - res = client.put('/api/v2/prefabs/1', json={'prefab': {'name': 'test prefab', 'rack' : {}}}) - assert '200' in res.status - - -def test_delete_prefab_non_existing(client, mocker): - mocker.patch.object(DB, 'fetch_one', return_value=None) - assert '404' in client.delete('/api/v2/prefabs/1').status - - -def test_delete_prefab_different_user(client, mocker): - DB.fetch_one = Mock() - DB.fetch_one.side_effect = [{ - '_id': '1', - 'name': 'test prefab', - 'authorId': '2', - 'visibility': 'private', - 'rack': {} - }, - { - '_id': '1' - } - ] - mocker.patch.object(DB, 'delete_one', return_value=None) - assert '403' in client.delete('/api/v2/prefabs/1').status - - -def test_delete_prefab(client, mocker): - DB.fetch_one = Mock() - DB.fetch_one.side_effect = [{ - '_id': '1', - 'name': 'test prefab', - 'authorId': '1', - 'visibility': 'private', - 'rack': {} - }, - { - '_id': '1' - } - ] - mocker.patch.object(DB, 'delete_one', return_value={'prefab': {'name': 'name'}}) - res = client.delete('/api/v2/prefabs/1') - assert '200' in res.status |
