def add_vlan_to_link(self, link_cid, iface_cid): """ Add vlan to component ID of link's interface when using a newly formatted RSpec. This format is used: "urn+...+datapath+<dpid>_<port>+vlan=<vlan>. """ if "vlan=" in link_cid: urn_src, vlan_src, urn_dst, vlan_dst = URNUtils.get_fields_from_domain_link_id(link_cid) if_vlan_pairs = {urn_src: vlan_src, urn_dst: vlan_dst} # if_dpid = URNUtils.get_datapath_from_datapath_id(if_cid) if_dpid, if_port = URNUtils.get_datapath_and_port_from_datapath_id(iface_cid) if_dpid_port = "%s_%s" % (if_dpid, if_port) for if_vlan in if_vlan_pairs.keys(): if if_dpid_port in if_vlan: iface_cid += "+vlan=%s" % if_vlan_pairs[if_vlan] break return iface_cid
def add_se_resources(self, slice_urn, nodes, links): """ Inserts one or more nodes with SERM resources information. @param slice_urn URN identifier of a given slice @param nodes Structure containing a list of SERM nodes and its attributes @param links Structure containing a list of SERM links and its attributes """ if slice_urn not in self.__stored: logger.error("Unable to find Topology info from %s!" % slice_urn) return topology = self.__stored.get(slice_urn) logger.debug("dd_se_resources Nodes=%d" % (len(nodes),)) for n in nodes: logger.debug("Node=%s" % (n,)) node_ = etree.SubElement( topology, "node", id=n.get("component_id"), type=self.SE_LINK_TYPE) if n.get("host_name"): self.__add_snmp_management(node_, n.get("host_name")) for ifs in n.get("interfaces"): interface_ = etree.SubElement( node_, "interface", id=ifs.get("component_id")) # Try to extract port info from the component id! self.__add_se_port_from_interface( ifs.get("component_id"), interface_) # vlan = ifs.get("vlan")[0].get("tag") # vlan1, vlan2 = l.get("component_id") # m_ = etree.SubElement(node_, "match") # etree.SubElement(m_, "vlan", start=vlan, end=vlan) for l in links: # FIXME: incorrect comparison link_id = l.get("component_id") if link_id == ifs.get("component_id"): urn_src, vlan_src, urn_dst, vlan_dst = \ URNUtils.get_fields_from_domain_link_id(link_id) m_ = etree.SubElement(node_, "match") etree.SubElement(m_, "vlan", start=vlan_src, end=vlan_src) m_ = etree.SubElement(node_, "match") etree.SubElement(m_, "vlan", start=vlan_dst, end=vlan_dst) logger.debug("add_se_resources Links=%d" % (len(links),)) for l in links: logger.debug("Link=%s" % (l,)) if len(l.get("interface_ref")) != 2: logger.warning("Unable to manage extra-list of info (%d)!" % len(l.get("interface_ref"))) continue # is it really necessary to put bidirectional links? # self.__add_link_info(topology, # l.get("interface_ref")[0].get("component_id"), # l.get("interface_ref")[1].get("component_id"), # l.get("link_type")) # store the values for the virtual island-to-island link self.__se_links.append( {'id': l.get("component_id"), 'source': l.get("interface_ref")[0].get("component_id"), 'destination': l.get("interface_ref")[1].get("component_id")}) # we need to add "special" links here: SE-to-SDN, SE-to-TN # and an "abstract" link self.__add_se_external_link_info( topology, [l.get("interface_ref")[0].get("component_id"), l.get("interface_ref")[1].get("component_id")])