def validateYang(self, topic, jsonStr): # # Get the mappings # mappingDetails = jsonToYang.getMappingDetails(topic) yangJsonStr = jsonToYang.validateYang(mappingDetails, jsonStr) return yangJsonStr
def convertToYang(topic, jsonStr): jsonObj = json.loads(jsonStr) mappingDetails = jsonToYang.getMappingDetails(topic) yangStr = jsonToYang.convertToYangJsonStr(mappingDetails, jsonObj) #pprint.pprint(yangStr) return yangStr
# Copyright Verizon Inc. # Licensed under the terms of the Apache License 2.0 license. # See LICENSE file in project root for terms. import json import jsonToYang jsonStr = '{"data": [{"attributes": {"ip-address": "10.182.10.105", "id": "-4014091938995079370", "native-condition-type": "LOS_OTS", "manual-clearable": false, "state": "ACTIVE", "alarm-id": "-4014091938995079370", "ra-alarm-id": "0100001127-0008-0560", "mac-address": "40AB07220500", "additional-attrs": {"source": "6500:OPTMON-1-6-13", "direction": "RCV", "location": "NEND", "mode": "NONE", "aidtype": "OPTMON"}, "service-affection": "SERVICE_AFFECTING", "device-id": "f114lb1e-c6d4-3690-96ed-966af131822d", "number-of-occurances": 2, "first-raise-time": "2017-10-23T14:36:18:00Z", "node-type": "6500", "additional-text": "Loss of Signal", "resource": "OPTMON-1-6-13", "acknowledge-state": "NOT_ACKNOWLEDGED", "condition-severity": "MAJOR", "last-raise-time": "2017-10-25T18:35:55:00Z", "device-name": "PC0722CRFE", "partition": [], "node-id": "f490c132-9a26-4b01-babf-99dea16fb099", "affecte-inventory-ids": []}, "type": "FilteredAlarm", "id": "-4014091938995079370"}]}' jsonObj = json.loads(jsonStr) mappingDetails = jsonToYang.getMappingDetails("UT_ALARMS_CIENA") yangJsonStr = jsonToYang.convertToYangJsonStr(mappingDetails, jsonObj)
# Copyright Verizon Inc. # Licensed under the terms of the Apache License 2.0 license. # See LICENSE file in project root for terms. import json import jsonToYang import UTSEquipment #with open('CICHRBNC-0023_Equipment_Response.json') as json_file: with open('UTSEquipmentDetail2.json') as json_file: jsonObj = json.load(json_file) mappingDetails = jsonToYang.getMappingDetails("UTS_EQUIPMENT_API") if mappingDetails['isEquipmentTopic'] == 'true': yangJsonStr = UTSEquipment.convertToYangJsonStr(jsonObj) print(str(yangJsonStr))
def convertToYang(self, topic, jsonStr): jsonObj = json.loads(jsonStr) mappingDetails = jsonToYang.getMappingDetails(topic) yangStr = jsonToYang.convertToYangJsonStr(mappingDetails, jsonObj)
# Copyright Verizon Inc. # Licensed under the terms of the Apache License 2.0 license. # See LICENSE file in project root for terms. import json import jsonToYang with open('MSECisco.json') as json_file: jsonObj = json.load(json_file) print(json.dumps(jsonObj)) mappingDetails = jsonToYang.getMappingDetails("MSE_ALARMS_CISCO") if mappingDetails['isEquipmentTopic'] == 'false': yangJsonStr = jsonToYang.convertToYangJsonStr(mappingDetails, jsonObj)