def get_test_target():
    return Target(
        {'a', 'b', 'c'},
        {'d': Scope(
            'd', {
                'd_1': Target({'d_1_a', 'd_1_b'}),
                'd_2': Target({'d_2_a', 'd_2_b'})
            })})
예제 #2
0
파일: validate.py 프로젝트: vespian/dcos
def get_target():
    return Target({
        'ssh_user',
        'ssh_port',
        'ssh_key_path',
        'master_list',
        'agent_list',
        'public_agent_list',
        'ssh_parallelism',
        'process_timeout'})
예제 #3
0
def test_resolve_simple():

    test_source = Source({
        'validate': [validate_a],
        'default': {
            'a': 'a_str',
            'd': 'd_1',
        },
        'must': {
            'b': 'b_str'
        },
        'conditional': {
            'd': {
                'd_1': {
                    'must': {
                        'd_1_b': 'd_1_b_str'
                    }
                },
                'd_2': {
                    'must': {
                        'd_2_b': 'd_2_b_str'
                    }
                }
            }
        }
    })

    test_target = Target({'a', 'b', 'c'}, {
        'd':
        Scope('d', {
            'd_1': Target({'d_1_a', 'd_1_b'}),
            'd_2': Target({'d_2_a', 'd_2_b'})
        })
    })

    resolver = gen.internals.resolve_configuration([test_source],
                                                   [test_target], {
                                                       'c': 'c_str',
                                                       'd_1_a': 'd_1_a_str'
                                                   })
    print(resolver)
    assert resolver.status_dict == {'status': 'ok'}
예제 #4
0
파일: config.py 프로젝트: unterstein/dcos
def validate_onprem_dcos_config_contents(onprem_dcos_config_contents,
                                         num_masters):
    # TODO DCOS-14033: [gen.internals] Source validate functions are global only
    user_config = yaml.load(onprem_dcos_config_contents)
    # Use the default config in the installer
    config = yaml.load(dcos_installer.config.config_sample)
    config.update(user_config)
    # This field is required and auto-added by installer, so add a dummy here
    if 'bootstrap_id' not in config:
        config['bootstrap_id'] = 'deadbeef'

    # Error message will instruct user to provide ip_detect_contents if we dont
    # have the filename argument provided. We want users providing the file
    if 'ip_detect_filename' not in config:
        config['ip_detect_filename'] = 'provide-this-ip-detect-path'

    # dummy master list to pass validation
    config['master_list'] = [('10.0.0.' + str(i))
                             for i in range(int(num_masters))]

    # Use the default config in the installer
    sources, targets, templates = gen.get_dcosconfig_source_target_and_templates(
        gen.stringify_configuration(config), list(),
        [ssh.validate.source, gen.build_deploy.bash.onprem_source])

    # Copy the gen target from dcos_installer/config.py, but instead remove
    # 'ssh_key_path' from the target because the validate fn in ssh_source is
    # too strict I.E. we cannot validate a key if we are going to generate
    # Furthermore, we cannot use the target ssh_key_path as it will automatically
    # invoked the validate fn from ssh/validate.py Luckily, we can instead use
    # the more idiomatic 'ssh_private_key_filename'
    targets.append(
        Target({
            'ssh_user', 'ssh_port', 'master_list', 'agent_list',
            'public_agent_list', 'ssh_parallelism', 'process_timeout'
        }))

    resolver = resolve_configuration(sources, targets)
    status = resolver.status_dict
    if status['status'] == 'errors':
        raise AssertionError(
            pretty_print_validate_error(status['errors'], status['unset']))
예제 #5
0
파일: config.py 프로젝트: unterstein/dcos
def get_target():
    """ Targets must never be used, and so must be instantiated dynamically
    """
    aws_platform_target = Target(
        {
            'aws_region', 'aws_access_key_id', 'aws_secret_access_key',
            'key_helper', 'zen_helper', 'deployment_name'
        }, {
            'provider':
            Scope(
                'provider', {
                    'aws':
                    Target({}),
                    'azure':
                    Target({}),
                    'onprem':
                    Target({}, {
                        'key_helper':
                        Scope('key_helper', {
                            'true': Target({}),
                            'false': Target({'aws_key_name'})
                        })
                    })
                })
        })
    azure_platform_target = Target({
        'azure_location', 'azure_client_id', 'azure_client_secret',
        'azure_tenant_id', 'azure_subscription_id', 'deployment_name',
        'key_helper'
    })
    template_target = Target({'template_url', 'template_parameters'})
    onprem_target = Target(
        {
            'deploy_bare_cluster_only',
        },
        {
            'deploy_bare_cluster_only':
            Scope(
                'deploy_bare_cluster_only', {
                    'true':
                    Target({'instance_count'}),
                    'false':
                    Target({
                        'installer_url', 'num_private_agents',
                        'num_public_agents', 'num_masters',
                        'onprem_dcos_config_contents'
                    })
                }),
            'platform':
            Scope(
                'platform',
                {
                    'aws': Target(
                        {'os_name', 'instance_type', 'instance_count'}),
                    'azure': Target({}),  # Unsupported currently
                    'bare_cluster': Target({})
                })
        })  # Unsupported currently
    return Target(
        {
            'launch_config_version', 'platform', 'provider', 'ssh_port',
            'ssh_private_key', 'ssh_user'
        }, {
            'platform':
            Scope(
                'platform', {
                    'aws': aws_platform_target,
                    'azure': azure_platform_target,
                    'bare_cluster': Target({'platform_info_filename'})
                }),
            'provider':
            Scope(
                'provider', {
                    'aws': template_target,
                    'azure': template_target,
                    'onprem': onprem_target
                })
        })
예제 #6
0
파일: config.py 프로젝트: warrenween/dcos
def get_target():
    """ Targets must never be re-used after its been evaluated by gen, so
    do not define it as a global constant
    """
    aws_platform_target = Target(
        {
            'aws_region', 'aws_access_key_id', 'aws_secret_access_key',
            'key_helper', 'zen_helper', 'deployment_name'
        }, {
            'provider':
            Scope(
                'provider', {
                    'aws':
                    Target({}),
                    'azure':
                    Target({}),
                    'onprem':
                    Target({}, {
                        'key_helper':
                        Scope('key_helper', {
                            'true': Target({}),
                            'false': Target({'aws_key_name'})
                        })
                    })
                })
        })
    azure_platform_target = Target({
        'azure_location', 'azure_client_id', 'azure_client_secret',
        'azure_tenant_id', 'azure_subscription_id', 'deployment_name',
        'key_helper'
    })
    template_target = Target({'template_url', 'template_parameters'})
    onprem_target = Target(
        {
            'installer_url', 'installer_port', 'num_private_agents',
            'num_public_agents', 'num_masters', 'prevalidate_onprem_config',
            'onprem_dcos_config_contents'
        }, {
            'platform':
            Scope(
                'platform', {
                    'aws':
                    Target({
                        'aws_key_name', 'cluster_size', 'instance_ami',
                        'instance_type', 'admin_location'
                    }),
                    'azure':
                    Target({})
                })
        })  # Unsupported currently
    return Target(
        {
            'launch_config_version', 'platform', 'provider', 'ssh_port',
            'ssh_private_key', 'ssh_user'
        }, {
            'platform':
            Scope('platform', {
                'aws': aws_platform_target,
                'azure': azure_platform_target
            }),
            'provider':
            Scope(
                'provider', {
                    'aws': template_target,
                    'azure': template_target,
                    'onprem': onprem_target
                })
        })