Loading __pycache__/validateInventory.cpython-312.pyc +134 B (17.4 KiB) File changed.No diff preview for this file type. View original file View changed file validateInventory.py +48 −41 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ def check_hardware_inventory(xml_reply): if len(cls)==0: actual_params = actual_params - 1 #return "Component class not found" if len(hw_rev)>0: if len(hw_rev)==0: actual_params = actual_params - 1 #return "hw rev not found" if len(parent_rel_pos)==0: Loading Loading @@ -286,23 +286,23 @@ def check_svc_inventory(xml_reply): #return "mssing bridge's info" actual_params = actual_params - 4 + len(name) + len(address) + len(bridge_type) + len(components) for component in components: expected_params = expected_params + 8 actual_params = actual_params + 8 expected_params = expected_params + 6 actual_params = actual_params + 6 name = component.findall(".//ns0:name", namespaces={"ns0": "urn:ieee:std:802.1Q:yang:ieee802-dot1q-bridge"}) id = component.findall(".//ns0:id", namespaces={"ns0": "urn:ieee:std:802.1Q:yang:ieee802-dot1q-bridge"}) type = component.findall(".//ns0:type", namespaces={"ns0": "urn:ieee:std:802.1Q:yang:ieee802-dot1q-bridge"}) bridge_port = component.findall(".//ns0:bridge-port", namespaces={"ns0": "urn:ieee:std:802.1Q:yang:ieee802-dot1q-bridge"}) filtering_database = component.findall(".//ns0:filtering-database", namespaces={"ns0": "urn:ieee:std:802.1Q:yang:ieee802-dot1q-bridge"}) bridge_vlan = component.findall(".//ns0:bridge-vlan", namespaces={"ns0": "urn:ieee:std:802.1Q:yang:ieee802-dot1q-bridge"}) vlan_reg_entry = filtering_database[0].findall(".//ns0:vlan-registration-entry", namespaces={"ns0": "urn:ieee:std:802.1Q:yang:ieee802-dot1q-bridge"}) vlans = bridge_vlan[0].findall(".//ns0:vlan", namespaces={"ns0": "urn:ieee:std:802.1Q:yang:ieee802-dot1q-bridge"}) if len(name)==0 or len(id)==0 or len(type)==0 or len(bridge_port)==0 or len(filtering_database)==0 or len(bridge_vlan)==0: #return "missing components's info" actual_params = actual_params - 6 + len(name) + len(id) + len(type) + len(bridge_port) + len(filtering_database) + len(bridge_vlan) if len(vlan_reg_entry)==0: actual_params = actual_params - 1 if len(vlans)==0: actual_params = actual_params - 1 for db in filtering_database: expected_params = expected_params + 1 #if there's the filtering db I expect to see also vlan_reg_entry vlan_reg_entry = db.findall(".//ns0:vlan-registration-entry", namespaces={"ns0": "urn:ieee:std:802.1Q:yang:ieee802-dot1q-bridge"}) if len(vlan_reg_entry)>0: actual_params = actual_params + 1 for v in vlan_reg_entry: actual_params = actual_params + 4 expected_params = expected_params + 4 Loading @@ -326,6 +326,12 @@ def check_svc_inventory(xml_reply): if len(port_ref)==0 or len(static_vlan_reg_entry)==0 or len(vlan_transmitted)==0 or len(registrar_admin_control)==0: #return "Missing data in port map" actual_params = actual_params - 4 + len(port_ref) + len(static_vlan_reg_entry) + len(vlan_transmitted) + len(registrar_admin_control) for br in bridge_vlan: expected_params = expected_params + 1 #if there's a bridge_vlan I also expect to see vlans vlans = br.findall(".//ns0:vlan", namespaces={"ns0": "urn:ieee:std:802.1Q:yang:ieee802-dot1q-bridge"}) if len(vlans)>0: actual_params = actual_params + 1 for vlan in vlans: expected_params = expected_params + 3 actual_params = actual_params + 3 Loading @@ -335,6 +341,7 @@ def check_svc_inventory(xml_reply): if len(vid)==0 or len(name)==0 or len(egress_ports)==0: #return "Missing data in bridge vlan" actual_params = actual_params - 3 + len(vid) + len(name) + len(egress_ports) if actual_params<expected_params: return "expected params = ",expected_params," got ", actual_params return "SUCCESS" No newline at end of file Loading
__pycache__/validateInventory.cpython-312.pyc +134 B (17.4 KiB) File changed.No diff preview for this file type. View original file View changed file
validateInventory.py +48 −41 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ def check_hardware_inventory(xml_reply): if len(cls)==0: actual_params = actual_params - 1 #return "Component class not found" if len(hw_rev)>0: if len(hw_rev)==0: actual_params = actual_params - 1 #return "hw rev not found" if len(parent_rel_pos)==0: Loading Loading @@ -286,23 +286,23 @@ def check_svc_inventory(xml_reply): #return "mssing bridge's info" actual_params = actual_params - 4 + len(name) + len(address) + len(bridge_type) + len(components) for component in components: expected_params = expected_params + 8 actual_params = actual_params + 8 expected_params = expected_params + 6 actual_params = actual_params + 6 name = component.findall(".//ns0:name", namespaces={"ns0": "urn:ieee:std:802.1Q:yang:ieee802-dot1q-bridge"}) id = component.findall(".//ns0:id", namespaces={"ns0": "urn:ieee:std:802.1Q:yang:ieee802-dot1q-bridge"}) type = component.findall(".//ns0:type", namespaces={"ns0": "urn:ieee:std:802.1Q:yang:ieee802-dot1q-bridge"}) bridge_port = component.findall(".//ns0:bridge-port", namespaces={"ns0": "urn:ieee:std:802.1Q:yang:ieee802-dot1q-bridge"}) filtering_database = component.findall(".//ns0:filtering-database", namespaces={"ns0": "urn:ieee:std:802.1Q:yang:ieee802-dot1q-bridge"}) bridge_vlan = component.findall(".//ns0:bridge-vlan", namespaces={"ns0": "urn:ieee:std:802.1Q:yang:ieee802-dot1q-bridge"}) vlan_reg_entry = filtering_database[0].findall(".//ns0:vlan-registration-entry", namespaces={"ns0": "urn:ieee:std:802.1Q:yang:ieee802-dot1q-bridge"}) vlans = bridge_vlan[0].findall(".//ns0:vlan", namespaces={"ns0": "urn:ieee:std:802.1Q:yang:ieee802-dot1q-bridge"}) if len(name)==0 or len(id)==0 or len(type)==0 or len(bridge_port)==0 or len(filtering_database)==0 or len(bridge_vlan)==0: #return "missing components's info" actual_params = actual_params - 6 + len(name) + len(id) + len(type) + len(bridge_port) + len(filtering_database) + len(bridge_vlan) if len(vlan_reg_entry)==0: actual_params = actual_params - 1 if len(vlans)==0: actual_params = actual_params - 1 for db in filtering_database: expected_params = expected_params + 1 #if there's the filtering db I expect to see also vlan_reg_entry vlan_reg_entry = db.findall(".//ns0:vlan-registration-entry", namespaces={"ns0": "urn:ieee:std:802.1Q:yang:ieee802-dot1q-bridge"}) if len(vlan_reg_entry)>0: actual_params = actual_params + 1 for v in vlan_reg_entry: actual_params = actual_params + 4 expected_params = expected_params + 4 Loading @@ -326,6 +326,12 @@ def check_svc_inventory(xml_reply): if len(port_ref)==0 or len(static_vlan_reg_entry)==0 or len(vlan_transmitted)==0 or len(registrar_admin_control)==0: #return "Missing data in port map" actual_params = actual_params - 4 + len(port_ref) + len(static_vlan_reg_entry) + len(vlan_transmitted) + len(registrar_admin_control) for br in bridge_vlan: expected_params = expected_params + 1 #if there's a bridge_vlan I also expect to see vlans vlans = br.findall(".//ns0:vlan", namespaces={"ns0": "urn:ieee:std:802.1Q:yang:ieee802-dot1q-bridge"}) if len(vlans)>0: actual_params = actual_params + 1 for vlan in vlans: expected_params = expected_params + 3 actual_params = actual_params + 3 Loading @@ -335,6 +341,7 @@ def check_svc_inventory(xml_reply): if len(vid)==0 or len(name)==0 or len(egress_ports)==0: #return "Missing data in bridge vlan" actual_params = actual_params - 3 + len(vid) + len(name) + len(egress_ports) if actual_params<expected_params: return "expected params = ",expected_params," got ", actual_params return "SUCCESS" No newline at end of file