def _add_se_link(self, link): # Special case: links to be filtered in POST {(M)RO -> (M)MS} SE_FILTERED_LINKS = ["*"] interfaces_cid = [ i.get("component_id") for i in link.get("interface_ref") ] interface_cid_in_filter = [ f for f in SE_FILTERED_LINKS if f in interfaces_cid ] # Avoid reinserting existing link tags in the topology if MonitoringUtils.check_existing_tag_in_topology( self.topology, "link", "lan", link.get("component_id")): return if not interface_cid_in_filter: l = etree.SubElement(self.topology, "link") # NOTE that this cannot be empty l.set("type", MonitoringUtilsLinks._translate_link_type(link)) link_id = "" links = link.get("interface_ref") for link in links: # SE link iface = etree.SubElement(l, "interface_ref") iface.set("client_id", link.get("component_id")) # - Prepare link ID for SERM-SDNRM link link_id = MonitoringUtilsLinks.get_id_for_link_serm_sdnrm_tnrm( links) l.set("id", link_id)
def _add_com_link(self, link, parent_node=None): if parent_node is None: parent_node = self.topology logger.debug("com-links=%s" % (link, )) #l = etree.SubElement(parent_node, "link") l = etree.Element("link") # NOTE that this cannot be empty l.set("type", MonitoringUtilsLinks._translate_link_type(link)) link_id = "" links = link.get("links") link_exists = False for link_i in links: if MonitoringUtils.check_existing_tag_in_topology( parent_node, "link", "lan", [link_i.get("source_id"), link_i.get("dest_id")]): link_exists = True break # Modify link on-the-fly to add the DPID port as needed link_i = MonitoringUtilsLinks._set_dpid_port_from_link( link.get("component_id"), link_i) # Source iface_source = etree.SubElement(l, "interface_ref") iface_source.set("client_id", link_i.get("source_id")) # Destination iface_dest = etree.SubElement(l, "interface_ref") iface_dest.set("client_id", link_i.get("dest_id")) # - Prepare link ID for CRM-SDNRM link link_id = MonitoringUtilsLinks.get_id_for_link_crm_sdnrm(link_i) # Finally, add it as subelement if not link_exists: l.set("id", link_id) parent_node.append(l)
def _add_sdn_link(self, link, parent_node=None): if parent_node is None: parent_node = self.topology auth1 = link.get("dpids")[0].get("component_manager_id").replace("authority+cm", "datapath") dpid1 = auth1 + "+" + link.get("dpids")[0].get("dpid") + "_" + link.get("ports")[0].get("port_num") auth2 = link.get("dpids")[1].get("component_manager_id").replace("authority+cm", "datapath") dpid2 = auth2 + "+" + link.get("dpids")[1].get("dpid") + "_" + link.get("ports")[1].get("port_num") if MonitoringUtils.check_existing_tag_in_topology( parent_node, "link", "lan", [dpid1, dpid2]): return l = etree.SubElement(parent_node, "link") # NOTE that this cannot be empty l.set("type", MonitoringUtilsLinks._translate_link_type(link)) link_id = "" ports = link.get("ports") dpids = link.get("dpids") try: for dpid_port in zip(dpids, ports): iface = etree.SubElement(l, "interface_ref") dpid = dpid_port[0]["component_id"] port = dpid_port[1]["port_num"] iface.set("client_id", "%s_%s" % (dpid, port)) except Exception as e: logger.warning("Physical topology - Cannot add SDN interface %s. \ Details: %s" % (link.get("component_id", "(unknown)"), e)) try: # - Prepare link ID for SDNRM-SDNRM link link_id = MonitoringUtilsLinks.get_id_for_link_sdnrm_sdnrm(zip(dpids, ports)) l.set("id", link_id) except Exception as e: logger.warning("Physical topology - Cannot add SDN link ID %s. \ Details: %s" % (link.get("component_id", "(unknown)"), e))
def _add_com_link(self, link, parent_node=None): if parent_node is None: parent_node = self.topology logger.debug("com-links=%s" % (link,)) # l = etree.SubElement(parent_node, "link") l = etree.Element("link") # NOTE that this cannot be empty l.set("type", MonitoringUtilsLinks._translate_link_type(link)) link_id = "" links = link.get("links") link_exists = False for link_i in links: if MonitoringUtils.check_existing_tag_in_topology(parent_node, "link", "lan", [link_i.get("source_id"), link_i.get("dest_id")]): link_exists = True break # Modify link on-the-fly to add the DPID port as needed link_i = MonitoringUtilsLinks._set_dpid_port_from_link(link.get("component_id"), link_i) # Source iface_source = etree.SubElement(l, "interface_ref") iface_source.set("client_id", link_i.get("source_id")) # Destination iface_dest = etree.SubElement(l, "interface_ref") iface_dest.set("client_id", link_i.get("dest_id")) # - Prepare link ID for CRM-SDNRM link link_id = MonitoringUtilsLinks.get_id_for_link_crm_sdnrm(link_i) # Finally, add it as subelement if not link_exists: l.set("id", link_id) parent_node.append(l)
def _add_se_link(self, link): # Special case: links to be filtered in POST {(M)RO -> (M)MS} SE_FILTERED_LINKS = ["*"] interfaces_cid = [i.get("component_id") for i in link.get("interface_ref")] interface_cid_in_filter = [f for f in SE_FILTERED_LINKS if f in interfaces_cid] # Avoid reinserting existing link tags in the topology if MonitoringUtils.check_existing_tag_in_topology( self.topology, "link", "lan", link.get("component_id")): return if not interface_cid_in_filter: l = etree.SubElement(self.topology, "link") # NOTE that this cannot be empty l.set("type", MonitoringUtilsLinks._translate_link_type(link)) link_id = "" links = link.get("interface_ref") for link in links: # SE link iface = etree.SubElement(l, "interface_ref") iface.set("client_id", link.get("component_id")) # - Prepare link ID for SERM-SDNRM link link_id = MonitoringUtilsLinks.\ get_id_for_link_serm_sdnrm_tnrm(links) l.set("id", link_id)
def _add_sdn_link(self, link, parent_node=None): if parent_node is None: parent_node = self.topology auth1 = link.get("dpids")[0].get("component_manager_id").replace( "authority+cm", "datapath") dpid1 = auth1 + "+" + link.get("dpids")[0].get( "dpid") + "_" + link.get("ports")[0].get("port_num") auth2 = link.get("dpids")[1].get("component_manager_id").replace( "authority+cm", "datapath") dpid2 = auth2 + "+" + link.get("dpids")[1].get( "dpid") + "_" + link.get("ports")[1].get("port_num") if MonitoringUtils.check_existing_tag_in_topology( parent_node, "link", "lan", [dpid1, dpid2]): return l = etree.SubElement(parent_node, "link") # NOTE that this cannot be empty l.set("type", MonitoringUtilsLinks._translate_link_type(link)) link_id = "" ports = link.get("ports") dpids = link.get("dpids") try: for dpid_port in zip(dpids, ports): iface = etree.SubElement(l, "interface_ref") dpid = dpid_port[0]["component_id"] port = dpid_port[1]["port_num"] iface.set("client_id", "%s_%s" % (dpid, port)) except Exception as e: logger.warning( "Physical topology - Cannot add SDN interface %s. Details: %s" % (link.get("component_id", "(unknown)"), e)) try: # - Prepare link ID for SDNRM-SDNRM link link_id = MonitoringUtilsLinks.get_id_for_link_sdnrm_sdnrm( zip(dpids, ports)) l.set("id", link_id) except Exception as e: logger.warning( "Physical topology - Cannot add SDN link ID %s. Details: %s" % (link.get("component_id", "(unknown)"), e))