Skip to content

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
removed ip addresses and clutter from aggregation sources
  • Loading branch information
christian-pinto committed Apr 23, 2024
1 parent e632762 commit ef1231e
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@
"@Redfish.Copyright": "Copyright 2014-2021 DMTF. For the full DMTF copyright policy, see http://www.dmtf.org/about/policies/copyright.",
"@odata.id": "/redfish/v1/AggregationService/AggregationSources/0fa4bc06-79a8-4fec-bea5-26dfa7678c28",
"@odata.type": "#AggregationSource.v1_2_.AggregationSource",
"Connections": {
"@odata.id": "/redfish/v1/Fabrics/CXL/Connections"
},
"Description": "CXL Fabric",
"Endpoints": {
"@odata.id": "/redfish/v1/Fabrics/CXL/Endpoints"
},
"FabricType": "CXL",
"HostName": "http://localhost:5050",
"Description": "PCIe Fabric",
"FabricType": "PCIe",
"HostName": "http://pcie-fabric-agent:5050",
"Id": "0fa4bc06-79a8-4fec-bea5-26dfa7678c28",
"Links": {
"ConnectionMethod": {
Expand All @@ -20,15 +14,9 @@

]
},
"Name": "CXL Fabric",
"Name": "PCIe Fabric",
"Status": {
"Health": "OK",
"State": "Enabled"
},
"Switches": {
"@odata.id": "/redfish/v1/Fabrics/CXL/Switches"
},
"Zones": {
"@odata.id": "/redfish/v1/Fabrics/CXL/Zones"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@
"@Redfish.Copyright": "Copyright 2014-2021 DMTF. For the full DMTF copyright policy, see http://www.dmtf.org/about/policies/copyright.",
"@odata.id": "/redfish/v1/AggregationService/AggregationSources/0fa4bc06-79a8-4fec-bea5-26dfa7678c29",
"@odata.type": "#AggregationSource.v1_2_.AggregationSource",
"Connections": {
"@odata.id": "/redfish/v1/Fabrics/CXL/Connections"
},
"Description": "CXL Fabric",
"Endpoints": {
"@odata.id": "/redfish/v1/Fabrics/CXL/Endpoints"
},
"FabricType": "CXL",
"HostName": "http://220.134.146.222:9080",
"HostName": "http://h3-cxl-appliance-agent:9080",
"Id": "0fa4bc06-79a8-4fec-bea5-26dfa7678c29",
"Links": {
"ConnectionMethod": {
Expand All @@ -23,11 +17,5 @@
"Status": {
"Health": "OK",
"State": "Enabled"
},
"Switches": {
"@odata.id": "/redfish/v1/Fabrics/CXL/Switches"
},
"Zones": {
"@odata.id": "/redfish/v1/Fabrics/CXL/Zones"
}
}
58 changes: 42 additions & 16 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,68 @@
# Copyright IBM Corp. 2023
# This software is available to you under a BSD 3-Clause License.
# The full license terms are available here: https://github.com/OpenFabrics/sunfish_server_reference/blob/main/LICENSE
import os
import traceback

from flask import Flask, request
from sunfishcorelib.core import Core
from sunfishcorelib.exceptions import *
from flask import Flask, request, render_template
from sunfish.lib.core import Core
from sunfish.lib.exceptions import *
import logging

FORMAT = "[%(filename)s:%(lineno)s - %(funcName)20s() ] %(message)s"
logging.basicConfig(format=FORMAT, level=logging.DEBUG)

logger = logging.getLogger("Server")
conf = {
"storage_backend": "FS",
"redfish_root": "/redfish/v1/",
"backend_conf" : {
"fs_root": "Resources"
"fs_root": "Resources",
"subscribers_root": "EventService/Subscriptions"
},
"handlers": {
"subscription_handler": "redfish",
"event_handler": "redfish"
}
}

# initialize flask

app = Flask(__name__)
template_dir = os.path.abspath('./templates_web')
app = Flask(__name__, template_folder=template_dir)
sunfish_core = Core(conf)

@app.route('/browse')
def browse():
return render_template('browse.html')

# Usa codici http
@app.route('/<path:resource>', methods=["GET"])
@app.route('/<path:resource>', methods=["GET"], strict_slashes=False)
def get(resource):

logger.debug(f"GET on: {request.path}")
try:
resp = sunfish_core.get_object(resource)
resp = sunfish_core.get_object(request.path)
return resp, 200
except ResourceNotFound as e:
return e.message, 404

@app.route('/<path:resource>', methods=["POST"])
@app.route('/<path:resource>', methods=["POST"], strict_slashes=False)
def post(resource):
logger.debug("POST")
try :
resp = sunfish_core.create_object(request.json)
if resource == "EventListener":
resp = sunfish_core.handle_event(request.json)
else:
resp = sunfish_core.create_object(request.path, request.json)
return resp
except CollectionNotSupported as e:
return e.message, 405 # method not allowed
except AlreadyExists as e:
return e.message, 409 # Conflict
except PropertyNotFound as e:
return e.message, 400

@app.route('/<path:resource>', methods=["PUT"])
@app.route('/<path:resource>', methods=["PUT"], strict_slashes=False)
def put(resource):
try:
data = request.json
Expand All @@ -48,19 +71,22 @@ def put(resource):
except ResourceNotFound as e:
return e.message, 404

@app.route('/<path:resource>', methods=["PATCH"])
@app.route('/<path:resource>', methods=["PATCH"], strict_slashes=False)
def patch(resource):
try:
logger.debug("PATCH")
data = request.json
resp = sunfish_core.patch_object(data)
resp = sunfish_core.patch_object(path=request.path, payload=data)
return resp, 200
except ResourceNotFound as e:
return e.message, 404
except Exception:
traceback.print_exc()

@app.route('/<path:resource>', methods=["DELETE"])
@app.route('/<path:resource>', methods=["DELETE"], strict_slashes=False)
def delete(resource):
try:
resp = sunfish_core.delete_object(resource)
resp = sunfish_core.delete_object(request.path)
return resp, 200
except ResourceNotFound as e:
return e.message, 404
Expand All @@ -70,4 +96,4 @@ def delete(resource):
return e.message, 400

# we run app debugging mode
app.run(debug=False)
app.run(debug=False)

0 comments on commit ef1231e

Please sign in to comment.