Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…rapper into main
  • Loading branch information
lmarinve committed Apr 17, 2024
2 parents 32ed9f0 + a29e889 commit 875d674
Show file tree
Hide file tree
Showing 5 changed files with 293 additions and 473 deletions.
21 changes: 3 additions & 18 deletions amlight/kytos-sdx-topology/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ def setup(self):
self.shelve_loaded = False # pylint: disable=W0201
self.version_control = False # pylint: disable=W0201
OXPO_ID = int(os.environ.get("OXPO_ID"))
sdx_lc_urls_str = os.environ.get("SDXLC_URLS")
self.sdxlc_url = sdx_lc_urls_str.split(",")[OXPO_ID]
oxpo_names_str = os.environ.get("OXPO_NAMES")
self.oxpo_name = oxpo_names_str.split(",")[OXPO_ID]
oxpo_urls_str = os.environ.get("OXPO_URLS")
Expand Down Expand Up @@ -82,20 +80,6 @@ def get_kytos_topology():
result = kytos_topology["topology"]
return result

def post_sdx_lc(self, event_type=None):
""" return the status from post sdx topology to sdx lc"""
sdxlc_url = self.sdxlc_url
post_topology = requests.post(
sdxlc_url,
timeout=60,
json=self.sdx_topology)
if post_topology.status_code == 200:
if event_type is not None:
return {"result": self.sdx_topology,
"status_code": post_topology.status_code}
return {"result": post_topology.json(),
"status_code": post_topology.status_code}

def validate_sdx_topology(self):
""" return 200 if validated topology following the SDX data model"""
try:
Expand Down Expand Up @@ -171,8 +155,9 @@ def post_sdx_topology(self, event_type=None, event_timestamp=None):
if evaluate_topology["status_code"] == 200:
self.kytos2sdx = topology_updated.get("kytos2sdx", {})
self.sdx2kytos = topology_updated.get("sdx2kytos", {})
result = self.post_sdx_lc(event_type)
return result

return {"result": self.sdx_topology,
"status_code": evaluate_topology["status_code"]}
with shelve.open("events_shelve") as log_events:
shelve_events = log_events['events']
shelve_events.append(
Expand Down
2 changes: 2 additions & 0 deletions os-base/nginx-base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ ENV LANG=C.UTF-8
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

COPY ./os-base/nginx-base/default.conf.template /etc/nginx/templates/default.conf.template
76 changes: 76 additions & 0 deletions os-base/nginx-base/default.conf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
types {
text/plain yaml;
text/plain yml;
}

gzip on;
gzip_static on;
gzip_disable "msie6";

gzip_vary on;
gzip_types text/plain text/css application/javascript;

map $request_method $access_control_max_age {
OPTIONS 1728000; # 20 days
}
server_tokens off; # Hide Nginx version

server {
listen $PORT;
server_name localhost;
index index.html index.htm;

location $BASE_URL {
absolute_redirect off;
alias /usr/share/nginx/html/;
expires 1d;

location ~ swagger-initializer.js {
expires -1;
include templates/cors.conf;
}

location ~* \.(?:json|yml|yaml)$ {
#SWAGGER_ROOT
expires -1;

include templates/cors.conf;
}

include templates/cors.conf;
include templates/embedding.conf;
}

location $DEFAULT_TOPOLOGY {
proxy_pass $DEFAULT_URL$TOPOLOGY_PATH;
}

location $TOPOLOGY_1 {
proxy_pass $URL_1$TOPOLOGY_PATH;
}

location $TOPOLOGY_2 {
proxy_pass $URL_2$TOPOLOGY_PATH;
}

location $TOPOLOGY_3 {
proxy_pass $URL_3$TOPOLOGY_PATH;
}

location $DEFAULT_CONNECTION {
proxy_pass $DEFAULT_URL$CONNECTION_PATH;
}

location $CONNECTION_1 {
proxy_pass $URL_1$CONNECTION_PATH;
}

location $CONNECTION_2 {
proxy_pass $URL_2$CONNECTION_PATH;
}

location $CONNECTION_3 {
proxy_pass $URL_3$CONNECTION_PATH;
}

}
112 changes: 112 additions & 0 deletions os-base/nginx-base/oxpoapi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"openapi": "3.0.0",
"info": {
"title": "Oxpo Api Wrapper",
"description": "The wrapper abstracts the complexities of direct API calls and offers a consistent method to interact with different OXPO services",
"version": "1.0.0",
"contact": {
"email": "[email protected]"
}
},
"servers": [
{
"url": "http://67.17.206.221"
}
],
"tags": [
{
"name": "topology",
"description": "Everything about your domain topology",
"externalDocs": {
"description": "Find out more",
"url": "https://www.atlanticwave-sdx.net"
}
},
{
"name": "node",
"description": "everything about a node in your domain"
},
{
"name": "link",
"description": "everything about a link in your domain"
},
{
"name": "user",
"description": "Operations about user",
"externalDocs": {
"description": "Find out more about our store",
"url": "https://www.atlanticwave-sdx.net"
}
}
],
"paths": {
"/topology": {
"get": {
"tags": [
"topology"
],
"summary": "Get SDX Topology",
"description": "Get SDX topology",
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {}
}
}
}
}
},
"/topology/1": {
"get": {
"tags": [
"topology"
],
"summary": "Get Ampath SDX Topology",
"description": "Get Ampath SDX topology",
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {}
}
}
}
}
},
"/topology/2": {
"get": {
"tags": [
"topology"
],
"summary": "Get SAX SDX Topology",
"description": "Get SAX SDX topology",
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {}
}
}
}
}
},
"/topology/3": {
"get": {
"tags": [
"topology"
],
"summary": "Get Tenet SDX Topology",
"description": "Get Tenet SDX topology",
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {}
}
}
}
}
}
}
}
Loading

0 comments on commit 875d674

Please sign in to comment.