def getAdvertisement (): NSMAP = {None: "%s" % (PGNS), "xs" : "%s" % (XSNS), "openflow" : "%s" % (OFNSv3)} rspec = ET.Element("rspec", nsmap = NSMAP) rspec.attrib["{%s}schemaLocation" % (XSNS)] = PGNS + " " \ "http://www.geni.net/resources/rspec/3/ad.xsd " + \ OFNSv3 + " " \ "http://www.geni.net/resources/rspec/ext/openflow/3/of-ad.xsd" rspec.attrib["type"] = "advertisement" links = FV.getLinkList() devices = FV.getDeviceList() fvversion = FV.getFVVersion() db_devices = GeniDB.getDeviceSet() GeniDB.refreshDevices(devices) for dpid in devices: db_devices.discard(dpid) addAdDevice(rspec, dpid) for dpid in db_devices: addAdDevice(rspec, dpid, False) #getLinks START for link in links: addAdLink(rspec, link) #getLinks END xml = StringIO() ET.ElementTree(rspec).write(xml) return xml.getvalue()
def pub_get_switches(self, **kwargs): ''' Return the switches that the FlowVisor gives. Change to CH format. ''' complete_list = [] try: dpids = FV.getDeviceList() for d in dpids: FV.log.debug("XMLRPC:getDeviceInfo (%s)" % (d)) infos = [FV.xmlcall("getDeviceInfo", d) for d in dpids] #need to make it prettier :) switches = zip(dpids, infos) except Exception,e: import traceback traceback.print_exc() raise e
def pub_get_switches(self, **kwargs): ''' Return the switches that the FlowVisor gives. Change to CH format. ''' complete_list = [] try: dpids = FV.getDeviceList() for d in dpids: FV.log.debug("XMLRPC:getDeviceInfo (%s)" % (d)) infos = [FV.xmlcall("getDeviceInfo", d) for d in dpids] #need to make it prettier :) switches = zip(dpids, infos) except Exception, e: import traceback traceback.print_exc() raise e
def refreshDevices (self, devices = None): from foam.flowvisor import Connection as FV if devices is None: devices = FV.getDeviceList() for dpid in devices: dpid = dpid.lower() s = select([datapaths], datapaths.c.dpid==dpid) conn = self.connection() result = conn.execute(s) row = result.first() if not row: switch_urn = generateSwitchComponentID(dpid) ins = datapaths.insert().values(dpid=dpid,urn=switch_urn.lower()) conn.execute(ins) self.commit()
def refreshDevices(self, devices=None): from foam.flowvisor import Connection as FV if devices is None: devices = FV.getDeviceList() for dpid in devices: dpid = dpid.lower() s = select([datapaths], datapaths.c.dpid == dpid) conn = self.connection() result = conn.execute(s) row = result.first() if not row: switch_urn = generateSwitchComponentID(dpid) ins = datapaths.insert().values(dpid=dpid, urn=switch_urn.lower()) conn.execute(ins) self.commit()
def getAdvertisement(): NSMAP = { None: "%s" % (PGNS), "xs": "%s" % (XSNS), "openflow": "%s" % (OFNSv3) } rspec = ET.Element("rspec", nsmap=NSMAP) rspec.attrib["{%s}schemaLocation" % (XSNS)] = PGNS + " " \ "http://www.geni.net/resources/rspec/3/ad.xsd " + \ OFNSv3 + " " \ "http://www.geni.net/resources/rspec/ext/openflow/3/of-ad.xsd" rspec.attrib["type"] = "advertisement" links = FV.getLinkList() devices = FV.getDeviceList() fvversion = FV.getFVVersion() db_devices = GeniDB.getDeviceSet() GeniDB.refreshDevices(devices) for dpid in devices: db_devices.discard(dpid) addAdDevice(rspec, dpid) for dpid in db_devices: addAdDevice(rspec, dpid, False) #getLinks START for link in links: addAdLink(rspec, link) #getLinks END xml = StringIO() ET.ElementTree(rspec).write(xml) return xml.getvalue()