diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..81cc57d423358df3ba87df1762087654e43d293a --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,173 @@ +default: + image: debian-bookworm:latest + tags: + - netvs +cache: + key: + files: + - package-lock.json + paths: + - .npm_ci/ +before_script: + ## dependencies + - apt-get update -y + - command -v curl || apt-get -y install curl + - command -v git || apt-get -y install git + - apt-get -y install apt-transport-https gnupg2 + - test -e /etc/apt/sources.list.d/nodesource.list || curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - + - test -e /etc/apt/sources.list.d/nodesource.list || echo 'deb https://deb.nodesource.com/node_16.x bookworm main' > /etc/apt/sources.list.d/nodesource.list + - "echo -e 'Package: *\nPin: origin deb.nodesource.com\nPin-Priority: 900' > /etc/apt/preferences.d/nodesource_pin" + - if [ $CI_JOB_STAGE != "deploy" ]; then command -v npm || (apt-get update -y && apt-get install -y nodejs); fi + - if [ $CI_JOB_STAGE != "deploy" ]; then command -v pip3 || (apt-get update -y && apt-get install -y python3-pip); fi + - if [ $CI_JOB_STAGE != "deploy" ]; then (apt-get update -y && apt-get install -y python3-venv && python3 -m venv /venv && source /venv/bin/activate); fi + - if [[ $CI_JOB_STAGE != "deploy" ]]; then if [[ $CI_COMMIT_BRANCH == "devel" ]]; then /venv/bin/pip3 install git+https://gitlab.kit.edu/scc-net/netvs/api-generator.git@devel#egg=net-api-generator; else /venv/bin/pip3 install git+https://gitlab.kit.edu/scc-net/netvs/api-generator.git@main#egg=net-api-generator; fi; fi + - echo "${CI_COMMIT_SHORT_SHA},Job ID ${CI_JOB_ID}@${CI_RUNNER_DESCRIPTION}" + - sed "s&__LOCAL_BUILD__&${CI_COMMIT_SHORT_SHA},Job ID ${CI_JOB_ID}@${CI_RUNNER_DESCRIPTION}&g" netvs.config.js.example > netvs.config.js + - sed -i "s&__JOB_ID__&${CI_JOB_ID}&g" netvs.config.js + - sed -i "s&__COMMIT_SHORT_SHA__&${CI_COMMIT_SHORT_SHA}&g" netvs.config.js + - sed -i "s&__JOB_ID__&${CI_JOB_ID}&g" public/version.json + - sed -i "s&__COMMIT_SHORT_SHA__&${CI_COMMIT_SHORT_SHA}&g" public/version.json + - if [[ $CI_JOB_STAGE != "deploy" ]]; then npm ci --cache .npm_ci --prefer-offline; fi + - export NETDB_VERSION="4.1" +stages: + - build + - lint + - deploy + - e2e + +frontend-build: + stage: build + script: + - python3 build_swagger.py + - /venv/bin/net-api-generator es-webpack + - npm run build + artifacts: + expire_in: 7 days + paths: + - dist/ + - src/api-services.gen/ + needs: [] + interruptible: true +frontend-lint: + stage: lint + script: + - npm run lint-ci + allow_failure: false + needs: [] + interruptible: true + +frontend-audit: + stage: lint + script: + - npm audit --audit-level high + allow_failure: true + needs: [] + interruptible: true + +deploy_lab: + stage: deploy + script: + - 'command -v ssh-agent || ( apt-get install openssh-client -y )' + - eval $(ssh-agent -s) + - echo "${SSH_PRIVATE_KEY}" | base64 -d | tr -d '\r' | ssh-add - + - mkdir -p ~/.ssh + - chmod 700 ~/.ssh + - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts + - chmod 644 ~/.ssh/known_hosts + - ssh www-netvs@netvs-lab.scc.kit.edu "${CI_PIPELINE_ID}" + environment: + name: lab + url: https://netvs-lab.scc.kit.edu + only: + - lab + needs: ["frontend-build"] + +deploy_devel: + stage: deploy + script: + - 'command -v ssh-agent || ( apt-get install openssh-client -y )' + - eval $(ssh-agent -s) + - echo "${SSH_PRIVATE_KEY}" | base64 -d | tr -d '\r' | ssh-add - + - mkdir -p ~/.ssh + - chmod 700 ~/.ssh + - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts + - chmod 644 ~/.ssh/known_hosts + - ssh www-netvs@netvs-devel.scc.kit.edu "${CI_PIPELINE_ID}" + environment: + name: devel + url: https://netvs-devel.scc.kit.edu + only: + - devel + needs: ["frontend-build"] + interruptible: false +Odeploy_test: + stage: deploy + script: + - 'command -v ssh-agent || ( apt-get install openssh-client -y )' + - eval $(ssh-agent -s) + - echo "$SSH_PRIVATE_KEY" | base64 -d | tr -d '\r' | ssh-add - + - mkdir -p ~/.ssh + - chmod 700 ~/.ssh + - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts + - chmod 644 ~/.ssh/known_hosts + - ssh www-netvs@netvs-test.scc.kit.edu "${CI_PIPELINE_ID}" + environment: + name: test + url: https://netvs-test.scc.kit.edu + only: + - prod + needs: ["frontend-build"] + interruptible: false + +deploy_prod: + stage: deploy + script: + - 'command -v ssh-agent || ( apt-get install openssh-client -y )' + - eval $(ssh-agent -s) + - echo "$SSH_PRIVATE_KEY" | base64 -d | tr -d '\r' | ssh-add - + - mkdir -p ~/.ssh + - chmod 700 ~/.ssh + - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts + - chmod 644 ~/.ssh/known_hosts + - ssh www-netvs@netvs.scc.kit.edu "${CI_PIPELINE_ID}" + environment: + name: prod + url: https://netvs.scc.kit.edu + only: + - prod + needs: ["frontend-build"] + interruptible: false + +e2e_chrome: + stage: e2e + script: + - curl -s https://dl.google.com/linux/linux_signing_key.pub | apt-key add - + - echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/chrome.list + - apt-get -y update && apt-get -y install google-chrome-stable + - npm run serve 2> /dev/null & + - sleep 45 && npx nightwatch --env chrome tests/specs + needs: ["frontend-build"] + allow_failure: true + artifacts: + when: always + paths: + - tests_output/ + - screens/ + reports: + junit: tests_output/**/*.xml + interruptible: true +#e2e_firefox: +# stage: e2e +# script: +# - apt-get -y update && apt-get -y install firefox-esr +# - cd frontend/ +# - npm run serve 2> /dev/null & +# - sleep 45 && npx nightwatch --env firefox tests/specs +# needs: ["frontend-build"] +# artifacts: +# when: always +# paths: +# - frontend/tests_output/ +# - frontend/screens/ +# reports: +# junit: frontend/tests_output/**/*.xml diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md new file mode 100644 index 0000000000000000000000000000000000000000..9314bb4233b0616214589537215938d5f55f85bf --- /dev/null +++ b/DEPLOYMENT.md @@ -0,0 +1,36 @@ +# NETVS Deployment + +Instances: +- [Prod](https://netvs.scc.kit.edu) +- [Test](https://netvs-test.scc.kit.edu) +- [Devel](https://netvs-devel.scc.kit.edu) +- [Devel-Oldrelease](https://netvs-devel-oldrelease.scc.kit.edu) +- [Lab](https://netvs-lab.scc.kit.edu) + +```mermaid +flowchart LR + NETDB_PROD[(Prod)] + NETDB_TEST[(Test)] + NETDB_DEVEL[(Devel)] + Oldrel_inst[Oldrelease] + Test_inst[fa:fa-vial Test] + Lab_inst[fa:fa-vials Lab] + Prod_inst[Prod] + Devel_inst[fa:fa-dumpster-fire Devel] + Devel{{`devel`}} + Lab{{`lab`}} + Main{{`main`}} + + Devel-->D{Feature working\n&&\nNETVS Target API\nsupported by\nNETDB Prod} + Devel <--> Lab + D -->|Yes| Main + D -->|No| Devel + + Lab -.->|deploys to| Lab_inst + Devel -.->|deploys to| Devel_inst + Main -.->|deploys to| Prod_inst & Oldrel_inst & Test_inst + + Lab_inst & Devel_inst & Oldrel_inst -.->|uses| NETDB_DEVEL + Prod_inst -.->|uses| NETDB_PROD + Test_inst -.->|uses| NETDB_TEST +``` diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..18b74de1a6de24f0dbf63d6d3576ee8f7831a9ea --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 KIT | Scientific Computing Center - Abteilung Netze + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/build_swagger.py b/build_swagger.py new file mode 100644 index 0000000000000000000000000000000000000000..d60780a198907ab462d7417cdd0e7aec74f9110f --- /dev/null +++ b/build_swagger.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +from typing import Optional + +import requests +import os, subprocess, sys + +default_endpoint = os.environ.get('CI_COMMIT_BRANCH', 'test') +api_generator = os.environ.get('API_GENERATOR', '/venv/bin/net-api-generator') + +if default_endpoint == 'devel': + api_endpoint = os.environ.get('NETDB_DEVEL_ENDPOINT') +else: + api_endpoint = os.environ.get('NETDB_ENDPOINT') + +endpoint_protocol = os.environ.get('NETDB_ENDPOINT_PROTOCOL', 'https') + +os.environ['NETDB_ENDPOINT'] = api_endpoint + +data = requests.get('{}://{}'.format(endpoint_protocol, api_endpoint)).json()[0] + +highest_api_version = None + + +def exec_command_into_file(command: list[str], file: Optional[str], env: dict[str, str | None]): + p = subprocess.Popen(command, env=env, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout, err = p.communicate() + p.wait() + if file is not None: + with open(file, 'w') as f: + f.write(stdout.decode('utf-8')) + if len(err.decode('utf-8')) > 0: + print(err.decode('utf-8'), file=sys.stderr) + sys.exit(1) + + +for api_version in data: + version_string = "{}.{}".format(api_version['major'], api_version['minor']) + if highest_api_version is None or highest_api_version < version_string: + highest_api_version = version_string + e = dict(os.environ) + e['NETDB_VERSION'] = version_string + print('Generating API for version {}'.format(version_string)) + exec_command_into_file([api_generator, 'openapi', '--default_endpoint='+default_endpoint], 'public/api_{}.yml'.format(version_string.replace('.', '_')), e) + +e = dict(os.environ) +e['NETDB_VERSION'] = highest_api_version +print('Generating TA schema for version {}'.format(highest_api_version)) +exec_command_into_file([api_generator, 'ta-schema'], 'public/netdb_{}_ta.yml'.format(highest_api_version.replace('.', '_')), e) diff --git a/logo.png b/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..8b08f3b3b90fe9bfc7d46e8d6923df8afe13eae4 Binary files /dev/null and b/logo.png differ diff --git a/the_netvs.svg b/the_netvs.svg new file mode 100644 index 0000000000000000000000000000000000000000..9ba884d45c2ab4b661c43525763da9cbb5923a55 --- /dev/null +++ b/the_netvs.svg @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + width="146.21mm" + height="146.21mm" + version="1.1" + viewBox="0 0 146.21 146.21" + id="svg9" + sodipodi:docname="the_netvs.svg" + inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg"> + <defs + id="defs9"> + <rect + x="413.32136" + y="374.21474" + width="66.099282" + height="140.30408" + id="rect10" /> + <rect + x="66.999895" + y="140.90735" + width="429.04921" + height="74.836658" + id="rect9" /> + </defs> + <sodipodi:namedview + id="namedview9" + pagecolor="#ffffff" + bordercolor="#000000" + borderopacity="0.25" + inkscape:showpageshadow="2" + inkscape:pageopacity="0.0" + inkscape:pagecheckerboard="0" + inkscape:deskcolor="#d1d1d1" + inkscape:document-units="mm" + inkscape:zoom="0.6831284" + inkscape:cx="141.9938" + inkscape:cy="289.1111" + inkscape:window-width="1920" + inkscape:window-height="1011" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="1" + inkscape:current-layer="svg9" /> + <rect + width="146.21" + height="146.21" + fill="#ffff00" + stroke-linejoin="round" + stroke-width="3.2112" + id="rect1" + inkscape:export-filename="../the_hpc.png" + inkscape:export-xdpi="34.744545" + inkscape:export-ydpi="34.744545" /> + <text + xml:space="preserve" + transform="scale(0.26458333)" + id="text9" + style="font-size:53.3333px;white-space:pre;shape-inside:url(#rect9);display:inline;fill:none;stroke:#000000;stroke-width:1.88976;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke markers fill" /> + <text + xml:space="preserve" + transform="scale(0.26458333)" + id="text10" + style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:53.3333px;font-family:Arial;-inkscape-font-specification:'Arial Bold';white-space:pre;shape-inside:url(#rect10);display:inline;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1.88976;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke markers fill" /> + <path + style="fill:#000000;stroke-width:0.211765" + d="m 134.23391,85.376249 c -2.58463,-0.149132 -4.1526,-0.860467 -5.23249,-2.373797 -0.64799,-0.908082 -0.98949,-1.887459 -1.12051,-3.213522 l -0.0291,-0.294154 h 2.03239 2.03239 l 0.0645,0.415164 c 0.1708,1.09863 0.81171,1.870214 1.82352,2.195331 0.39031,0.125419 0.58847,0.150988 1.35372,0.174701 0.7603,0.02358 0.98056,0.01033 1.45013,-0.08707 0.92719,-0.192324 1.48004,-0.552745 1.78917,-1.166422 0.36632,-0.727209 0.34802,-1.737071 -0.0417,-2.302636 -0.41634,-0.604161 -1.04529,-0.873142 -3.11353,-1.331547 -2.16898,-0.480739 -3.31162,-0.820183 -4.21185,-1.251235 -1.45489,-0.696629 -2.3943,-1.817766 -2.68274,-3.201716 -0.14196,-0.681164 -0.15315,-1.844514 -0.0242,-2.514923 0.42522,-2.2103 2.08917,-3.68574 4.66433,-4.135922 0.80386,-0.14053 3.20386,-0.140489 3.9073,6.4e-5 2.27569,0.454705 3.79629,1.496435 4.59644,3.148948 0.30723,0.634491 0.46877,1.247849 0.51279,1.947018 l 0.0344,0.546286 h -2.05354 -2.05354 l -9.1e-4,-0.21011 c -0.001,-0.305819 -0.14609,-0.872527 -0.3011,-1.177691 -0.45904,-0.903749 -1.21166,-1.268339 -2.61159,-1.265135 -1.44942,0.0032 -2.10276,0.313311 -2.51566,1.193616 -0.1293,0.275685 -0.14573,0.38021 -0.14572,0.927043 2e-5,0.732661 0.11766,1.06642 0.50012,1.418963 0.55989,0.516084 1.25559,0.767588 3.1978,1.15604 1.53517,0.307044 3.06692,0.75018 3.86756,1.118893 0.61773,0.284478 1.16231,0.673299 1.60653,1.147047 0.87774,0.936086 1.22142,1.906288 1.22142,3.448114 0,1.54041 -0.51591,2.840321 -1.53396,3.865052 -1.09377,1.100933 -2.53526,1.642583 -4.85058,1.822636 -0.81115,0.06308 -1.05353,0.06319 -2.13193,9.1e-4 z M 8.8402409,77.534296 V 69.914847 L 6.16484,69.900282 3.4894393,69.885718 3.4746021,68.190829 3.4597649,66.495943 h 7.3686821 7.368678 v 1.708894 1.708895 h -2.661392 -2.661392 v 7.61999 7.619991 H 10.857284 8.8402269 Z M 20.830522,75.824855 v -9.328884 h 2.04507 2.04507 v 3.754401 3.754397 l 3.403784,-0.01443 3.40378,-0.01443 0.01438,-3.739961 0.01438,-3.739955 h 2.016661 2.016657 v 9.328885 9.328884 h -2.017053 -2.017057 v -3.838008 -3.838009 h -3.417788 -3.417793 v 3.838009 3.838008 h -2.04507 -2.045071 z m 18.937915,0 v -9.328884 h 5.490876 5.490875 v 1.568823 1.56882 h -3.445806 -3.4458 v 2.269189 2.269189 h 3.4458 3.445806 v 1.568819 1.568824 h -3.445806 -3.4458 v 2.353229 2.353233 h 4.258227 4.258229 v 1.568824 1.568819 H 46.07174 39.768437 Z m 21.179094,0 v -9.328884 h 2.151261 2.151261 l 3.443425,5.9251 c 3.341732,5.750113 3.448637,5.925625 3.619761,5.942665 l 0.176335,0.01757 v -5.942674 -5.942659 h 1.961026 1.961031 v 9.329549 9.329549 l -2.137015,-0.01465 -2.137016,-0.0147 -3.451914,-5.911092 C 65.296985,73.411776 65.230441,73.30321 65.05168,73.285974 l -0.182097,-0.01757 v 5.94266 5.942664 h -1.961026 -1.961026 z m 19.442179,0 v -9.328884 h 5.490876 5.490876 v 1.568396 1.568395 l -3.45981,0.01443 -3.459815,0.01443 v 2.241176 2.241171 l 3.459815,0.01443 3.45981,0.01443 v 1.567964 1.567968 l -3.45981,0.01443 -3.459815,0.01443 v 2.32522 2.325216 l 4.244225,0.01438 4.244224,0.01438 v 1.568469 1.568469 H 86.665 80.38971 Z m 18.993952,1.708894 v -7.619986 h -2.661394 -2.661396 v -1.708898 -1.708894 h 7.368678 7.36868 l -0.0148,1.694889 -0.0148,1.694886 -2.64739,0.01456 -2.64738,0.01456 v 7.61944 7.619444 h -2.04508 -2.045068 z m 16.611198,7.549956 c -0.35294,-0.950618 -6.02166,-18.27558 -6.02166,-18.403626 v -0.184108 h 2.05979 2.05979 l 1.08307,3.627903 c 0.59569,1.995342 1.52557,5.109173 2.06642,6.91962 l 0.98334,3.291722 0.17405,-6.3e-5 0.17405,-6.4e-5 1.08389,-3.627835 c 0.59614,-1.995306 1.52672,-5.10911 2.06795,-6.919557 l 0.98406,-3.291726 h 2.06421 2.06421 l 0.003,0.154079 c 0.002,0.08475 -1.36623,4.282637 -3.0396,9.328648 l -3.0425,9.174569 -2.36899,2.09e-4 c -1.84416,1.87e-4 -2.37476,-0.01525 -2.395,-0.06979 z M 82.367539,64.766788 c -0.829444,-0.2866 -1.302063,-0.969929 -1.303538,-1.884709 -9.1e-4,-0.699464 0.166022,-1.134079 0.596851,-1.551886 0.804595,-0.780278 2.370274,-0.707817 3.06657,0.141922 0.362706,0.442635 0.452826,0.717807 0.452594,1.381949 -2.14e-4,0.748931 -0.11721,1.039819 -0.596401,1.483465 -0.256633,0.237602 -0.412333,0.331056 -0.699114,0.419635 -0.468923,0.144834 -1.113809,0.148925 -1.516962,0.0096 z m 5.88977,0.0053 c -0.888152,-0.316615 -1.359383,-1.07093 -1.300835,-2.08228 0.04595,-0.793896 0.452621,-1.402252 1.158561,-1.73316 0.277847,-0.13024 0.384088,-0.147542 0.903194,-0.147095 0.528919,4.55e-4 0.623645,0.01677 0.938352,0.161624 0.416784,0.191838 0.748241,0.52984 0.957659,0.976568 0.131742,0.28103 0.149064,0.386329 0.149064,0.906283 0,0.519457 -0.01739,0.625391 -0.148559,0.905174 -0.185232,0.395106 -0.542363,0.749312 -0.944018,0.936279 -0.414013,0.192724 -1.279189,0.231405 -1.713418,0.07661 z" + id="path1" /> +</svg>