示例#1
0
文件: model.py 项目: ogelbukh/rubick
    def config(self):
        schema = ConfigSchemaRegistry.get_schema(self.component, self.version)
        if not schema:
            self.logger.debug(
                'No schema for component "%s" main config version %s. '
                'Using untyped parameters (everything is string)' %
                (self.component, self.version))

        return self._parse_config_resources(self.config_files, schema)
示例#2
0
    def config(self):
        schema = ConfigSchemaRegistry.get_schema(self.component, self.version)
        if not schema:
            self.logger.debug(
                'No schema for component "%s" main config version %s. '
                'Using untyped parameters (everything is string)' %
                (self.component, self.version))

        return self._parse_config_resources(self.config_files, schema)
示例#3
0
文件: model.py 项目: ogelbukh/rubick
    def config(self):
        config = Configuration()
        schema = ConfigSchemaRegistry.get_schema('rabbitmq', Version(1000000))
        if schema:
            for parameter in schema.parameters:
                if not parameter.default:
                    continue

                config.set_default(parameter.name, parameter.default)
        else:
            print("RabbitMQ schema not found")

        return config
示例#4
0
    def config(self):
        config = Configuration()
        schema = ConfigSchemaRegistry.get_schema('rabbitmq', Version(1000000))
        if schema:
            for parameter in schema.parameters:
                if not parameter.default:
                    continue

                config.set_default(parameter.name, parameter.default)
        else:
            print("RabbitMQ schema not found")

        return config
    def test_sample(self):
        nova = ConfigSchemaRegistry.register_schema(project='nova')

        with nova.version('1.0.0', checkpoint=True) as cfg:
            cfg.param(name='verbose', type='boolean')
            cfg.param(name='rabbit_host', type='address')

        with nova.version('1.1.0') as cfg:
            cfg.param(name='verbose', type='boolean', default=False)
            cfg.remove_param('rabbit_host')

        schema10 = ConfigSchemaRegistry.get_schema(project='nova',
                                                   version='1.0.0')

        self.assertEqual(Version('1.0.0'), schema10.version)
        self.assertEqual('ini', schema10.format)

        def find_param(params, name):
            return find(params, lambda p: p.name == name)

        verbose_param = find_param(schema10.parameters, 'verbose')
        self.assertIsNotNone(verbose_param)
        self.assertEqual('boolean', verbose_param.type)
        self.assertEqual(None, verbose_param.default)

        rabbit_host_param = find_param(schema10.parameters, 'rabbit_host')
        self.assertIsNotNone(rabbit_host_param)
        self.assertEqual('address', rabbit_host_param.type)

        schema11 = ConfigSchemaRegistry.get_schema(project='nova',
                                                   version='1.1.0')

        verbose_param11 = find_param(schema11.parameters, 'verbose')
        self.assertIsNotNone(verbose_param11)
        self.assertEqual(False, verbose_param11.default)

        rabbit_host_param11 = find_param(schema11.parameters, 'rabbit_host')
        self.assertIsNone(rabbit_host_param11)
示例#6
0
    def test_sample(self):
        nova = ConfigSchemaRegistry.register_schema(project='nova')

        with nova.version('1.0.0', checkpoint=True) as cfg:
            cfg.param(name='verbose', type='boolean')
            cfg.param(name='rabbit_host', type='address')

        with nova.version('1.1.0') as cfg:
            cfg.param(name='verbose', type='boolean', default=False)
            cfg.remove_param('rabbit_host')

        schema10 = ConfigSchemaRegistry.get_schema(project='nova',
                                                   version='1.0.0')

        self.assertEqual(Version('1.0.0'), schema10.version)
        self.assertEqual('ini', schema10.format)

        def find_param(params, name):
            return find(params, lambda p: p.name == name)

        verbose_param = find_param(schema10.parameters, 'verbose')
        self.assertIsNotNone(verbose_param)
        self.assertEqual('boolean', verbose_param.type)
        self.assertEqual(None, verbose_param.default)

        rabbit_host_param = find_param(schema10.parameters, 'rabbit_host')
        self.assertIsNotNone(rabbit_host_param)
        self.assertEqual('address', rabbit_host_param.type)

        schema11 = ConfigSchemaRegistry.get_schema(project='nova',
                                                   version='1.1.0')

        verbose_param11 = find_param(schema11.parameters, 'verbose')
        self.assertIsNotNone(verbose_param11)
        self.assertEqual(False, verbose_param11.default)

        rabbit_host_param11 = find_param(schema11.parameters, 'rabbit_host')
        self.assertIsNone(rabbit_host_param11)