Skip to content

Commit

Permalink
Various server fixes (#12)
Browse files Browse the repository at this point in the history
A series of changes that fixed the below issues
- fixes #10 
- fixes #9 
- fixes #8

---------
Signed-off-by: Christian Pinto <[email protected]>
  • Loading branch information
christian-pinto authored Apr 23, 2024
1 parent f999440 commit 9710dcb
Show file tree
Hide file tree
Showing 16 changed files with 345 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"@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",
"Description": "PCIe Fabric",
"FabricType": "PCIe",
"HostName": "http://pcie-fabric-agent:5050",
"Id": "0fa4bc06-79a8-4fec-bea5-26dfa7678c28",
"Links": {
"ConnectionMethod": {
"@odata.id": "/redfish/v1/AggregationService/ConnectionMethods/CXL"
},
"ResourcesAccessed": [

]
},
"Name": "PCIe Fabric",
"Status": {
"Health": "OK",
"State": "Enabled"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"@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",
"Description": "CXL Fabric",
"FabricType": "CXL",
"HostName": "http://h3-cxl-appliance-agent:9080",
"Id": "0fa4bc06-79a8-4fec-bea5-26dfa7678c29",
"Links": {
"ConnectionMethod": {
"@odata.id": "/redfish/v1/AggregationService/ConnectionMethods/CXL"
},
"ResourcesAccessed": [
]
},
"Name": "CXL Fabric",
"Status": {
"Health": "OK",
"State": "Enabled"
}
}
14 changes: 14 additions & 0 deletions Resources/AggregationService/AggregationSources/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"@odata.id": "/redfish/v1/AggregationService/AggregationSources",
"@odata.type": "#AggregationService/AggregationSourcesCollection.AggregationService/AggregationSourcesCollection",
"Members": [
{
"@odata.id": "/redfish/v1/AggregationService/AggregationSources/0fa4bc06-79a8-4fec-bea5-26dfa7678c29"
},
{
"@odata.id": "/redfish/v1/AggregationService/AggregationSources/0fa4bc06-79a8-4fec-bea5-26dfa7678c28"
}
],
"[email protected]": 1,
"Name": "AggregationService/AggregationSources Collection"
}
16 changes: 16 additions & 0 deletions Resources/AggregationService/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"@odata.context": "/redfish/v1/$metadata#CompositionService.AggregationService",
"@odata.type": "#CompositionService.v1_2_2.AggregationService",
"@odata.id": "/redfish/v1/AggregationService",
"Id": "AggregationService",
"Name": "Aggregation Service",
"Status": {
"State": "Enabled",
"Health": "OK"
},
"ServiceEnabled": true,
"AgregationSources": {
"@odata.id": "/redfish/v1/AggregationService/AggregationSources"
},
"Oem": {}
}
8 changes: 8 additions & 0 deletions Resources/CompositionService/ResourceBlocks/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"@odata.context": "/redfish/v1/$metadata#ResourceBlockCollection.ResourceBlockCollection",
"@odata.id": "/redfish/v1/CompositionService/ResourceBlocks",
"@odata.type": "#ResourceBlockCollection.ResourceBlockCollection",
"Name": "Resource Block Collection",
"[email protected]": 20,
"Members": []
}
16 changes: 16 additions & 0 deletions Resources/CompositionService/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"@odata.context": "/redfish/v1/$metadata#CompositionService.CompositionService",
"@odata.type": "#CompositionService.v1_2_2.CompositionService",
"@odata.id": "/redfish/v1/CompositionService",
"Id": "CompositionService",
"Name": "Composition Service",
"Status": {
"State": "Enabled",
"Health": "OK"
},
"ServiceEnabled": true,
"ResourceBlocks": {
"@odata.id": "/redfish/v1/CompositionService/ResourceBlocks"
},
"Oem": {}
}
12 changes: 3 additions & 9 deletions Resources/Systems/index.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
{
"@odata.id": "/redfish/v1/Systems",
"@odata.type": "#SystemsCollection.SystemsCollection",
"Members": [
{
"@odata.id": "/redfish/v1/Systems/1"
},
{
"@odata.id": "/redfish/v1/Systems/1234"
}
],
"[email protected]": 2,
"Members": [],
"[email protected]": 0,

"Name": "Systems Collection"
}
7 changes: 7 additions & 0 deletions Resources/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,12 @@
"RedfishVersion": "1.14.0",
"Systems": {
"@odata.id": "/redfish/v1/Systems"
},
"CompositionService": {
"@odata.id": "/redfish/v1/CompositionService"
},
"AggregationServiceService": {
"@odata.id": "/redfish/v1/AggregationService"

}
}
60 changes: 45 additions & 15 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,72 @@
# 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 +75,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 Down
Binary file added static/create.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/re-allocate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/register-button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/reset-button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/sunfish_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/sunfish_logo_no_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9710dcb

Please sign in to comment.