Esempio n. 1
0
 def print_deploy_deprecation():
     print(color_summary('Hi. Things have changed.'))
     print()
     print(
         'The `commcare-cloud <env> fab deploy` command has been deprecated.'
     )
     print('Instead, please use')
     print()
     print(color_highlight('  commcare-cloud <env> deploy'))
     print()
     print("For info on how you can use the new command, please see")
     print(
         color_link(
             "https://dimagi.github.io/commcare-cloud/commcare-cloud/commands/#deploy"
         ))
     print("or run")
     print()
     print(color_highlight('  commcare-cloud <env> deploy -h'))
     print()
     print("For more information on this change, please see")
     print(
         color_link(
             "https://dimagi.github.io/commcare-cloud/changelog/0029-add-deploy-command.html"
         ))
     print()
     print(color_summary('Thank you for using commcare-cloud.'))
     print()
Esempio n. 2
0
def describe(migration):
    puts('\nMembership')
    with indent():
        puts(get_membership(migration.target_couch_config).get_printable())
    puts('\nDB Info')
    print_db_info(migration.target_couch_config)

    puts('\nShard allocation')
    diff_with_db = None
    if os.path.exists(migration.shard_plan_path):
        diff_with_db = diff_plan(migration)
        if diff_with_db:
            puts(color_highlight('DB allocation differs from plan:\n'))
            puts("{}\n\n".format(diff_with_db))
        else:
            puts(color_success('DB allocation matches plan.'))

    if not diff_with_db:
        print_shard_table([
            get_shard_allocation(migration.target_couch_config, db_name)
            for db_name in sorted(
                get_db_list(migration.target_couch_config.get_control_node()))
        ])

    puts('\nShard count by node')
    print_shard_allocation_by_node([
        get_shard_allocation(migration.target_couch_config, db_name)
        for db_name in sorted(
            get_db_list(migration.target_couch_config.get_control_node()))
    ])
    return 0
Esempio n. 3
0
def commit(migration, ansible_context):
    print_allocation(migration)
    alloc_docs_by_db = {plan.db_name: plan for plan in migration.shard_plan}
    puts(color_summary("Checking shards on disk vs plan. Please wait."))
    if not assert_files(migration, alloc_docs_by_db, ansible_context):
        puts(color_error("Some shard files are not where we expect. Have you run 'migrate'?"))
        puts(color_error("Aborting"))
        return 1
    else:
        puts(color_success("All shards appear to be where we expect according to the plan."))

    if ask("Are you sure you want to update the Couch Database config?"):
        commit_migration(migration)

        diff_with_db = diff_plan(migration)
        if diff_with_db:
            puts(color_error('DB allocation differs from expected:\n'))
            puts("{}\n\n".format(diff_with_db))
            puts("Check the DB state and logs and maybe try running 'commit' again?")
            return 1

        puts(color_highlight("New shard allocation:\n"))
        print_shard_table([
            get_shard_allocation(migration.target_couch_config, db_name)
            for db_name in sorted(get_db_list(migration.target_couch_config.get_control_node()))
        ])
    return 0