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
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'}
Пример #3
0
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
                })
        })
Пример #4
0
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
                })
        })