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