Exemplo n.º 1
0
def stop_staging_cbbkpmgr(staged_source, repository, source_config):
    stop_staging = CouchbaseOperation(
        Resource.ObjectBuilder.set_staged_source(staged_source).set_repository(
            repository).set_source_config(source_config).build())
    stop_staging.stop_couchbase()
    stop_staging.save_config(what='current')
    stop_staging.delete_config()
Exemplo n.º 2
0
def start_staging_xdcr(staged_source, repository, source_config):
    start_staging = CouchbaseOperation(
        Resource.ObjectBuilder.set_staged_source(staged_source).set_repository(
            repository).set_source_config(source_config).build())

    logger.debug("Enabling the D_SOURCE:{}".format(source_config.pretty_name))
    dsource_type = staged_source.parameters.d_source_type
    rx_connection = staged_source.staged_connection

    start_staging.stop_couchbase()
    start_staging.delete_config()
    # TODO error handling
    start_staging.restore_config(what='current')
    start_staging.start_couchbase()

    # already_set_up_done, name_conflict = start_staging.check_duplicate_replication(
    #     start_staging.parameters.stg_cluster_name)
    # if already_set_up_done:
    #     logger.info("No need to XDCR setup again")
    # elif name_conflict:
    #     raise DuplicateClusterError("Already cluster is present")
    # else:
    #     logger.info("First time XDCR set up")
    #     start_staging.xdcr_setup()

    start_staging.setup_replication()

    config_dir = start_staging.create_config_dir()
    msg = "dSource Creation / Snapsync for dSource {} is in progress".format(
        source_config.pretty_name)
    helper_lib.write_file(
        rx_connection, msg,
        config_dir + "/" + helper_lib.get_sync_lock_file_name(
            dsource_type, source_config.pretty_name))
    logger.debug("D_SOURCE:{} enabled".format(source_config.pretty_name))
Exemplo n.º 3
0
def stop_staging_xdcr(staged_source, repository, source_config):
    stop_staging = CouchbaseOperation(
        Resource.ObjectBuilder.set_staged_source(staged_source).set_repository(
            repository).set_source_config(source_config).build())

    logger.debug("Disabling the D_SOURCE:{}".format(source_config.pretty_name))
    dsource_type = staged_source.parameters.d_source_type
    rx_connection = staged_source.staged_connection
    logger.info("Deleting Existing Replication")
    is_xdcr_setup, cluster_name = stop_staging.delete_replication()
    if is_xdcr_setup:
        logger.info("Deleting XDCR")
        stop_staging.xdcr_delete(cluster_name)
    config_dir = stop_staging.create_config_dir()
    helper_lib.delete_file(
        rx_connection, config_dir + "/" + helper_lib.get_sync_lock_file_name(
            dsource_type, source_config.pretty_name))
    stop_staging.stop_couchbase()
    stop_staging.save_config(what='current')
    stop_staging.delete_config()
    logger.debug("D_SOURCE:{} disabled".format(source_config.pretty_name))
Exemplo n.º 4
0
def vdb_unconfigure(virtual_source, repository, source_config):
    # delete all buckets
    provision_process = CouchbaseOperation(
        Resource.ObjectBuilder.set_virtual_source(virtual_source).
        set_repository(repository).set_source_config(source_config).build())

    vdb_stop(virtual_source, repository, source_config)
    provision_process.delete_config()

    if provision_process.parameters.node_list is not None and len(
            provision_process.parameters.node_list) > 0:
        for node in provision_process.parameters.node_list:
            logger.debug("+++++++++++++++++++++++++++")
            logger.debug(node)
            logger.debug("+++++++++++++++++++++++++++")
            addnode = CouchbaseOperation(
                Resource.ObjectBuilder.set_virtual_source(
                    virtual_source).set_repository(
                        repository).set_source_config(source_config).build(),
                make_nonprimary_connection(provision_process.connection,
                                           node['environment'],
                                           node['environmentUser']))
            addnode.delete_config()
            addnode.stop_couchbase()
Exemplo n.º 5
0
def vdb_configure(virtual_source, snapshot, repository):
    # try:

    logger.debug("VDB CONFIG START")

    provision_process = CouchbaseOperation(
        Resource.ObjectBuilder.set_virtual_source(virtual_source).
        set_repository(repository).set_snapshot(snapshot).build())

    # TODO:
    # fail if already has cluster ?

    # to make sure there is no config
    provision_process.delete_config()

    provision_process.restore_config(what='parent')

    # if bucket doesn't existing in target cluster
    # couchbase will delete directory while starting
    # so we have to rename it before start

    bucket_list_and_size = json.loads(snapshot.bucket_list)

    if not bucket_list_and_size:
        raise FailedToReadBucketDataFromSnapshot("Snapshot Data is empty.")
    else:
        logger.debug(
            "snapshot bucket data is: {}".format(bucket_list_and_size))

    # for item in helper_lib.filter_bucket_name_from_output(bucket_list_and_size):
    #     logger.debug("Checking bucket: {}".format(item))
    #     bucket_name = item.split(',')[0]
    #     # rename folder
    #     provision_process.move_bucket(bucket_name, 'save')

    provision_process.restart_couchbase(provision=True)
    provision_process.rename_cluster()
    #provision_process.node_init()
    #provision_process.cluster_init()

    #_do_provision(provision_process, snapshot)
    #_cleanup(provision_process, snapshot)

    #_build_indexes(provision_process, snapshot)

    #     if self.__node_local:
    #         logger.debug("it will start on main envioronment")
    #         connection = self.config.connection
    #     else:
    #         logger.debug("it will start on an additional environment {}".format(str(self.__node_environment)))
    #         connection=make_nonprimary_connection(self.config.connection, self.__node_environment, self.__node_envuser)

    nodeno = 1

    logger.debug("MAIN CONNECTION HOST: {}".format(
        provision_process.connection.environment.host.name))

    if provision_process.parameters.node_list is not None and len(
            provision_process.parameters.node_list) > 0:
        for node in provision_process.parameters.node_list:
            nodeno = nodeno + 1
            logger.debug("+++++++++++++++++++++++++++")
            logger.debug(node)
            logger.debug(nodeno)
            logger.debug("+++++++++++++++++++++++++++")
            addnode = CouchbaseOperation(
                Resource.ObjectBuilder.set_virtual_source(virtual_source).
                set_repository(repository).set_snapshot(snapshot).build(),
                make_nonprimary_connection(provision_process.connection,
                                           node['environment'],
                                           node['environmentUser']))
            logger.debug("ADDITIONAL CONNECTION HOST: {}".format(
                provision_process.connection.environment.host.name))
            addnode.addnode(nodeno, node)
            # TODO
            # FINISH HERE
            # addnode.delete_config()
            # addnode.stop_couchbase()

    src_cfg_obj = _source_config(virtual_source, repository, None, snapshot)

    return src_cfg_obj