Exemple #1
0
 def updateGlobalConfig(serveriplist, amipool, endpoints):
     '''Configuration for Zultys endpoints (global):
     
     Apparently, each supported model fetches a common file named 
     {$MODEL}_common.cfg in the base TFTP directory. Additionally, each
     supported phone model gets its own configuration directory.
     '''
     for sModel in ('ZIP2x1', 'ZIP2x2'):
         vars = {
             'server_ip' :   Endpoint._global_serverip,
             'model'     :   sModel,
         }
         sConfigFile = sModel + '_common.cfg'
         sConfigPath = elastix.BaseEndpoint.TFTP_DIR + '/' + sConfigFile
         try:
             BaseEndpoint._writeTemplate('Zultys_global_cfg.tpl', vars, sConfigPath)
         except IOError, e:
             logging.error('Failed to write %s for Zultys - %s' % (sConfigFile, str(e),))
             return False
         
         try:
             os.makedirs(elastix.BaseEndpoint.TFTP_DIR + '/' + sModel, 0777)
         except OSError, e:
             # swallow "already exists", re-raise anything else
             if e.errno != errno.EEXIST: 
                 logging.error('Failed to create directory for Zultys - %s' % (str(e),))
                 return False
Exemple #2
0
    def updateGlobalConfig(serveriplist, amipool, endpoints):
        '''Configuration for Cisco endpoints (global)

        SIP global definition goes in /tftpboot/SIPDefault.cnf and has a
        reference to a firmware file P0S*.sb2. If there are several files, the
        higher version is selected.
        '''
        sFirmwareVersion = None
        for sPathName in glob.glob(elastix.BaseEndpoint.TFTP_DIR + '/P0S*.sb2'):
            sVersion, ext = os.path.splitext(os.path.basename(sPathName))
            if sFirmwareVersion == None or sFirmwareVersion < sVersion:
                sFirmwareVersion = sVersion
        if sFirmwareVersion == None:
            logging.error('Failed to find firmware file P0S*.sb2 in ' + elastix.BaseEndpoint.TFTP_DIR)
            return False

        vars = {
            'firmware_version'  : sFirmwareVersion,
            'phonesrv'          : BaseEndpoint._buildPhoneProv(Endpoint._global_serverip, 'Cisco', 'GLOBAL'),
        }
        try:
            sConfigFile = 'SIPDefault.cnf'
            sConfigPath = elastix.BaseEndpoint.TFTP_DIR + '/' + sConfigFile
            BaseEndpoint._writeTemplate('Cisco_global_SIPDefault.tpl', vars, sConfigPath)
            return True
        except IOError, e:
            logging.error('Failed to write global config for Cisco - %s' % (str(e),))
            return False
Exemple #3
0
    def updateGlobalConfig(serveriplist, amipool, endpoints):
        '''Configuration for Aastra endpoints (global)

        SIP global definition goes in /tftpboot/aastra.cfg. Even though its
        contents are very similar to the per-phone config, and it also defines
        a SIP server, this file must exist and have a "valid" (even if redundant)
        configuration, or the phone will refuse to boot.
        '''
        vars = {'server_ip' : Endpoint._global_serverip}
        try:
            sConfigFile = 'aastra.cfg'
            sConfigPath = elastix.BaseEndpoint.TFTP_DIR + '/' + sConfigFile
            BaseEndpoint._writeTemplate('Aastra_global_cfg.tpl', vars, sConfigPath)
            return True
        except IOError, e:
            logging.error('Failed to write global config for Aastra - %s' % (str(e),))
            return False
Exemple #4
0
class Endpoint(BaseEndpoint):
    _global_serverip = None

    def __init__(self, amipool, dbpool, sServerIP, sIP, mac):
        BaseEndpoint.__init__(self, 'Polycom', amipool, dbpool, sServerIP, sIP,
                              mac)
        if Endpoint._global_serverip == None:
            Endpoint._global_serverip = sServerIP
        elif Endpoint._global_serverip != sServerIP:
            logging.warning(
                'global server IP is %s but endpoint %s requires ' +
                'server IP %s - this endpoint might not work correctly.' %
                (Endpoint._global_serverip, sIP, sServerIP))

    # FIXME: currently no known way to probe phone model remotely

    @staticmethod
    def updateGlobalConfig(serveriplist, amipool, endpoints):
        '''Configuration for Polycom endpoints (global):
        
        Server definition goes in /tftpboot/server.cfg
        Sip global definition goes in /tftpboot/sip.cfg
        Requires directories /tftpboot/polycom/{logs,overrides,contacts}
        '''
        for sDir in ('/polycom/logs', '/polycom/overrides',
                     '/polycom/contacts'):
            try:
                os.makedirs(elastix.BaseEndpoint.TFTP_DIR + sDir, 0777)
            except OSError, e:
                # swallow "already exists", re-raise anything else
                if e.errno != errno.EEXIST:
                    logging.error(
                        'Failed to create directory for Polycom - %s' %
                        (str(e), ))
                    return False
        vars = {
            'server_ip':
            Endpoint._global_serverip,
            'phonesrv':
            BaseEndpoint._buildPhoneProv(Endpoint._global_serverip, 'Polycom',
                                         'GLOBAL'),
        }

        for sConfigFile, sTemplate in (
            ('server.cfg', 'Polycom_global_server.tpl'),
            ('sip_1.cfg', 'Polycom_global_sip_1.tpl'),
            ('sip_2.cfg', 'Polycom_global_sip_2.tpl'),
        ):
            try:
                sConfigPath = elastix.BaseEndpoint.TFTP_DIR + '/' + sConfigFile
                BaseEndpoint._writeTemplate(sTemplate, vars, sConfigPath)
            except IOError, e:
                logging.error('Failed to write %s for Polycom - %s' % (
                    sConfigFile,
                    str(e),
                ))
                return False
Exemple #5
0
    def updateGlobalConfig(serveriplist, amipool, endpoints):
        '''Configuration for Snom endpoints (global):

        SIP global definition goes in /tftpboot/snom{300|320|360}.htm
        '''
        vars = {'server_ip': Endpoint._global_serverip}

        #for sConfigFile in ('snom300.htm', 'snom320.htm', 'snom360.htm', 'snom821.htm'):
        for sModel in ('300', '320', '360', '710', '720', '760', '821', '870'):
            try:
                #sConfigPath = elastix.BaseEndpoint.TFTP_DIR + '/' + sConfigFile
                sConfigPath = '%s/snom%s.htm' % (elastix.BaseEndpoint.TFTP_DIR,
                                                 sModel)
                BaseEndpoint._writeTemplate('Snom_global_3xx.tpl', vars,
                                            sConfigPath)
            except IOError, e:
                logging.error('Failed to write %s for Snom - %s' % (
                    sConfigFile,
                    str(e),
                ))
                return False