def addAdDevice (rspec, dpid, active=True): switch_urn = generateSwitchComponentID(dpid) od = ET.SubElement(rspec, "{%s}datapath" % (OFNSv3)) od.attrib["component_id"] = switch_urn od.attrib["component_manager_id"] = getManagerID() od.attrib["dpid"] = dpid locdata = GeniDB.getLocationData(dpid, switch_urn) if locdata: ET.SubElement(od, "{%s}location" % (OFNSv3), country=locdata.country, latitude=locdata.lat, longitude=locdata.long) attachments = TopoDB.getDPIDAttachments(dpid) if active: ports = FV.getDevicePorts(dpid) for port in ports: if (port.features == None): p = ET.SubElement(od, "{%s}port" % (OFNSv3), num=str(port.num), name=port.name) else: p = ET.SubElement(od, "{%s}port" % (OFNSv3), num=str(port.num), name=port.name, features=port.features) for info in attachments.setdefault(port.name, []): a = ET.SubElement(p, "{%s}attachment" % (OFNSv3)) a.attrib["remote_component_id"] = info.remote_component_id a.attrib["remote_port"] = info.remote_port a.attrib["desc"] = info.desc
def __parse_openflowv3_datapath (self, dom): self.component_id = dom.get("component_id") cmid = dom.get("component_manager_id") if self.component_id.count(cmid[:-12]) != 1: raise ComponentManagerIDMismatch(self.component_id, cmid) if cmid != getManagerID(): raise UnknownComponentManagerID(self.component_id) self.dpid = GeniDB.getSwitchDPID(self.component_id) self.ports = set() for port in dom.findall('{%s}port' % (OFNSv3)): p = foam.openflow.types.Port() p.num = int(port.get("num")) p.dpid = self.dpid self.ports.add(p)
def __parse_openflowv3_datapath(self, dom): self.component_id = dom.get("component_id") cmid = dom.get("component_manager_id") if self.component_id.count(cmid[:-12]) != 1: raise ComponentManagerIDMismatch(self.component_id, cmid) if cmid != getManagerID(): raise UnknownComponentManagerID(self.component_id) self.dpid = GeniDB.getSwitchDPID(self.component_id) self.ports = set() for port in dom.findall('{%s}port' % (OFNSv3)): p = foam.openflow.types.Port() p.num = int(port.get("num")) p.dpid = self.dpid self.ports.add(p)
def addAdDevice(rspec, dpid, active=True): switch_urn = generateSwitchComponentID(dpid) od = ET.SubElement(rspec, "{%s}datapath" % (OFNSv3)) od.attrib["component_id"] = switch_urn od.attrib["component_manager_id"] = getManagerID() od.attrib["dpid"] = dpid locdata = GeniDB.getLocationData(dpid, switch_urn) if locdata: ET.SubElement(od, "{%s}location" % (OFNSv3), country=locdata.country, latitude=locdata.lat, longitude=locdata.long) attachments = TopoDB.getDPIDAttachments(dpid) if active: ports = FV.getDevicePorts(dpid) for port in ports: if (port.features == None): p = ET.SubElement(od, "{%s}port" % (OFNSv3), num=str(port.num), name=port.name) else: p = ET.SubElement(od, "{%s}port" % (OFNSv3), num=str(port.num), name=port.name, features=port.features) for info in attachments.setdefault(port.name, []): a = ET.SubElement(p, "{%s}attachment" % (OFNSv3)) a.attrib["remote_component_id"] = info.remote_component_id a.attrib["remote_port"] = info.remote_port a.attrib["desc"] = info.desc