Skip to content

Commit

Permalink
redfish: Add redfish schemas only from implementation and oem
Browse files Browse the repository at this point in the history
Implemented logic inside the "redfish-gen" tool to prepare schemas based on BMC implementation
and Oem schemas necessary for the "Redfish Service Validator" tool.

Part of BBMC-1462

End-User-Impact: Low: (The BMC's redfish service may be validated
		by the "Redfish Service Validator" tool)

Signed-off-by: Sergey Gulyaev <[email protected]>
  • Loading branch information
Sergey Gulyaev committed Feb 21, 2023
1 parent 7ca1ec9 commit b24a80a
Show file tree
Hide file tree
Showing 4 changed files with 556 additions and 5 deletions.
3 changes: 3 additions & 0 deletions tools/redfish-gen/redfish_gen/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import yaml
from datetime import date
from .redfish_node import RedfishNode
from .redfish_schema import RedfishSchema
from .globals import __BASE_PATH__


Expand Down Expand Up @@ -41,6 +42,7 @@ def generate(self, loader):
template = Generator.render(
loader, "node.hpp.mako", instance=self.instance, year=year)
Generator.__write_gen_file(self.instance.classname(), template)
RedfishSchema.build("redfish", self.instance.schema_id(), self.instance.version(), resolved=True, schema_json=self.instance.schema)

@staticmethod
def get_node(schema_name):
Expand All @@ -59,6 +61,7 @@ def render(loader, template, **kwargs):
def generate_all(loader):
for node in Generator.nodes:
node.generate(loader=loader)
RedfishSchema.generate_all_schema()

@staticmethod
def __write_gen_file(filename, content, basedir=__BASE_PATH__+"/src/redfish/generated/"):
Expand Down
1 change: 1 addition & 0 deletions tools/redfish-gen/redfish_gen/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
__BASE_PATH__ = os.path.dirname(os.path.dirname(
os.path.dirname(os.path.dirname(gen.__file__))))
__RFG_PATH__ = __BASE_PATH__ + "/tools/redfish-gen/"
__WWW_PATH__ = __BASE_PATH__ + "/www"
14 changes: 9 additions & 5 deletions tools/redfish-gen/redfish_gen/property.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .globals import __RFG_PATH__

import redfish_gen.generator as generator
from .redfish_schema import RedfishSchema
import json


Expand Down Expand Up @@ -139,6 +140,7 @@ def resolve_property_spec(prop_spec, global_spec, recursive=True):
if ref_path is None:
return prop_spec
prop_path = ref_path.fragment.split("/")
properties = definition["definitions"] if "definitions" in definition else None
for segment in prop_path:
if len(segment) > 0:
if segment == "definitions" and segment not in definition:
Expand All @@ -147,11 +149,13 @@ def resolve_property_spec(prop_spec, global_spec, recursive=True):
definition = definition[segment]
else:
raise ValueError("Invalid specification of %s" % segment)
ref = Property.__retrieve_ref(definition)
if recursive and ref is not None and not ref.endswith("/idRef"):
ref_spec = Property.__resolve_spec_by_ref(urlparse(ref))
recursive_spec = ref_spec if ref_spec is not None else global_spec
return Property.resolve_property_spec(definition, recursive_spec)
if recursive:
ref = Property.__retrieve_ref(definition)
if ref is not None and not ref.endswith("/idRef"):
ref_spec = Property.__resolve_spec_by_ref(urlparse(ref))
recursive_spec = ref_spec if ref_spec is not None else global_spec
return Property.resolve_property_spec(definition, recursive_spec)
RedfishSchema.extract_schemas(properties)
return definition

def value(self):
Expand Down
Loading

0 comments on commit b24a80a

Please sign in to comment.