def links(self): links_ = [] for l in self.rspec.iterchildren("{%s}link" % (self.none)): c_ = None component_manager = l.find("{%s}component_manager" % (self.none)) if component_manager is not None: c_ = component_manager.attrib.get("name") link_type = l.find("{%s}link_type" % (self.none)) if link_type is None: self.raise_exception("Link_type tag not found!") l_ = SELink(l.attrib.get("component_id"), link_type.attrib.get("name"), c_) self.__update_protogeni_cm_uuid(l, l_) for ref in l.iterchildren("{%s}interface_ref" % (self.none)): l_.add_interface_ref(ref.attrib.get("component_id")) for p in l.iterchildren("{%s}property" % (self.none)): l_.add_property(p.attrib.get("source_id"), p.attrib.get("dest_id"), p.attrib.get("capacity")) links_.append(l_.serialize()) return links_
def get_links(self, rspec): links_ = [] for l in rspec.findall(".//{%s}link" % (self.none)): manager_ = l.find("{%s}component_manager" % (self.none)) if manager_ is None: self.raise_exception("Component-Mgr tag not found in link!") if not self.check_se_link_resource(l, manager_): logger.info("Skipping this link, not a SE-res: %s", (l, )) continue type_ = l.find("{%s}link_type" % (self.none)) if type_ is None: self.raise_exception("Link-Type tag not found in link!") l_ = SELink(l.attrib.get("client_id"), type_.attrib.get("name"), manager_.attrib.get("name")) self.update_protogeni_cm_uuid(l, l_) [ l_.add_interface_ref(i.attrib.get("client_id")) for i in l.iterfind("{%s}interface_ref" % (self.none)) ] [ l_.add_property(p.attrib.get("source_id"), p.attrib.get("dest_id"), p.attrib.get("capacity")) for p in l.iterfind("{%s}property" % (self.none)) ] links_.append(l_.serialize()) return links_
def __create_link(self, if1, if2, vlan1, vlan2, sliver_id): """ Generates the SE link in a proper format: <urn_dpid_1>_<port1>_<dpid2>_<port2>_<vlan1>_<vlan2> """ i = if1.rindex("_") n1, num1 = if1[0:i], if1[i+1:len(if1)] i = if2.rindex("_") n2, num2 = if2[0:i], if2[i+1:len(if2)] dpid2 = n2[n2.rindex("+")+1:] cid = n1 + "_" + num1 + "_" + dpid2 + "_" + num2 logger.debug("cid=%s, node-id=%s, port-num1=%s, port-num2=%s" % (cid, n1, num1, num2,)) typee, cm_name = db_sync_manager.get_se_link_info(n1 + "_" + num1) l = SELink(cid, typee, cm_name, sliver=sliver_id) l.add_interface_ref(if1, vlan1) l.add_interface_ref(if2, vlan2) return l