예제 #1
0
파일: lib.py 프로젝트: HalasNet/felix
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()
예제 #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
예제 #4
0
파일: db.py 프로젝트: HalasNet/felix
  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()
예제 #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()
예제 #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()