def parse_external_rspec(rspec):
    
    root = et.fromstring(rspec)
    
    switch_elems = root.findall(".//%s" % SWITCH_TAG)
    switches = {}
    for switch_elem in switch_elems:
        urn = switch_elem.get(URN)
        dpid = _urn_to_dpid(urn)
        switches[dpid] = []
    
    port_elems = root.findall(".//%s" % PORT_TAG)
    for port_elem in port_elems:
        urn = port_elem.get(URN)
        dpid, port = _urn_to_port(urn)
        try:
            switches[dpid].append(port)
        except KeyError:
            raise Exception("No switch with datapath ID %s found"
                            " for port with URN %s" % (dpid, urn))
        
    link_elems = root.findall(".//%s" % LINK_TAG)
    links = []
    for link_elem in link_elems:
        src_urn = link_elem.get(SRC_URN)
        dst_urn = link_elem.get(DST_URN)
        src_dpid, src_port = _urn_to_port(src_urn)
        dst_dpid, dst_port = _urn_to_port(dst_urn)
        links.append((src_dpid, src_port, dst_dpid, dst_port, {}))
        
    return switches, links
Parse the given rspec and create dicts of the given switches.
dataset/ETHPy150Open fp7-ofelia/ocf/expedient/src/python/plugins/openflow/plugin/gapi/rspec.py/parse_external_rspec