Ed Tanous | 683f727 | 2018-07-26 12:47:19 -0700 | [diff] [blame] | 1 | #!/usr/bin/python3 |
| 2 | import requests |
| 3 | import zipfile |
| 4 | from io import BytesIO |
| 5 | import os |
Ed Tanous | 683f727 | 2018-07-26 12:47:19 -0700 | [diff] [blame] | 6 | from collections import OrderedDict |
Ed Tanous | 683f727 | 2018-07-26 12:47:19 -0700 | [diff] [blame] | 7 | import shutil |
| 8 | import json |
| 9 | |
Ed Tanous | 118b1c7 | 2018-09-13 13:45:51 -0700 | [diff] [blame] | 10 | import xml.etree.ElementTree as ET |
| 11 | |
Gunnar Mills | 60c922d | 2021-12-01 09:28:53 -0600 | [diff] [blame] | 12 | VERSION = "DSP8010_2021.3" |
Ed Tanous | cb10313 | 2019-10-08 11:34:22 -0700 | [diff] [blame] | 13 | |
Gunnar Mills | 349a2ac | 2021-01-20 22:29:16 -0600 | [diff] [blame] | 14 | # To use a new schema, add to list and rerun tool |
| 15 | include_list = [ |
| 16 | 'AccountService', |
| 17 | 'ActionInfo', |
| 18 | 'Assembly', |
| 19 | 'AttributeRegistry', |
| 20 | 'Bios', |
| 21 | 'Certificate', |
| 22 | 'CertificateCollection', |
| 23 | 'CertificateLocations', |
| 24 | 'CertificateService', |
| 25 | 'Chassis', |
| 26 | 'ChassisCollection', |
| 27 | 'ComputerSystem', |
| 28 | 'ComputerSystemCollection', |
| 29 | 'Drive', |
| 30 | 'DriveCollection', |
| 31 | 'EthernetInterface', |
| 32 | 'EthernetInterfaceCollection', |
| 33 | 'Event', |
| 34 | 'EventDestination', |
| 35 | 'EventDestinationCollection', |
| 36 | 'EventService', |
| 37 | 'IPAddresses', |
| 38 | 'JsonSchemaFile', |
Ed Tanous | f395daa | 2021-08-02 08:56:24 -0700 | [diff] [blame] | 39 | 'JsonSchemaFileCollection', # redfish/v1/JsonSchemas |
Gunnar Mills | 349a2ac | 2021-01-20 22:29:16 -0600 | [diff] [blame] | 40 | 'LogEntry', |
| 41 | 'LogEntryCollection', |
| 42 | 'LogService', |
| 43 | 'LogServiceCollection', |
| 44 | 'Manager', |
| 45 | 'ManagerAccount', |
| 46 | 'ManagerAccountCollection', |
| 47 | 'ManagerCollection', |
| 48 | 'ManagerNetworkProtocol', |
| 49 | 'Memory', |
| 50 | 'MemoryCollection', |
| 51 | 'Message', |
| 52 | 'MessageRegistry', |
| 53 | 'MessageRegistryCollection', |
| 54 | 'MessageRegistryFile', |
| 55 | 'MessageRegistryFileCollection', |
| 56 | 'MetricDefinition', |
| 57 | 'MetricDefinitionCollection', |
| 58 | 'MetricReport', |
| 59 | 'MetricReportCollection', |
| 60 | 'MetricReportDefinition', |
| 61 | 'MetricReportDefinitionCollection', |
| 62 | 'OperatingConfig', |
| 63 | 'OperatingConfigCollection', |
| 64 | 'PCIeDevice', |
| 65 | 'PCIeDeviceCollection', |
| 66 | 'PCIeFunction', |
| 67 | 'PCIeFunctionCollection', |
| 68 | 'Power', |
Ed Tanous | f395daa | 2021-08-02 08:56:24 -0700 | [diff] [blame] | 69 | 'Privileges', # Used in Role |
Gunnar Mills | 349a2ac | 2021-01-20 22:29:16 -0600 | [diff] [blame] | 70 | 'Processor', |
| 71 | 'ProcessorCollection', |
| 72 | 'RedfishError', |
| 73 | 'RedfishExtensions', |
| 74 | 'Redundancy', |
| 75 | 'Resource', |
| 76 | 'Role', |
| 77 | 'RoleCollection', |
| 78 | 'Sensor', |
| 79 | 'SensorCollection', |
| 80 | 'ServiceRoot', |
| 81 | 'Session', |
| 82 | 'SessionCollection', |
| 83 | 'SessionService', |
| 84 | 'Settings', |
| 85 | 'SoftwareInventory', |
| 86 | 'SoftwareInventoryCollection', |
| 87 | 'Storage', |
| 88 | 'StorageCollection', |
| 89 | 'StorageController', |
| 90 | 'StorageControllerCollection', |
| 91 | 'Task', |
| 92 | 'TaskCollection', |
| 93 | 'TaskService', |
| 94 | 'TelemetryService', |
| 95 | 'Thermal', |
| 96 | 'UpdateService', |
| 97 | 'VLanNetworkInterfaceCollection', |
| 98 | 'VLanNetworkInterface', |
| 99 | 'VirtualMedia', |
| 100 | 'VirtualMediaCollection', |
| 101 | 'odata', |
| 102 | 'odata-v4', |
| 103 | 'redfish-error', |
| 104 | 'redfish-payload-annotations', |
| 105 | 'redfish-schema', |
| 106 | 'redfish-schema-v1', |
| 107 | ] |
| 108 | |
Ed Tanous | 683f727 | 2018-07-26 12:47:19 -0700 | [diff] [blame] | 109 | SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) |
| 110 | |
| 111 | proxies = { |
| 112 | 'https': os.environ.get("https_proxy", None) |
| 113 | } |
| 114 | |
Ed Tanous | cb10313 | 2019-10-08 11:34:22 -0700 | [diff] [blame] | 115 | r = requests.get( |
| 116 | 'https://www.dmtf.org/sites/default/files/standards/documents/' + |
| 117 | VERSION + |
| 118 | '.zip', |
| 119 | proxies=proxies) |
Ed Tanous | 683f727 | 2018-07-26 12:47:19 -0700 | [diff] [blame] | 120 | |
| 121 | r.raise_for_status() |
| 122 | |
| 123 | static_path = os.path.realpath(os.path.join(SCRIPT_DIR, "..", "static", |
| 124 | "redfish", "v1")) |
| 125 | |
| 126 | schema_path = os.path.join(static_path, "schema") |
| 127 | json_schema_path = os.path.join(static_path, "JsonSchemas") |
Ed Tanous | 118b1c7 | 2018-09-13 13:45:51 -0700 | [diff] [blame] | 128 | metadata_index_path = os.path.join(static_path, "$metadata", "index.xml") |
Ed Tanous | 683f727 | 2018-07-26 12:47:19 -0700 | [diff] [blame] | 129 | |
| 130 | zipBytesIO = BytesIO(r.content) |
| 131 | zip_ref = zipfile.ZipFile(zipBytesIO) |
| 132 | |
| 133 | # Remove the old files |
Szymon Dompke | d699cf9 | 2021-08-11 19:46:31 +0200 | [diff] [blame] | 134 | skip_prefixes = ('Oem') |
Ed Tanous | 683f727 | 2018-07-26 12:47:19 -0700 | [diff] [blame] | 135 | if os.path.exists(schema_path): |
Szymon Dompke | d699cf9 | 2021-08-11 19:46:31 +0200 | [diff] [blame] | 136 | files = [os.path.join(schema_path, f) for f in os.listdir(schema_path) |
| 137 | if not f.startswith(skip_prefixes)] |
James Feist | aee8d84 | 2018-09-10 16:07:40 -0700 | [diff] [blame] | 138 | for f in files: |
| 139 | os.remove(f) |
Ed Tanous | 683f727 | 2018-07-26 12:47:19 -0700 | [diff] [blame] | 140 | if os.path.exists(json_schema_path): |
Szymon Dompke | d699cf9 | 2021-08-11 19:46:31 +0200 | [diff] [blame] | 141 | files = [os.path.join(json_schema_path, f) for f in |
| 142 | os.listdir(json_schema_path) if not f.startswith(skip_prefixes)] |
Ed Tanous | 118b1c7 | 2018-09-13 13:45:51 -0700 | [diff] [blame] | 143 | for f in files: |
| 144 | if (os.path.isfile(f)): |
| 145 | os.remove(f) |
| 146 | else: |
| 147 | shutil.rmtree(f) |
| 148 | os.remove(metadata_index_path) |
Ed Tanous | 683f727 | 2018-07-26 12:47:19 -0700 | [diff] [blame] | 149 | |
Ed Tanous | 118b1c7 | 2018-09-13 13:45:51 -0700 | [diff] [blame] | 150 | if not os.path.exists(schema_path): |
| 151 | os.makedirs(schema_path) |
| 152 | if not os.path.exists(json_schema_path): |
| 153 | os.makedirs(json_schema_path) |
Ed Tanous | 683f727 | 2018-07-26 12:47:19 -0700 | [diff] [blame] | 154 | |
Ed Tanous | 118b1c7 | 2018-09-13 13:45:51 -0700 | [diff] [blame] | 155 | with open(metadata_index_path, 'w') as metadata_index: |
| 156 | |
| 157 | metadata_index.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") |
| 158 | metadata_index.write( |
Ed Tanous | f395daa | 2021-08-02 08:56:24 -0700 | [diff] [blame] | 159 | "<edmx:Edmx xmlns:edmx=" |
| 160 | "\"http://docs.oasis-open.org/odata/ns/edmx\"" |
| 161 | " Version=\"4.0\">\n") |
Ed Tanous | 118b1c7 | 2018-09-13 13:45:51 -0700 | [diff] [blame] | 162 | |
| 163 | for zip_filepath in zip_ref.namelist(): |
Gunnar Mills | 60c922d | 2021-12-01 09:28:53 -0600 | [diff] [blame] | 164 | if zip_filepath.startswith('csdl/') and \ |
Ed Tanous | f395daa | 2021-08-02 08:56:24 -0700 | [diff] [blame] | 165 | (zip_filepath != VERSION + "/csdl/") and \ |
Gunnar Mills | 60c922d | 2021-12-01 09:28:53 -0600 | [diff] [blame] | 166 | (zip_filepath != "csdl/"): |
Ed Tanous | 118b1c7 | 2018-09-13 13:45:51 -0700 | [diff] [blame] | 167 | filename = os.path.basename(zip_filepath) |
Gunnar Mills | 349a2ac | 2021-01-20 22:29:16 -0600 | [diff] [blame] | 168 | |
| 169 | # filename looks like Zone_v1.xml |
| 170 | filenamesplit = filename.split("_") |
| 171 | if filenamesplit[0] not in include_list: |
| 172 | print("excluding schema: " + filename) |
| 173 | continue |
| 174 | |
Ed Tanous | f395daa | 2021-08-02 08:56:24 -0700 | [diff] [blame] | 175 | with open(os.path.join(schema_path, filename), 'wb') as schema_out: |
Ed Tanous | 118b1c7 | 2018-09-13 13:45:51 -0700 | [diff] [blame] | 176 | |
| 177 | metadata_index.write( |
Ed Tanous | cb10313 | 2019-10-08 11:34:22 -0700 | [diff] [blame] | 178 | " <edmx:Reference Uri=\"/redfish/v1/schema/" + |
| 179 | filename + |
| 180 | "\">\n") |
Ed Tanous | 118b1c7 | 2018-09-13 13:45:51 -0700 | [diff] [blame] | 181 | |
| 182 | content = zip_ref.read(zip_filepath) |
Ed Tanous | cb10313 | 2019-10-08 11:34:22 -0700 | [diff] [blame] | 183 | content = content.replace(b'\r\n', b'\n') |
Ed Tanous | 118b1c7 | 2018-09-13 13:45:51 -0700 | [diff] [blame] | 184 | xml_root = ET.fromstring(content) |
Ed Tanous | f395daa | 2021-08-02 08:56:24 -0700 | [diff] [blame] | 185 | edmx = "{http://docs.oasis-open.org/odata/ns/edmx}" |
Szymon Dompke | d699cf9 | 2021-08-11 19:46:31 +0200 | [diff] [blame] | 186 | edm = "{http://docs.oasis-open.org/odata/ns/edm}" |
Ed Tanous | 118b1c7 | 2018-09-13 13:45:51 -0700 | [diff] [blame] | 187 | for edmx_child in xml_root: |
Ed Tanous | f395daa | 2021-08-02 08:56:24 -0700 | [diff] [blame] | 188 | if edmx_child.tag == edmx + "DataServices": |
Ed Tanous | 118b1c7 | 2018-09-13 13:45:51 -0700 | [diff] [blame] | 189 | for data_child in edmx_child: |
Szymon Dompke | d699cf9 | 2021-08-11 19:46:31 +0200 | [diff] [blame] | 190 | if data_child.tag == edm + "Schema": |
Ed Tanous | 118b1c7 | 2018-09-13 13:45:51 -0700 | [diff] [blame] | 191 | namespace = data_child.attrib["Namespace"] |
| 192 | if namespace.startswith("RedfishExtensions"): |
| 193 | metadata_index.write( |
Ed Tanous | f395daa | 2021-08-02 08:56:24 -0700 | [diff] [blame] | 194 | " " |
| 195 | "<edmx:Include Namespace=\"" + |
| 196 | namespace + |
| 197 | "\" Alias=\"Redfish\"/>\n" |
| 198 | ) |
Ed Tanous | 118b1c7 | 2018-09-13 13:45:51 -0700 | [diff] [blame] | 199 | |
| 200 | else: |
| 201 | metadata_index.write( |
Ed Tanous | f395daa | 2021-08-02 08:56:24 -0700 | [diff] [blame] | 202 | " " |
| 203 | "<edmx:Include Namespace=\"" |
| 204 | + namespace + "\"/>\n" |
| 205 | ) |
| 206 | schema_out.write(content) |
Ed Tanous | 118b1c7 | 2018-09-13 13:45:51 -0700 | [diff] [blame] | 207 | metadata_index.write(" </edmx:Reference>\n") |
| 208 | |
Ed Tanous | f395daa | 2021-08-02 08:56:24 -0700 | [diff] [blame] | 209 | metadata_index.write(" <edmx:DataServices>\n" |
| 210 | " <Schema " |
| 211 | "xmlns=\"http://docs.oasis-open.org/odata/ns/edm\" " |
| 212 | "Namespace=\"Service\">\n" |
| 213 | " <EntityContainer Name=\"Service\" " |
| 214 | "Extends=\"ServiceRoot.v1_0_0.ServiceContainer\"/>\n" |
| 215 | " </Schema>\n" |
| 216 | " </edmx:DataServices>\n" |
| 217 | ) |
Ed Tanous | cb10313 | 2019-10-08 11:34:22 -0700 | [diff] [blame] | 218 | # TODO:Issue#32 There's a bug in the script that currently deletes this |
Asmitha Karunanithi | d337bb7 | 2020-09-21 10:34:02 -0500 | [diff] [blame] | 219 | # schema (because it's an OEM schema). Because it's the only six, and we |
Ed Tanous | cb10313 | 2019-10-08 11:34:22 -0700 | [diff] [blame] | 220 | # don't update schemas very often, we just manually fix it. Need a |
| 221 | # permanent fix to the script. |
| 222 | metadata_index.write( |
| 223 | " <edmx:Reference Uri=\"/redfish/v1/schema/OemManager_v1.xml\">\n") |
Marri Devender Rao | d45d2d0 | 2019-01-21 10:11:34 -0600 | [diff] [blame] | 224 | metadata_index.write(" <edmx:Include Namespace=\"OemManager\"/>\n") |
| 225 | metadata_index.write(" </edmx:Reference>\n") |
Gunnar Mills | 2077899 | 2020-02-06 16:36:47 -0600 | [diff] [blame] | 226 | |
| 227 | metadata_index.write( |
Ed Tanous | f395daa | 2021-08-02 08:56:24 -0700 | [diff] [blame] | 228 | " <edmx:Reference Uri=\"" |
| 229 | "/redfish/v1/schema/OemComputerSystem_v1.xml\">\n") |
| 230 | metadata_index.write( |
| 231 | " <edmx:Include Namespace=\"OemComputerSystem\"/>\n") |
Gunnar Mills | 2077899 | 2020-02-06 16:36:47 -0600 | [diff] [blame] | 232 | metadata_index.write(" </edmx:Reference>\n") |
| 233 | |
| 234 | metadata_index.write( |
Ed Tanous | f395daa | 2021-08-02 08:56:24 -0700 | [diff] [blame] | 235 | " <edmx:Reference Uri=\"" |
| 236 | "/redfish/v1/schema/OemVirtualMedia_v1.xml\">\n") |
| 237 | metadata_index.write( |
| 238 | " <edmx:Include Namespace=\"OemVirtualMedia\"/>\n") |
| 239 | metadata_index.write( |
| 240 | " <edmx:Include Namespace=\"OemVirtualMedia.v1_0_0\"/>\n") |
Gunnar Mills | 2077899 | 2020-02-06 16:36:47 -0600 | [diff] [blame] | 241 | metadata_index.write(" </edmx:Reference>\n") |
| 242 | |
| 243 | metadata_index.write( |
Ed Tanous | f395daa | 2021-08-02 08:56:24 -0700 | [diff] [blame] | 244 | " <edmx:Reference Uri=\"" |
| 245 | "/redfish/v1/schema/OemAccountService_v1.xml\">\n") |
| 246 | metadata_index.write( |
| 247 | " <edmx:Include Namespace=\"OemAccountService\"/>\n") |
| 248 | metadata_index.write( |
| 249 | " <edmx:Include Namespace=\"OemAccountService.v1_0_0\"/>\n") |
Gunnar Mills | 2077899 | 2020-02-06 16:36:47 -0600 | [diff] [blame] | 250 | metadata_index.write(" </edmx:Reference>\n") |
| 251 | |
Ravi Teja | e7d68c3 | 2020-03-15 13:30:41 -0500 | [diff] [blame] | 252 | metadata_index.write( |
Sunitha Harish | 9dc5074 | 2020-05-11 00:10:20 -0500 | [diff] [blame] | 253 | " <edmx:Reference Uri=\"/redfish/v1/schema/OemSession_v1.xml\">\n") |
| 254 | metadata_index.write(" <edmx:Include Namespace=\"OemSession\"/>\n") |
Ed Tanous | f395daa | 2021-08-02 08:56:24 -0700 | [diff] [blame] | 255 | metadata_index.write( |
| 256 | " <edmx:Include Namespace=\"OemSession.v1_0_0\"/>\n") |
Sunitha Harish | 9dc5074 | 2020-05-11 00:10:20 -0500 | [diff] [blame] | 257 | metadata_index.write(" </edmx:Reference>\n") |
| 258 | |
Ed Tanous | 118b1c7 | 2018-09-13 13:45:51 -0700 | [diff] [blame] | 259 | metadata_index.write("</edmx:Edmx>\n") |
Ed Tanous | 683f727 | 2018-07-26 12:47:19 -0700 | [diff] [blame] | 260 | |
| 261 | schema_files = {} |
| 262 | for zip_filepath in zip_ref.namelist(): |
Gunnar Mills | 60c922d | 2021-12-01 09:28:53 -0600 | [diff] [blame] | 263 | if zip_filepath.startswith(os.path.join('json-schema/')): |
Ed Tanous | 683f727 | 2018-07-26 12:47:19 -0700 | [diff] [blame] | 264 | filename = os.path.basename(zip_filepath) |
| 265 | filenamesplit = filename.split(".") |
Gunnar Mills | 349a2ac | 2021-01-20 22:29:16 -0600 | [diff] [blame] | 266 | |
| 267 | # exclude schemas again to save flash space |
| 268 | if filenamesplit[0] not in include_list: |
| 269 | continue |
| 270 | |
Ed Tanous | 683f727 | 2018-07-26 12:47:19 -0700 | [diff] [blame] | 271 | if len(filenamesplit) == 3: |
| 272 | thisSchemaVersion = schema_files.get(filenamesplit[0], None) |
Ed Tanous | cb10313 | 2019-10-08 11:34:22 -0700 | [diff] [blame] | 273 | if thisSchemaVersion is None: |
Ed Tanous | 683f727 | 2018-07-26 12:47:19 -0700 | [diff] [blame] | 274 | schema_files[filenamesplit[0]] = filenamesplit[1] |
| 275 | else: |
| 276 | # need to see if we're a newer version. |
| 277 | if list(map(int, filenamesplit[1][1:].split("_"))) > list(map( |
| 278 | int, thisSchemaVersion[1:].split("_"))): |
| 279 | schema_files[filenamesplit[0]] = filenamesplit[1] |
| 280 | |
| 281 | |
| 282 | for schema, version in schema_files.items(): |
| 283 | basename = schema + "." + version + ".json" |
Gunnar Mills | 60c922d | 2021-12-01 09:28:53 -0600 | [diff] [blame] | 284 | zip_filepath = os.path.join("json-schema", basename) |
Ed Tanous | 683f727 | 2018-07-26 12:47:19 -0700 | [diff] [blame] | 285 | schemadir = os.path.join(json_schema_path, schema) |
| 286 | os.makedirs(schemadir) |
Marri Devender Rao | d45d2d0 | 2019-01-21 10:11:34 -0600 | [diff] [blame] | 287 | location_json = OrderedDict() |
| 288 | location_json["Language"] = "en" |
| 289 | location_json["PublicationUri"] = ( |
| 290 | "http://redfish.dmtf.org/schemas/v1/" + schema + ".json") |
| 291 | location_json["Uri"] = ( |
Ed Tanous | 63faafa | 2019-01-03 14:09:56 -0800 | [diff] [blame] | 292 | "/redfish/v1/JsonSchemas/" + schema + "/" + schema + ".json") |
Ed Tanous | 118b1c7 | 2018-09-13 13:45:51 -0700 | [diff] [blame] | 293 | |
Marri Devender Rao | d45d2d0 | 2019-01-21 10:11:34 -0600 | [diff] [blame] | 294 | index_json = OrderedDict() |
Ed Tanous | f395daa | 2021-08-02 08:56:24 -0700 | [diff] [blame] | 295 | index_json["@odata.context"] = \ |
| 296 | "/redfish/v1/$metadata#JsonSchemaFile.JsonSchemaFile" |
Ed Tanous | 63faafa | 2019-01-03 14:09:56 -0800 | [diff] [blame] | 297 | index_json["@odata.id"] = "/redfish/v1/JsonSchemas/" + schema |
Marri Devender Rao | d45d2d0 | 2019-01-21 10:11:34 -0600 | [diff] [blame] | 298 | index_json["@odata.type"] = "#JsonSchemaFile.v1_0_2.JsonSchemaFile" |
| 299 | index_json["Name"] = schema + " Schema File" |
| 300 | index_json["Schema"] = "#" + schema + "." + schema |
Ed Tanous | cb10313 | 2019-10-08 11:34:22 -0700 | [diff] [blame] | 301 | index_json["Description"] = schema + " Schema File Location" |
Marri Devender Rao | d45d2d0 | 2019-01-21 10:11:34 -0600 | [diff] [blame] | 302 | index_json["Id"] = schema |
Ed Tanous | cb10313 | 2019-10-08 11:34:22 -0700 | [diff] [blame] | 303 | index_json["Languages"] = ["en"] |
Marri Devender Rao | d45d2d0 | 2019-01-21 10:11:34 -0600 | [diff] [blame] | 304 | index_json["Languages@odata.count"] = 1 |
Ed Tanous | cb10313 | 2019-10-08 11:34:22 -0700 | [diff] [blame] | 305 | index_json["Location"] = [location_json] |
Marri Devender Rao | d45d2d0 | 2019-01-21 10:11:34 -0600 | [diff] [blame] | 306 | index_json["Location@odata.count"] = 1 |
Ed Tanous | 118b1c7 | 2018-09-13 13:45:51 -0700 | [diff] [blame] | 307 | |
| 308 | with open(os.path.join(schemadir, "index.json"), 'w') as schema_file: |
| 309 | json.dump(index_json, schema_file, indent=4) |
| 310 | with open(os.path.join(schemadir, schema + ".json"), 'wb') as schema_file: |
Ed Tanous | cb10313 | 2019-10-08 11:34:22 -0700 | [diff] [blame] | 311 | schema_file.write(zip_ref.read(zip_filepath).replace(b'\r\n', b'\n')) |
Ed Tanous | 683f727 | 2018-07-26 12:47:19 -0700 | [diff] [blame] | 312 | |
| 313 | with open(os.path.join(json_schema_path, "index.json"), 'w') as index_file: |
Ed Tanous | 6f56d0c | 2019-05-03 17:15:41 -0700 | [diff] [blame] | 314 | members = [{"@odata.id": "/redfish/v1/JsonSchemas/" + schema} |
Ed Tanous | 683f727 | 2018-07-26 12:47:19 -0700 | [diff] [blame] | 315 | for schema in schema_files] |
| 316 | |
| 317 | members.sort(key=lambda x: x["@odata.id"]) |
| 318 | |
| 319 | indexData = OrderedDict() |
| 320 | |
| 321 | indexData["@odata.id"] = "/redfish/v1/JsonSchemas" |
| 322 | indexData["@odata.context"] = ("/redfish/v1/$metadata" |
| 323 | "#JsonSchemaFileCollection." |
| 324 | "JsonSchemaFileCollection") |
| 325 | indexData["@odata.type"] = ("#JsonSchemaFileCollection." |
| 326 | "JsonSchemaFileCollection") |
| 327 | indexData["Name"] = "JsonSchemaFile Collection" |
| 328 | indexData["Description"] = "Collection of JsonSchemaFiles" |
| 329 | indexData["Members@odata.count"] = len(schema_files) |
| 330 | indexData["Members"] = members |
| 331 | |
| 332 | json.dump(indexData, index_file, indent=2) |
| 333 | |
| 334 | zip_ref.close() |