Skip to content
Snippets Groups Projects
Select Git revision
  • a3b092b7fcfbfce44edc1beb7eced57b528ec9a1
  • master default
  • cnit_ofc26
  • feat/344-implement-a-new-firewall-agent-controllable-through-restconf-openconfig
  • feat/343-integration-of-mimir-deployment-in-production-environment
  • ofc_polimi
  • feat/305-cttc-enhanced-netconf-openconfig-sbi-driver-for-dscm-pluggables
  • feat/306-cttc-enhanced-restconf-based-openconfig-nbi-for-dscm-pluggables
  • feat/301-cttc-dscm-pluggables
  • CTTC-IMPLEMENT-NBI-CONNECTOR-NOS-ZTP
  • CTTC-TEST-SMARTNICS-6GMICROSDN-ZTP
  • develop protected
  • feat/327-tid-new-service-to-ipowdm-controller-to-manage-transceivers-configuration-on-external-agent
  • cnit_tapi
  • feat/330-tid-pcep-component
  • feat/tid-newer-pcep-component
  • feat/116-ubi-updates-in-telemetry-backend-to-support-p4-in-band-network-telemetry
  • feat/292-cttc-implement-integration-test-for-ryu-openflow
  • cnit-p2mp-premerge
  • feat/325-tid-nbi-e2e-to-manage-e2e-path-computation
  • feat/326-tid-external-management-of-devices-telemetry-nbi
  • feat/324-tid-nbi-ietf_l3vpn-deploy-fail
  • v5.0.0 protected
  • v4.0.0 protected
  • demo-dpiab-eucnc2024
  • v3.0.0 protected
  • v2.1.0 protected
  • v2.0.0 protected
  • v1.0.0 protected
29 results

PytestGenerateTests.py

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    json_loader.py 1.54 KiB
    # Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
    
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    
    #      http://www.apache.org/licenses/LICENSE-2.0
    
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    
    import json
    
    def getInterfaceFromJson():
        json_file = open('interfaces.json', 'r',encoding='utf-8')
        interface_data = json.load(json_file)
        return interface_data
    
    def getInterfaceFromNodeNames(json_file,node_name_src,node_name_dst):
    
        interface_src=[]
        interface_dst=[]
        for device in json_file['devices']:
            print("dev: %s",device.keys())
            if device['name'] == node_name_src:
                interface_src=list(device['links'].keys())[list(device['links'].values()).index(node_name_dst)]
            if device['name'] == node_name_dst:
                interface_dst=list(device['links'].keys())[list(device['links'].values()).index(node_name_src)]
    
        return interface_src,interface_dst
        
    
    if __name__ == "__main__":
        data=getInterfaceFromJson()
        print("data: %s",data['devices'])
        # for device in data['devices']:
        #     print(device['interfaces'].keys())
    
        print(getInterfaceFromNodeNames(data,"HL2-2-1","HL2-2-2"))