Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor ALTO server by a modular design #19

Merged
merged 16 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM python:3.10.7

COPY / /tmp/alto
RUN rm -rf /tmp/alto/.git && \
pip install redis && \
pip install /tmp/alto && \
rm -rf /tmp/alto

EXPOSE 8000

1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn alto.server.django_server.django_server.wsgi
42 changes: 42 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
services:
gateway:
image: nginx
volumes:
- ./etc/nginx.conf:/etc/nginx/nginx.conf
- ./etc/htpasswd:/etc/nginx/conf.d/.htpasswd
- ./etc/cert.pem:/etc/nginx/cert.pem
- ./etc/cert.key:/etc/nginx/cert.key
ports:
- "8443:443"
alto-frontend:
image: openalto/alto
volumes:
- ./src/alto:/usr/local/lib/python3.10/site-packages/alto
entrypoint: gunicorn
command: ["-b", "0.0.0.0:8000", "--reload", "alto.server.django_server.django_server.wsgi", "--preload"]
alto-lg-agent:
image: openalto/alto
volumes:
- ./etc/lg-agent.json:/etc/lg-agent.json
entrypoint: python
command: ["-m", "alto.agent.manage", "--pid", "/tmp", "start", "-c", "/etc/lg-agent.json", "-D", "cernlg"]
network_mode: "service:alto-frontend"
alto-cric-agent:
image: openalto/alto
volumes:
- ./etc/cric-agent.json:/etc/cric-agent.json
entrypoint: python
command: ["-m", "alto.agent.manage", "--pid", "/tmp", "start", "-c", "/etc/cric-agent.json", "-D", "cric"]
network_mode: "service:alto-frontend"
alto-db:
image: redis
network_mode: "service:alto-frontend"
alto-client:
image: curlimages/curl
volumes:
- ./tmp/request.json:/request.json
- ./tmp/pvtest.sh:/pvtest.sh
- ./etc/cert.pem:/etc/cert.pem
- ./etc/cert.key:/etc/cert.key
entrypoint: sh
command: ["-c", "tail -f /dev/null"]
43 changes: 43 additions & 0 deletions etc/alto.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
# The MIT License (MIT)
#
# Copyright (c) 2021 OpenALTO Community
#
# 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.
#
# Authors:
# - Jensen Zhang <[email protected]>

####################################################
# Configure an ALTO client
####################################################
[client]
# ALTO server
default_ird = http://localhost:8181/alto/simpleird/default
default_networkmap = http://mininet:8181/networkmap
default_costmap = http://mininet:8181/costmap
static_ird = {
"costmap-bw-available": "http://mininet:8181/costmap/bw-available",
"costmap-delay-ow": "http://mininet:8181/costmap/delay-ow" }
auth_type = userpass
username = admin
password = admin

[http]
retry = 3
28 changes: 28 additions & 0 deletions etc/cert.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDEUjwm5XkQ/gIo
UNT9qZsTF+tp69b9MpS92FK0YHaGQs50Jy9fwB5iNlmLNWBYxeId+NKsTaNzJYL/
5jYvwycUGBtVI2OrvO8ZpDnYrscaSnG7pBLAWNrxcjQQjB2qu9ZBenOTFvBVnFSR
+xs9XfGMnJ7rMMMxx9k4oKPJgCHiwGnuyoppJRSRiO/7Gwjirq46co/AAUizPlzC
zC3XeEuFcY/YvuZJ9e99n3086vo6yNGLd5Z6adnjfPiP4AwDFbTZmnqsLNSFdFYu
m7lDe60VeeWp2lkqV9y8bTMGgXcotkhD4kcbvd/Iyf1HrWfEGzsH5JeVoS/zrZXe
y1e3eSQnAgMBAAECggEAHRfSsjDvcAU0bKUN60lnIb05tcitY3hLcpbMKs7gwaTE
05G7A4WE+yjyvB582Kr6h1aIYeBfiIDWmPWUsh9Je0DXTBaifqDRDgu4RtQfzVWa
5SO7Y6XHTGCQNqONAfA0IB/1YKbVltpD7h44Oy/gy+Wp51CinI3xMuMbYpEKdH+s
piGqf7XevqTHMX3hapgCXh6pP+iWo8pZqSmy426I3heYg7VQpL3/e3a0R5mECDD/
DAowzJlyXgJTJpWocscZWgaCwJVmqBav9a1xMryPPio61nRuyO/pshO1pIAEG3dD
ksx+Ic9hDPS8BOXH6ZcKls3iADYEth2RIe9yI/wwgQKBgQDtMxtwW/FoKJjj2QIw
ALEg23TE6w3f2dH3lP2dSxcnBVPe/f41/aKgjEpU3HCvt3xLSyaqvYrWJYOBxvNk
ZhHiG/IO5jmm7/sPRhz0grz/CbuO/M4a5/iVBQU8c1wAC+Tz4oZEn/1Dul3CE771
kvDTIJP+lnWerC+Fo1Zx/tygHQKBgQDT4a+Bw87qtZpHbySUViTaz5INgWWHu3QN
yOvE66gX793VP5t11QHMy6JYFDMhjvmr3WJLt4pFVoXf/JEpSfFeTyn7ZteS3oF/
8JOstWqzPvJl1z3fA5D6EAqNw+t1i2/ueWWvcbIx33TZ8oNoFjOS+n3qBbTtUmXV
M22exv6qEwKBgQDavMqM7vzL5MQ5OaG+yqSNfFNOVMTSrXfnLMpEBz8uiMczWF7Z
QzB5hWX2o+J26GoCtSbPRUOG/8kqIGHLMCVFsieifcSkoaGQEEQbZ4UKW9tOnOsj
/M9L/Pk7KdapZE6aaUcQecmAb5iOpM7wf7T9vYk8uVt2G6snPd01+qVSMQKBgQCi
KuoZd7S3D6e1ZOuqXQR4NMakb5U1/dMledJ6NaPCLmSrArQJy65FANaQc2VvGe8e
C6NgMGo0B7UPak/wOhfzBsQrFtuIHaUgNxHP7kpsRpFgQQ2p0yDzQ7PQLVPZ848I
BwI89dhdM5pL9cF9uQBgTjhxFU0VFyu5slMEY2om4QKBgDaCC3Y40hyXByCcDVzQ
7wnBnmOFd/sixb9SKLEDzyjeBcihj92lhOz/WEjc9l3dZW53i3woOY4Fmkpo+JUR
MQc3Ri6fi7oSamWQfkuPRuzrKAElPXyI3lpemnYq7pod5mdSxTAwWFC2YoTUMzs+
8UxWpzTt0i6oXf12/xLb3mar
-----END PRIVATE KEY-----
21 changes: 21 additions & 0 deletions etc/cert.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-----BEGIN CERTIFICATE-----
MIIDdTCCAl2gAwIBAgIUF7vQC3ITOTeNs2jfIsBjD7+V2hEwDQYJKoZIhvcNAQEL
BQAwSjELMAkGA1UEBhMCQ04xETAPBgNVBAgMCFNoYW5naGFpMREwDwYDVQQHDAhT
aGFuZ2hhaTEVMBMGA1UECgwMVG9uZ2ppIFVuaXYuMB4XDTIyMTAwMzEyNTc1MFoX
DTMyMDkzMDEyNTc1MFowSjELMAkGA1UEBhMCQ04xETAPBgNVBAgMCFNoYW5naGFp
MREwDwYDVQQHDAhTaGFuZ2hhaTEVMBMGA1UECgwMVG9uZ2ppIFVuaXYuMIIBIjAN
BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxFI8JuV5EP4CKFDU/ambExfraevW
/TKUvdhStGB2hkLOdCcvX8AeYjZZizVgWMXiHfjSrE2jcyWC/+Y2L8MnFBgbVSNj
q7zvGaQ52K7HGkpxu6QSwFja8XI0EIwdqrvWQXpzkxbwVZxUkfsbPV3xjJye6zDD
McfZOKCjyYAh4sBp7sqKaSUUkYjv+xsI4q6uOnKPwAFIsz5cwswt13hLhXGP2L7m
SfXvfZ99POr6OsjRi3eWemnZ43z4j+AMAxW02Zp6rCzUhXRWLpu5Q3utFXnlqdpZ
KlfcvG0zBoF3KLZIQ+JHG73fyMn9R61nxBs7B+SXlaEv862V3stXt3kkJwIDAQAB
o1MwUTAdBgNVHQ4EFgQU7rTPvm72oxWXeQtmNng0zSQ8kh0wHwYDVR0jBBgwFoAU
7rTPvm72oxWXeQtmNng0zSQ8kh0wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0B
AQsFAAOCAQEAOKo4Tsf3xqgahnUu3IasoeNAqwpxZbhXpt/Ru7+M387znwtnPdX0
64X4vyOZl/Q5qe2JzGwTmpwsoVIPCxv39pbylxetdG9l+HBVmWA58l+lgyTgj6d+
ZaQtvencQrV8V+zqDbJKPZ+Rs2Ah3bEunNWfTij9oCqGfRHtXyY6M8U7LXzs0tVZ
exEE/Rzjtk488jqxJyhTMa4lL1LMJjX2N09tocMCBHqFHZcIIQxHYwsnrH+6HzpB
2WhCEJJI+huePqkrwiJJTWyya0+WiTHWjX4kfXUfmtXjzKhsA1Q9BeI235Ops0XS
7Nk9j+ZnSklcyGjeyY0UGqw8b0tJA7A0tA==
-----END CERTIFICATE-----
7 changes: 7 additions & 0 deletions etc/cric-agent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"namespace": "default",
"agent_class": "alto.agent.cric.CRICAgent",
"uri": "https://wlcg-cric.cern.ch/api/core/rcsite/query/?json",
"local_asn": 513,
"refresh_interval": 300
}
1 change: 1 addition & 0 deletions etc/htpasswd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cern:$apr1$bX1nUbQN$/tJBeK010/hlHPqJNLfm90
7 changes: 7 additions & 0 deletions etc/lg-agent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"namespace": "default",
"agent_class": "alto.agent.cernlg.LookingGlassAgent",
"uri": "http://lhcone-lg.cern.ch/lg.cgi",
"default_router": "ex2j.cern.ch:juniper",
"refresh_interval": 300
}
34 changes: 34 additions & 0 deletions etc/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
}

http {
server {
listen 443 ssl;
keepalive_timeout 60;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers AES128-SHA:AES256-SHA:RC4-SHA:DES-CBC3-SHA:RC4-MD5;
ssl_certificate /etc/nginx/cert.pem;
ssl_certificate_key /etc/nginx/cert.key;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;

# auth_basic "Restricted Access!";
# auth_basic_user_file /etc/nginx/conf.d/.htpasswd;

location / {
deny 192.168.80.1;
allow 192.168.80.0/24;
deny all;
proxy_pass http://alto-frontend:8000;
}
}
}
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ build-backend = "setuptools.build_meta"
# For smarter version schemes and other configuration options,
# check out https://github.com/pypa/setuptools_scm
version_scheme = "no-guess-dev"
fallback_version = "0.1.0"
7 changes: 7 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ install_requires =
importlib-metadata; python_version<"3.8"
requests
pytricia
Django
djangorestframework
networkx
lxml
service
gunicorn


[options.packages.find]
Expand All @@ -63,6 +69,7 @@ exclude =
# Add here additional requirements for extra features, to install with:
# `pip install alto[PDF]` like:
# PDF = ReportLab; RXP
redis = redis

# Add here test requirements (semicolon/line-separated)
testing =
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

if __name__ == "__main__":
try:
setup(use_scm_version={"version_scheme": "no-guess-dev"})
setup(use_scm_version={"version_scheme": "no-guess-dev", "fallback_version": "0.1.0"})
except: # noqa
print(
"\n\nAn error occurred while building the project, "
Expand Down
Loading