コード例 #1
0
    def test_find_extenfeatures_settings_when_features_is_none(self):
        exten = self.add_extension(exten='*98', context='xivo-features', type='extenfeatures', typeval='vmusermsg')
        expected_result = [
            {'exten': u'*98',
             'commented': 0,
             'context': u'xivo-features',
             'typeval': 'vmusermsg',
             'type': 'extenfeatures',
             'id': exten.id}
        ]

        extensions = asterisk_conf_dao.find_extenfeatures_settings(None)

        assert_that(extensions, expected_result)
コード例 #2
0
    def _generate(self, output):
        data_general = asterisk_conf_dao.find_sip_general_settings()
        self._gen_general(data_general, output)
        print >> output

        data_auth = asterisk_conf_dao.find_sip_authentication_settings()
        self._gen_authentication(data_auth, output)
        print >> output

        self._gen_trunk(output)
        print >> output

        data_ccss = asterisk_conf_dao.find_extenfeatures_settings(['cctoggle'])
        ccss_options = self._ccss_options(data_ccss)
        self._gen_user(ccss_options, output)

        print >> output
コード例 #3
0
ファイル: driver.py プロジェクト: sboily/kamailio-xivo
    def _generate(self, output):
        data_general = asterisk_conf_dao.find_sip_general_settings()
        self._gen_general(data_general, output)
        print >> output

        data_auth = asterisk_conf_dao.find_sip_authentication_settings()
        self._gen_authentication(data_auth, output)
        print >> output

        self._gen_trunk(output)
        print >> output

        data_ccss = asterisk_conf_dao.find_extenfeatures_settings(['cctoggle'])
        ccss_options = self._ccss_options(data_ccss)
        self._gen_user(ccss_options, output)

        print >> output
コード例 #4
0
    def test_find_extenfeatures_settings(self):
        exten1 = self.add_extension(exten='*98', context='xivo-features', type='extenfeatures', typeval='vmusermsg')
        exten2 = self.add_extension(exten='*92', context='xivo-features', type='extenfeatures', typeval='vmuserpurge')
        self.add_extension(exten='3492', context='robert', type='user', typeval='14')

        expected_result = [
            {'exten': u'*98',
             'commented': 0,
             'context': u'xivo-features',
             'typeval': 'vmusermsg',
             'type': 'extenfeatures',
             'id': exten1.id},
            {'exten': u'*92',
             'commented': 0,
             'context': u'xivo-features',
             'typeval': 'vmuserpurge',
             'type': 'extenfeatures',
             'id': exten2.id}
        ]

        extensions = asterisk_conf_dao.find_extenfeatures_settings(['vmusermsg', 'vmuserpurge'])

        assert_that(extensions, contains_inanyorder(*expected_result))
コード例 #5
0
    def generate(self, output):
        options = output

        if self.contextsconf is not None:
            # load context templates
            conf = ConfigParser.RawConfigParser(
                dict_type=CustomConfigParserStorage)
            try:
                conf.read([self.contextsconf])
            except ConfigParser.DuplicateSectionError:
                raise ValueError("%s has conflicting section names" %
                                 self.contextsconf)
            if not conf.has_section('template'):
                raise ValueError("Template section doesn't exist in %s" %
                                 self.contextsconf)

        # hints & features (init)
        self._generate_global_hints(output)
        extenfeature_names = (
            'bsfilter',
            'fwdbusy',
            'fwdrna',
            'fwdunc',
            'phoneprogfunckey',
            'vmusermsg',
        )
        extenfeatures = asterisk_conf_dao.find_extenfeatures_settings(
            features=extenfeature_names)
        xfeatures = {
            extenfeature.typeval: {
                'exten': extenfeature.exten,
                'commented': extenfeature.commented
            }
            for extenfeature in extenfeatures
        }

        # foreach active context
        for ctx in asterisk_conf_dao.find_context_settings():
            # context name preceded with '!' is ignored
            if conf and conf.has_section('!%s' % ctx['name']):
                continue

            print >> options, "\n[%s]" % ctx['name']

            if conf.has_section(ctx['name']):
                section = ctx['name']
            elif conf.has_section('type:%s' % ctx['contexttype']):
                section = 'type:%s' % ctx['contexttype']
            else:
                section = 'template'

            tmpl = []
            for option_name, option_value in conf.items(section):
                if option_name == 'objtpl':
                    tmpl.append(option_value)
                    continue
                print >> options, "%s = %s" % (option_name,
                                               option_value.replace(
                                                   '%%CONTEXT%%', ctx['name']))

            # context includes
            for row in asterisk_conf_dao.find_contextincludes_settings(
                    ctx['name']):
                print >> options, "include = %s" % row['include']
            print >> options

            # objects extensions (user, group, ...)
            for exten_row in asterisk_conf_dao.find_exten_settings(
                    ctx['name']):
                exten_generator = extension_generators.get(
                    exten_row['type'], GenericExtensionGenerator)
                exten = exten_generator(exten_row).generate()
                self.gen_dialplan_from_template(tmpl, exten, options)

            self._generate_hints(ctx['name'], options)

        print >> options, self._extensions_features(conf, xfeatures)
        self._generate_ivr(output)

        return options.getvalue()