Exemplo n.º 1
0
    def validate(self):
        provider = ProviderConfig.getCommonSchemaDict()

        label = {
            'name': str,
            'min-ready': int,
            'max-ready-age': int,
        }

        diskimage = {
            'name': str,
            'pause': bool,
            'elements': [str],
            'formats': [str],
            'release': v.Any(str, int),
            'rebuild-age': int,
            'env-vars': {
                str: str
            },
            'username': str,
            'build-timeout': int,
        }

        webapp = {
            'port': int,
            'listen_address': str,
        }

        top_level = {
            'webapp': webapp,
            'elements-dir': str,
            'images-dir': str,
            'build-log-dir': str,
            'build-log-retention': int,
            'zookeeper-servers': [{
                'host': str,
                'port': int,
                'chroot': str,
            }],
            'providers': list,
            'labels': [label],
            'diskimages': [diskimage],
            'max-hold-age': int,
        }

        log.info("validating %s" % self.config_file)
        config = yaml.load(open(self.config_file))

        # validate the overall schema
        schema = v.Schema(top_level)
        schema(config)
        for provider_dict in config.get('providers', []):
            provider_schema = get_provider_config(provider_dict).getSchema()
            provider_schema.extend(provider)(provider_dict)
Exemplo n.º 2
0
    def validate(self):
        provider = ProviderConfig.getCommonSchemaDict()

        label = {
            'name': str,
            'min-ready': int,
            'max-ready-age': int,
        }

        diskimage = {
            'name': str,
            'pause': bool,
            'elements': [str],
            'formats': [str],
            'release': v.Any(str, int),
            'rebuild-age': int,
            'env-vars': {str: str},
            'username': str,
            'build-timeout': int,
        }

        webapp = {
            'port': int,
            'listen_address': str,
        }

        top_level = {
            'webapp': webapp,
            'elements-dir': str,
            'images-dir': str,
            'build-log-dir': str,
            'build-log-retention': int,
            'zookeeper-servers': [{
                'host': str,
                'port': int,
                'chroot': str,
            }],
            'providers': list,
            'labels': [label],
            'diskimages': [diskimage],
            'max-hold-age': int,
        }

        log.info("validating %s" % self.config_file)
        config = yaml.safe_load(open(self.config_file))

        # validate the overall schema
        schema = v.Schema(top_level)
        schema(config)
        for provider_dict in config.get('providers', []):
            provider_schema = get_provider_config(provider_dict).getSchema()
            provider_schema.extend(provider)(provider_dict)
Exemplo n.º 3
0
 def getSchema(self):
     pool_node = {
         v.Required('name'): str,
         v.Required('labels'): v.Any(str, [str]),
         'username': str,
         'timeout': int,
         'host-key': v.Any(str, [str]),
         'connection-port': int,
         'connection-type': str,
         'max-parallel-jobs': int,
     }
     pool = ConfigPool.getCommonSchemaDict()
     pool.update({
         'name': str,
         'nodes': [pool_node],
     })
     schema = ProviderConfig.getCommonSchemaDict()
     schema.update({'pools': [pool]})
     return v.Schema(schema)
Exemplo n.º 4
0
 def getSchema(self):
     pool_node = {
         v.Required('name'): str,
         v.Required('labels'): v.Any(str, [str]),
         'username': str,
         'timeout': int,
         'host-key': v.Any(str, [str]),
         'connection-port': int,
         'connection-type': str,
         'max-parallel-jobs': int,
     }
     pool = ConfigPool.getCommonSchemaDict()
     pool.update({
         'name': str,
         'nodes': [pool_node],
     })
     schema = ProviderConfig.getCommonSchemaDict()
     schema.update({'pools': [pool]})
     return v.Schema(schema)
Exemplo n.º 5
0
    def getSchema(self):
        pool_label = {
            v.Required('name'): str,
            v.Exclusive('cloud-image', 'label-image'): str,
            v.Required('instance-type'): str,
            v.Required('key-name'): str,
            'volume-type': str,
            'volume-size': int
        }

        pool = ConfigPool.getCommonSchemaDict()
        pool.update({
            v.Required('name'): str,
            v.Required('labels'): [pool_label],
            'security-group-id': str,
            'subnet-id': str,
            'subnets': [str],
        })

        provider_cloud_images = {
            'name': str,
            'connection-type': str,
            'connection-port': int,
            'image-id': str,
            'username': str,
            'python-path': str,
        }

        provider = ProviderConfig.getCommonSchemaDict()
        provider.update({
            v.Required('pools'): [pool],
            v.Required('region-name'): str,
            'profile-name': str,
            'cloud-images': [provider_cloud_images],
            'hostname-format': str,
            'boot-timeout': int,
            'launch-retries': int,
        })
        return v.Schema(provider)
Exemplo n.º 6
0
    def getSchema(self):
        openshift_label = {
            v.Required('name'): str,
            v.Required('type'): str,
            'image': str,
            'image-pull': str,
            'cpu': int,
            'memory': int,
        }

        pool = {
            v.Required('name'): str,
            v.Required('labels'): [openshift_label],
        }

        schema = ProviderConfig.getCommonSchemaDict()
        schema.update({
            v.Required('pools'): [pool],
            v.Required('context'): str,
            'launch-retries': int,
            'max-projects': int,
        })
        return v.Schema(schema)
Exemplo n.º 7
0
    def getSchema(self):
        k8s_label = {
            v.Required('name'): str,
            v.Required('type'): str,
            'image': str,
            'image-pull': str,
        }

        pool = ConfigPool.getCommonSchemaDict()
        pool.update({
            v.Required('name'): str,
            v.Required('labels'): [k8s_label],
        })

        provider = {
            v.Required('pools'): [pool],
            v.Required('context'): str,
            'launch-retries': int,
        }

        schema = ProviderConfig.getCommonSchemaDict()
        schema.update(provider)
        return v.Schema(schema)
Exemplo n.º 8
0
    def getSchema(self):
        openshift_label = {
            v.Required('name'): str,
            v.Required('type'): str,
            'image': str,
            'image-pull': str,
            'cpu': int,
            'memory': int,
        }

        pool = {
            v.Required('name'): str,
            v.Required('labels'): [openshift_label],
        }

        schema = ProviderConfig.getCommonSchemaDict()
        schema.update({
            v.Required('pools'): [pool],
            v.Required('context'): str,
            'launch-retries': int,
            'max-projects': int,
        })
        return v.Schema(schema)
Exemplo n.º 9
0
    def getSchema(self):
        pool_label = {
            v.Required('name'): str,
            v.Exclusive('cloud-image', 'label-image'): str,
            v.Required('instance-type'): str,
            v.Required('key-name'): str,
            'volume-type': str,
            'volume-size': int
        }

        pool = ConfigPool.getCommonSchemaDict()
        pool.update({
            v.Required('name'): str,
            v.Required('labels'): [pool_label],
            'security-group-id': str,
            'subnet-id': str,
        })

        provider_cloud_images = {
            'name': str,
            'connection-type': str,
            'connection-port': int,
            'image-id': str,
            'username': str,
        }

        provider = ProviderConfig.getCommonSchemaDict()
        provider.update({
            v.Required('pools'): [pool],
            v.Required('region-name'): str,
            'profile-name': str,
            'cloud-images': [provider_cloud_images],
            'hostname-format': str,
            'boot-timeout': int,
            'launch-retries': int,
        })
        return v.Schema(provider)
Exemplo n.º 10
0
    def getSchema(self):
        provider_diskimage = {
            'name': str,
            'pause': bool,
            'meta': dict,
            'config-drive': bool,
            'connection-type': str,
            'connection-port': int,
        }

        provider_cloud_images = {
            'name': str,
            'config-drive': bool,
            'connection-type': str,
            'connection-port': int,
            v.Exclusive('image-id', 'cloud-image-name-or-id'): str,
            v.Exclusive('image-name', 'cloud-image-name-or-id'): str,
            'username': str,
        }

        pool_label_main = {
            v.Required('name'): str,
            v.Exclusive('diskimage', 'label-image'): str,
            v.Exclusive('cloud-image', 'label-image'): str,
            'min-ram': int,
            'flavor-name': str,
            'key-name': str,
            'console-log': bool,
            'boot-from-volume': bool,
            'volume-size': int,
            'instance-properties': dict,
            'userdata': str,
        }

        label_min_ram = v.Schema({v.Required('min-ram'): int}, extra=True)

        label_flavor_name = v.Schema({v.Required('flavor-name'): str},
                                     extra=True)

        label_diskimage = v.Schema({v.Required('diskimage'): str}, extra=True)

        label_cloud_image = v.Schema({v.Required('cloud-image'): str},
                                     extra=True)

        pool_label = v.All(pool_label_main,
                           v.Any(label_min_ram, label_flavor_name),
                           v.Any(label_diskimage, label_cloud_image))

        pool = ConfigPool.getCommonSchemaDict()
        pool.update({
            'name': str,
            'networks': [str],
            'auto-floating-ip': bool,
            'host-key-checking': bool,
            'ignore-provider-quota': bool,
            'max-cores': int,
            'max-ram': int,
            'labels': [pool_label],
            'availability-zones': [str],
            'security-groups': [str]
        })

        schema = ProviderConfig.getCommonSchemaDict()
        schema.update({
            'region-name': str,
            v.Required('cloud'): str,
            'boot-timeout': int,
            'launch-timeout': int,
            'launch-retries': int,
            'nodepool-id': str,
            'rate': v.Coerce(float),
            'hostname-format': str,
            'image-name-format': str,
            'clean-floating-ips': bool,
            'pools': [pool],
            'diskimages': [provider_diskimage],
            'cloud-images': [provider_cloud_images],
        })
        return v.Schema(schema)
Exemplo n.º 11
0
 def getSchema(self):
     pool = ConfigPool.getCommonSchemaDict()
     pool.update({'name': str, 'labels': [str]})
     schema = ProviderConfig.getCommonSchemaDict()
     schema.update({'pools': [pool]})
     return v.Schema(schema)
Exemplo n.º 12
0
    def getSchema(self):
        provider_diskimage = {
            'name': str,
            'pause': bool,
            'meta': dict,
            'config-drive': bool,
            'connection-type': str,
            'connection-port': int,
        }

        provider_cloud_images = {
            'name': str,
            'config-drive': bool,
            'connection-type': str,
            'connection-port': int,
            v.Exclusive('image-id', 'cloud-image-name-or-id'): str,
            v.Exclusive('image-name', 'cloud-image-name-or-id'): str,
            'username': str,
        }

        pool_label_main = {
            v.Required('name'): str,
            v.Exclusive('diskimage', 'label-image'): str,
            v.Exclusive('cloud-image', 'label-image'): str,
            'min-ram': int,
            'flavor-name': str,
            'key-name': str,
            'console-log': bool,
            'boot-from-volume': bool,
            'volume-size': int,
            'instance-properties': dict,
            'userdata': str,
        }

        label_min_ram = v.Schema({v.Required('min-ram'): int}, extra=True)

        label_flavor_name = v.Schema({v.Required('flavor-name'): str},
                                     extra=True)

        label_diskimage = v.Schema({v.Required('diskimage'): str}, extra=True)

        label_cloud_image = v.Schema({v.Required('cloud-image'): str},
                                     extra=True)

        pool_label = v.All(pool_label_main,
                           v.Any(label_min_ram, label_flavor_name),
                           v.Any(label_diskimage, label_cloud_image))

        pool = ConfigPool.getCommonSchemaDict()
        pool.update({
            'name': str,
            'networks': [str],
            'auto-floating-ip': bool,
            'host-key-checking': bool,
            'ignore-provider-quota': bool,
            'max-cores': int,
            'max-ram': int,
            'labels': [pool_label],
            'availability-zones': [str],
            'security-groups': [str]
        })

        schema = ProviderConfig.getCommonSchemaDict()
        schema.update({
            'region-name': str,
            v.Required('cloud'): str,
            'boot-timeout': int,
            'launch-timeout': int,
            'launch-retries': int,
            'nodepool-id': str,
            'rate': v.Coerce(float),
            'hostname-format': str,
            'image-name-format': str,
            'clean-floating-ips': bool,
            'pools': [pool],
            'diskimages': [provider_diskimage],
            'cloud-images': [provider_cloud_images],
        })
        return v.Schema(schema)