Пример #1
0
def create_deployment_resources(deploy_name, bundle_name,
                                deploy_only_resources=None,
                                deploy_only_types=None,
                                excluded_resources=None,
                                excluded_types=None,
                                replace_output=False):
    resources = load_meta_resources(bundle_name)
    # validate_deployment_packages(resources)
    _LOG.info('{0} file was loaded successfully'.format(BUILD_META_FILE_NAME))

    # TODO make filter chain
    if deploy_only_resources:
        resources = dict((k, v) for (k, v) in resources.items() if
                         k in deploy_only_resources)

    if excluded_resources:
        resources = dict((k, v) for (k, v) in resources.items() if
                         k not in excluded_resources)
    if deploy_only_types:
        resources = dict((k, v) for (k, v) in resources.items() if
                         v['resource_type'] in deploy_only_types)

    if excluded_types:
        resources = dict((k, v) for (k, v) in resources.items() if
                         v['resource_type'] not in excluded_types)

    resources = resolve_meta(resources)
    _LOG.debug('Names were resolved')
    _LOG.debug(prettify_json(resources))

    _LOG.debug('Going to create: {0}'.format(prettify_json(resources)))

    # sort resources with priority
    resources_list = list(resources.items())
    resources_list.sort(key=cmp_to_key(_compare_deploy_resources))

    _LOG.info('Going to deploy AWS resources')
    success, output = deploy_resources(resources_list)
    if success:
        _LOG.info('AWS resources were deployed successfully')

        # apply dynamic changes that uses ARNs
        _LOG.info('Going to apply dynamic changes')
        _apply_dynamic_changes(resources, output)
        _LOG.info('Dynamic changes were applied successfully')

    _LOG.info('Going to create deploy output')
    create_deploy_output(bundle_name=bundle_name,
                         deploy_name=deploy_name,
                         output=output,
                         success=success,
                         replace_output=replace_output)
    _LOG.info('Deploy output for {0} was created.'.format(deploy_name))
    return success
Пример #2
0
def continue_deployment_resources(deploy_name,
                                  bundle_name,
                                  deploy_only_resources=None,
                                  deploy_only_types=None,
                                  excluded_resources=None,
                                  excluded_types=None,
                                  replace_output=False):
    output = load_failed_deploy_output(bundle_name, deploy_name)
    _LOG.info('Failed output file was loaded successfully')

    resources = resolve_meta(load_meta_resources(bundle_name))
    _LOG.debug('Names were resolved')
    _LOG.debug(prettify_json(resources))

    # TODO make filter chain
    if deploy_only_resources:
        resources = dict((k, v) for (k, v) in resources.items()
                         if k in deploy_only_resources)

    if excluded_resources:
        resources = dict((k, v) for (k, v) in resources.items()
                         if k not in excluded_resources)
    if deploy_only_types:
        resources = dict((k, v) for (k, v) in resources.items()
                         if v['resource_type'] in deploy_only_types)

    if excluded_types:
        resources = dict((k, v) for (k, v) in resources.items()
                         if v['resource_type'] not in excluded_types)

    # sort resources with priority
    resources_list = list(resources.items())
    resources_list.sort(key=cmp_to_key(_compare_deploy_resources))

    success, updated_output = continue_deploy_resources(resources_list, output)
    _LOG.info('AWS resources were deployed successfully')
    if success:
        # apply dynamic changes that uses ARNs
        _LOG.info('Going to apply dynamic changes')
        _apply_dynamic_changes(resources, updated_output)
        _LOG.info('Dynamic changes were applied successfully')

    # remove failed output from bucket
    remove_failed_deploy_output(bundle_name, deploy_name)
    _LOG.info('Going to create deploy output')
    create_deploy_output(bundle_name=bundle_name,
                         deploy_name=deploy_name,
                         output=updated_output,
                         success=success,
                         replace_output=replace_output)
    return success
Пример #3
0
def update_deployment_resources(bundle_name,
                                deploy_name,
                                replace_output=False,
                                update_only_types=None,
                                update_only_resources=None):
    from syndicate.core import PROCESSOR_FACADE
    resources = resolve_meta(load_meta_resources(bundle_name))
    _LOG.debug(prettify_json(resources))

    _LOG.warn('Please pay attention that only the '
              'following resources types are supported for update: {}'.format(
                  list(PROCESSOR_FACADE.update_handlers().keys())))

    # TODO make filter chain
    resources = dict(
        (k, v) for (k, v) in resources.items()
        if v['resource_type'] in PROCESSOR_FACADE.update_handlers().keys())

    if update_only_types:
        resources = dict((k, v) for (k, v) in resources.items()
                         if v['resource_type'] in update_only_types)

    if update_only_resources:
        resources = dict((k, v) for (k, v) in resources.items()
                         if k in update_only_resources)

    _LOG.debug('Going to update the following resources: {0}'.format(
        prettify_json(resources)))
    resources_list = list(resources.items())
    resources_list.sort(key=cmp_to_key(_compare_update_resources))
    success, output = _process_resources(
        resources=resources_list,
        handlers_mapping=PROCESSOR_FACADE.update_handlers(),
        pass_context=True)
    create_deploy_output(bundle_name=bundle_name,
                         deploy_name=deploy_name,
                         output=output,
                         success=success,
                         replace_output=replace_output)
    return success
def update_lambdas(bundle_name, publish_only_lambdas,
                   excluded_lambdas_resources):
    resources = resolve_meta(load_meta_resources(bundle_name))
    _LOG.debug('Names were resolved')
    _LOG.debug(prettify_json(resources))

    # TODO make filter chain
    resources = dict((k, v) for (k, v) in resources.items()
                     if v['resource_type'] == LAMBDA_TYPE)

    if publish_only_lambdas:
        resources = dict((k, v) for (k, v) in resources.items()
                         if k in publish_only_lambdas)

    if excluded_lambdas_resources:
        resources = dict((k, v) for (k, v) in resources.items()
                         if k not in excluded_lambdas_resources)

    _LOG.debug('Going to update the following lambdas: {0}'.format(
        prettify_json(resources)))
    resources = list(resources.items())
    update_resources(resources=resources)