Exemple #1
0
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()
Exemple #2
0
 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
Exemple #4
0
  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()
Exemple #5
0
    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()
Exemple #6
0
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()