예제 #1
0
  def GetDset(self, num, default_addr):
    query = """
      SELECT PG.id, PG.groupnumber AS inum, PG.externalnumber AS exnum, PG.servergroup_id AS sgid, INET_NTOA(SG.ip) AS addr, SG.name as sg, PG.metagroup AS is_meta
      FROM phones_phonegroup AS PG
      LEFT JOIN phones_servergroup AS SG
      ON SG.id = PG.servergroup_id
      WHERE PG.groupnumber = %s OR PG.externalnumber = %s
      LIMIT 1
    """
    res = self.getDict(query, (num, num))

    if len(res):
      info = res[0]
      if info['is_meta']:
        ldbg("call to meta-group '%s'" % info['exnum'])
        return self.getMetaDset(num, info['addr'], info['id'], info['sgid'], default_addr)
      if info['sg'] != "opensers":
        ldbg("call to PBX '%s@%s" % (num, info['addr']))
        dset = URISet()
        dset.append(num, info['addr'])
        return dset
      ldbg("call to group '%s'" % num)
      return self.getGroupDset(info['id'], default_addr)
    dset = self.getPhoneDset(num, default_addr)
    if dset:
      ldbg("call to phone '%s'" % num)
    return dset
예제 #2
0
    def GetDset(self, num, default_addr):
        query = """
      SELECT PG.id, PG.groupnumber AS inum, PG.externalnumber AS exnum, PG.servergroup_id AS sgid, INET_NTOA(SG.ip) AS addr, SG.name as sg, PG.metagroup AS is_meta
      FROM phones_phonegroup AS PG
      LEFT JOIN phones_servergroup AS SG
      ON SG.id = PG.servergroup_id
      WHERE PG.groupnumber = %s OR PG.externalnumber = %s
      LIMIT 1
    """
        res = self.getDict(query, (num, num))

        if len(res):
            info = res[0]
            if info['is_meta']:
                ldbg("call to meta-group '%s'" % info['exnum'])
                return self.getMetaDset(num, info['addr'], info['id'],
                                        info['sgid'], default_addr)
            if info['sg'] != "opensers":
                ldbg("call to PBX '%s@%s" % (num, info['addr']))
                dset = URISet()
                dset.append(num, info['addr'])
                return dset
            ldbg("call to group '%s'" % num)
            return self.getGroupDset(info['id'], default_addr)
        dset = self.getPhoneDset(num, default_addr)
        if dset:
            ldbg("call to phone '%s'" % num)
        return dset
예제 #3
0
 def makeDset(self, set, default_addr=None):
   dset = URISet(default_addr)
   for r in set:
     if r.get('locked'):
       continue
     dset.append(r['inum'], r.get('addr'))
   if len(dset):
     return dset
예제 #4
0
 def GetGatewayDset(self, num):
   addr = self.getGatewayAddr()
   if addr:
     dset = URISet()
     dset.append(num, addr)
     return dset
   else:
     lerr("FAIL: couldn't get gateway address")
예제 #5
0
 def makeDset(self, set, default_addr=None):
     dset = URISet(default_addr)
     for r in set:
         if r.get('locked'):
             continue
         dset.append(r['inum'], r.get('addr'))
     if len(dset):
         return dset
예제 #6
0
 def GetGatewayDset(self, num):
     addr = self.getGatewayAddr()
     if addr:
         dset = URISet()
         dset.append(num, addr)
         return dset
     else:
         lerr("FAIL: couldn't get gateway address")