Beispiel #1
0
    def validateConfig(config):
        result = validate_dict(['siteFolder', 'filesFolder'], config)
        if not result:
            return result

        if 'database' not in config:
            return validate_dict(['user', 'pass', 'name'], config['database'],
                                 'database')
Beispiel #2
0
def getDockerConfig(docker_config_name, runLocally=False, printErrors=True):

    settings = getAll()

    if 'dockerHosts' not in settings:
        return False

    dockerHosts = settings['dockerHosts']

    if not dockerHosts or docker_config_name not in dockerHosts:
        return False

    docker_config = copy.deepcopy(dockerHosts[docker_config_name])
    docker_config = resolve_inheritance(docker_config, dockerHosts)

    if 'runLocally' in docker_config and docker_config[
            'runLocally'] or runLocally:
        keys = ['rootFolder', 'tasks']
    else:
        docker_config['runLocally'] = False
        keys = ['tasks', 'rootFolder', 'user', 'host', 'port']

    errors = validate_dict(keys, docker_config)
    if len(errors) > 0:
        if printErrors:
            for key in errors:
                log.error('Missing key \'%s\' in docker-configuration %s' %
                          (key, docker_config_name))

        return False

    return docker_config
Beispiel #3
0
def validate_config_against_methods(config):
    from lib import methods

    errors = validate_dict(['rootFolder', 'type', 'needs'], config)
    methodNames = config['needs']
    for methodName in methodNames:
        m = methods.getMethod(methodName)
        e = m.validateConfig(config)
        errors = data_merge(errors, e)

    if len(errors) > 0:
        for key, msg in errors.iteritems():
            print red('Key \'%s\' in %s: %s' %
                      (key, config['config_name'], msg))

        exit(1)
Beispiel #4
0
def expandBlueprints(data):
    """
  Expand a list of blueprint configurations with a list of variants.
  Helps documenting the available hosts better
  """
    from lib import blueprints
    for blueprint in data['blueprints']:
        errors = validate_dict(['configName', 'variants'], blueprint)
        if len(errors) > 0:
            for key, error in errors.iteritems():
                log.error('can not expand blueprints, %s: %s!' % (error, key))
            exit(1)
        template = blueprints.getTemplate(blueprint['configName'])
        if not template:
            log.error('Missing blueprint config %s' % blueprint['configName'])

        for variant in blueprint['variants']:
            c = blueprints.apply(variant, template)
            data['hosts'][c['configName']] = c
Beispiel #5
0
 def validateConfig(config):
     keys = ['host', 'user']
     return validate_dict(keys, config)
Beispiel #6
0
  def validateConfig(config):
    if 'docker' not in config:
      return validate_dict(['docker'], config)

    return validate_dict(['configuration', 'name'], config['docker'], 'docker')
Beispiel #7
0
 def validateConfig(config):
     return validate_dict([], config)
Beispiel #8
0
 def validateConfig(config):
     return validate_dict(['branch'], config)
Beispiel #9
0
 def validateConfig(config):
     return validate_dict(
         ['rootFolder', 'siteFolder', 'filesFolder', 'backupFolder'],
         config)