diff options
author | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2023-03-13 11:00:21 +0000 |
---|---|---|
committer | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2023-03-14 14:25:16 +0000 |
commit | 870ff702088b89549bc21631eb48443fff0bcd71 (patch) | |
tree | 5d52aca25035644bdc2ac687275ed858ba524e7e /mock-cds | |
parent | 98e0e65ba145ab4c85c301118d4a0d02940221ec (diff) |
Migrate mock applications from Orange GitLab
Move from Orange repositories into ONAP one.
Issue-ID: INT-2208
Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl>
Change-Id: I6e165da5144c28a6ff151e02e32f5ae89ce124e3
Diffstat (limited to 'mock-cds')
-rw-r--r-- | mock-cds/Dockerfile | 17 | ||||
-rw-r--r-- | mock-cds/Pipfile | 12 | ||||
-rw-r--r-- | mock-cds/Pipfile.lock | 125 | ||||
-rw-r--r-- | mock-cds/README.md | 2 | ||||
-rw-r--r-- | mock-cds/app/app.py | 22 | ||||
-rw-r--r-- | mock-cds/app/routes.py | 22 | ||||
-rw-r--r-- | mock-cds/app/views.py | 51 | ||||
-rw-r--r-- | mock-cds/cleanup-dev.sh | 6 | ||||
-rw-r--r-- | mock-cds/run-dev.sh | 8 |
9 files changed, 265 insertions, 0 deletions
diff --git a/mock-cds/Dockerfile b/mock-cds/Dockerfile new file mode 100644 index 0000000..4a396bb --- /dev/null +++ b/mock-cds/Dockerfile @@ -0,0 +1,17 @@ +FROM python:3.7.8-alpine + +COPY . /app +WORKDIR /app + +# GCC for Alpine Linux in Docker +RUN apk add build-base + + +# Dependencies +RUN pip install pipenv && \ + pipenv requirements > requirements.txt && \ + pip install -r requirements.txt + + +ENTRYPOINT ["python"] +CMD ["app/app.py"]
\ No newline at end of file diff --git a/mock-cds/Pipfile b/mock-cds/Pipfile new file mode 100644 index 0000000..857def1 --- /dev/null +++ b/mock-cds/Pipfile @@ -0,0 +1,12 @@ +[[source]] +name = "pypi" +url = "https://pypi.org/simple" +verify_ssl = true + +[dev-packages] + +[packages] +aiohttp = "*" + +[requires] +python_version = "3.7" diff --git a/mock-cds/Pipfile.lock b/mock-cds/Pipfile.lock new file mode 100644 index 0000000..9ac068c --- /dev/null +++ b/mock-cds/Pipfile.lock @@ -0,0 +1,125 @@ +{ + "_meta": { + "hash": { + "sha256": "2c5c75ab0fc628a232239706591e922fec111ed0bb34cc8c62d3352e2d21a02d" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.7" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "aiohttp": { + "hashes": [ + "sha256:1e984191d1ec186881ffaed4581092ba04f7c61582a177b187d3a2f07ed9719e", + "sha256:259ab809ff0727d0e834ac5e8a283dc5e3e0ecc30c4d80b3cd17a4139ce1f326", + "sha256:2f4d1a4fdce595c947162333353d4a44952a724fba9ca3205a3df99a33d1307a", + "sha256:32e5f3b7e511aa850829fbe5aa32eb455e5534eaa4b1ce93231d00e2f76e5654", + "sha256:344c780466b73095a72c616fac5ea9c4665add7fc129f285fbdbca3cccf4612a", + "sha256:460bd4237d2dbecc3b5ed57e122992f60188afe46e7319116da5eb8a9dfedba4", + "sha256:4c6efd824d44ae697814a2a85604d8e992b875462c6655da161ff18fd4f29f17", + "sha256:50aaad128e6ac62e7bf7bd1f0c0a24bc968a0c0590a726d5a955af193544bcec", + "sha256:6206a135d072f88da3e71cc501c59d5abffa9d0bb43269a6dcd28d66bfafdbdd", + "sha256:65f31b622af739a802ca6fd1a3076fd0ae523f8485c52924a89561ba10c49b48", + "sha256:ae55bac364c405caa23a4f2d6cfecc6a0daada500274ffca4a9230e7129eac59", + "sha256:b778ce0c909a2653741cb4b1ac7015b5c130ab9c897611df43ae6a58523cb965" + ], + "index": "pypi", + "version": "==3.6.2" + }, + "async-timeout": { + "hashes": [ + "sha256:0c3c816a028d47f659d6ff5c745cb2acf1f966da1fe5c19c77a70282b25f4c5f", + "sha256:4291ca197d287d274d0b6cb5d6f8f8f82d434ed288f962539ff18cc9012f9ea3" + ], + "markers": "python_full_version >= '3.5.3'", + "version": "==3.0.1" + }, + "attrs": { + "hashes": [ + "sha256:08a96c641c3a74e44eb59afb61a24f2cb9f4d7188748e76ba4bb5edfa3cb7d1c", + "sha256:f7b7ce16570fe9965acd6d30101a28f62fb4a7f9e926b3bbc9b61f8b04247e72" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==19.3.0" + }, + "chardet": { + "hashes": [ + "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", + "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" + ], + "version": "==3.0.4" + }, + "idna": { + "hashes": [ + "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6", + "sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==2.10" + }, + "multidict": { + "hashes": [ + "sha256:1ece5a3369835c20ed57adadc663400b5525904e53bae59ec854a5d36b39b21a", + "sha256:275ca32383bc5d1894b6975bb4ca6a7ff16ab76fa622967625baeebcf8079000", + "sha256:3750f2205b800aac4bb03b5ae48025a64e474d2c6cc79547988ba1d4122a09e2", + "sha256:4538273208e7294b2659b1602490f4ed3ab1c8cf9dbdd817e0e9db8e64be2507", + "sha256:5141c13374e6b25fe6bf092052ab55c0c03d21bd66c94a0e3ae371d3e4d865a5", + "sha256:51a4d210404ac61d32dada00a50ea7ba412e6ea945bbe992e4d7a595276d2ec7", + "sha256:5cf311a0f5ef80fe73e4f4c0f0998ec08f954a6ec72b746f3c179e37de1d210d", + "sha256:6513728873f4326999429a8b00fc7ceddb2509b01d5fd3f3be7881a257b8d463", + "sha256:7388d2ef3c55a8ba80da62ecfafa06a1c097c18032a501ffd4cabbc52d7f2b19", + "sha256:9456e90649005ad40558f4cf51dbb842e32807df75146c6d940b6f5abb4a78f3", + "sha256:c026fe9a05130e44157b98fea3ab12969e5b60691a276150db9eda71710cd10b", + "sha256:d14842362ed4cf63751648e7672f7174c9818459d169231d03c56e84daf90b7c", + "sha256:e0d072ae0f2a179c375f67e3da300b47e1a83293c554450b29c900e50afaae87", + "sha256:f07acae137b71af3bb548bd8da720956a3bc9f9a0b87733e0899226a2317aeb7", + "sha256:fbb77a75e529021e7c4a8d4e823d88ef4d23674a202be4f5addffc72cbb91430", + "sha256:fcfbb44c59af3f8ea984de67ec7c306f618a3ec771c2843804069917a8f2e255", + "sha256:feed85993dbdb1dbc29102f50bca65bdc68f2c0c8d352468c25b54874f23c39d" + ], + "markers": "python_version >= '3.5'", + "version": "==4.7.6" + }, + "typing-extensions": { + "hashes": [ + "sha256:6e95524d8a547a91e08f404ae485bbb71962de46967e1b71a0cb89af24e761c5", + "sha256:79ee589a3caca649a9bfd2a8de4709837400dfa00b6cc81962a1e6a1815969ae", + "sha256:f8d2bd89d25bc39dabe7d23df520442fa1d8969b82544370e03d88b5a591c392" + ], + "markers": "python_version < '3.8'", + "version": "==3.7.4.2" + }, + "yarl": { + "hashes": [ + "sha256:040b237f58ff7d800e6e0fd89c8439b841f777dd99b4a9cca04d6935564b9409", + "sha256:17668ec6722b1b7a3a05cc0167659f6c95b436d25a36c2d52db0eca7d3f72593", + "sha256:3a584b28086bc93c888a6c2aa5c92ed1ae20932f078c46509a66dce9ea5533f2", + "sha256:4439be27e4eee76c7632c2427ca5e73703151b22cae23e64adb243a9c2f565d8", + "sha256:48e918b05850fffb070a496d2b5f97fc31d15d94ca33d3d08a4f86e26d4e7c5d", + "sha256:9102b59e8337f9874638fcfc9ac3734a0cfadb100e47d55c20d0dc6087fb4692", + "sha256:9b930776c0ae0c691776f4d2891ebc5362af86f152dd0da463a6614074cb1b02", + "sha256:b3b9ad80f8b68519cc3372a6ca85ae02cc5a8807723ac366b53c0f089db19e4a", + "sha256:bc2f976c0e918659f723401c4f834deb8a8e7798a71be4382e024bcc3f7e23a8", + "sha256:c22c75b5f394f3d47105045ea551e08a3e804dc7e01b37800ca35b58f856c3d6", + "sha256:c52ce2883dc193824989a9b97a76ca86ecd1fa7955b14f87bf367a61b6232511", + "sha256:ce584af5de8830d8701b8979b18fcf450cef9a382b1a3c8ef189bedc408faf1e", + "sha256:da456eeec17fa8aa4594d9a9f27c0b1060b6a75f2419fe0c00609587b2695f4a", + "sha256:db6db0f45d2c63ddb1a9d18d1b9b22f308e52c83638c26b422d520a815c4b3fb", + "sha256:df89642981b94e7db5596818499c4b2219028f2a528c9c37cc1de45bf2fd3a3f", + "sha256:f18d68f2be6bf0e89f1521af2b1bb46e66ab0018faafa81d70f358153170a317", + "sha256:f379b7f83f23fe12823085cd6b906edc49df969eb99757f58ff382349a3303c6" + ], + "markers": "python_version >= '3.5'", + "version": "==1.5.1" + } + }, + "develop": {} +} diff --git a/mock-cds/README.md b/mock-cds/README.md new file mode 100644 index 0000000..d74d171 --- /dev/null +++ b/mock-cds/README.md @@ -0,0 +1,2 @@ +# mock-cds + diff --git a/mock-cds/app/app.py b/mock-cds/app/app.py new file mode 100644 index 0000000..a15dbea --- /dev/null +++ b/mock-cds/app/app.py @@ -0,0 +1,22 @@ +""" + Copyright 2023 Deutsche Telekom AG, Orange + + 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. +""" +from aiohttp import web +from routes import setup_routes + +app = web.Application() + +setup_routes(app) +web.run_app(app)
\ No newline at end of file diff --git a/mock-cds/app/routes.py b/mock-cds/app/routes.py new file mode 100644 index 0000000..10da668 --- /dev/null +++ b/mock-cds/app/routes.py @@ -0,0 +1,22 @@ +""" + Copyright 2023 Deutsche Telekom AG, Orange + + 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. +""" +from views import blueprint_enrich, blueprint_publish, dictionary, dictionary_get + +def setup_routes(app): + app.router.add_post('/api/v1/blueprint-model/enrich', blueprint_enrich) + app.router.add_post('/api/v1/blueprint-model/publish', blueprint_publish) + app.router.add_post('/api/v1/dictionary', dictionary) + app.router.add_get('/api/v1/dictionary/{name}', dictionary_get)
\ No newline at end of file diff --git a/mock-cds/app/views.py b/mock-cds/app/views.py new file mode 100644 index 0000000..b6d9f37 --- /dev/null +++ b/mock-cds/app/views.py @@ -0,0 +1,51 @@ +""" + Copyright 2023 Deutsche Telekom AG, Orange + + 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 json + +from aiohttp import web + +BYTES = b'Response in bytes' +DICTIONARY = { + "message": "Response in JSON", + "success": True + } +DICTIONARIES = {} + +async def blueprint_enrich(request): + """ Blueprint enrichment """ + return web.Response(body=BYTES, status=200) + +async def blueprint_publish(request): + """ Blueprint publishing """ + return web.Response(body=BYTES, status=200) + +async def dictionary(request): + """ Data dictionary """ + try: + body = await request.json() + DICTIONARIES[body["name"]] = body + except ValueError: + print("No JSON sent! Leave it because we used that endpoint during " + "the availability and we won't break the integration tests") + return web.json_response(data=DICTIONARY, status=200) + +async def dictionary_get(request): + """ Data dictionary get """ + name = request.match_info["name"] + try: + return web.json_response(data=DICTIONARIES[name], status=200) + except KeyError: + return web.Response(status=404)
\ No newline at end of file diff --git a/mock-cds/cleanup-dev.sh b/mock-cds/cleanup-dev.sh new file mode 100644 index 0000000..fb4a1bc --- /dev/null +++ b/mock-cds/cleanup-dev.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +export APP_NAME=mock-cds-app + +docker rm $(docker stop $(docker ps -a -q --filter ancestor="${APP_NAME}" --format="{{.ID}}")) +docker rmi ${APP_NAME}
\ No newline at end of file diff --git a/mock-cds/run-dev.sh b/mock-cds/run-dev.sh new file mode 100644 index 0000000..392bfaa --- /dev/null +++ b/mock-cds/run-dev.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +export APP_NAME=mock-cds-app +export DOCKER_PORT=8080 +export APP_PORT=8080 + +docker build -t $APP_NAME . +docker run -d -p $DOCKER_PORT:$APP_PORT $APP_NAME
\ No newline at end of file |