def post_snapshot_xdcr(staged_source, repository, source_config, dsource_type): logger.info("In Post snapshot...") post_snapshot_process = CouchbaseOperation( Resource.ObjectBuilder.set_staged_source(staged_source).set_repository( repository).set_source_config(source_config).build()) post_snapshot_process.start_couchbase() snapshot = SnapshotDefinition(validate=False) bucket_details = post_snapshot_process.bucket_list() if len(staged_source.parameters.config_settings_prov) != 0: bucket_list = [] for config_setting in staged_source.parameters.config_settings_prov: bucket_list.append( helper_lib.get_bucket_name_with_size( bucket_details, config_setting["bucketName"])) else: bucket_list = helper_lib.get_stg_all_bucket_list_with_ramquota_size( bucket_details) snapshot.db_path = staged_source.parameters.mount_path snapshot.couchbase_port = source_config.couchbase_src_port snapshot.couchbase_host = source_config.couchbase_src_host snapshot.bucket_list = ":".join(bucket_list) snapshot.time_stamp = helper_lib.current_time() snapshot.snapshot_id = str(helper_lib.get_snapshot_id()) logger.debug("snapshot schema: {}".format(snapshot)) logger.debug("Deleting the snap sync lock file {}".format( config.SNAP_SYNC_FILE_NAME)) helper_lib.delete_file(staged_source.staged_connection, config.SNAP_SYNC_FILE_NAME) return snapshot
def _cleanup_in_exception_case(rx_connection, is_sync, is_snap_sync): logger.debug("In clean up") try: if is_snap_sync and config.SNAP_SYNC_FLAG_TO_USE_CLEANUP_ONLY_IF_CURRENT_JOB_CREATED: delete_file(rx_connection, config.SNAP_SYNC_FILE_NAME) if is_sync and config.SYNC_FLAG_TO_USE_CLEANUP_ONLY_IF_CURRENT_JOB_CREATED: delete_file(rx_connection, config.SYNC_FILE_NAME) if not config.SNAP_SYNC_FLAG_TO_USE_CLEANUP_ONLY_IF_CURRENT_JOB_CREATED or \ not config.SYNC_FLAG_TO_USE_CLEANUP_ONLY_IF_CURRENT_JOB_CREATED: logger.debug(constants.ALREADY_SYNC_FILE_PRESENT_ON_HOST) except Exception as err: logger.debug("Failed to clean up the lock files {}".format( err.message)) raise
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() logger.debug("D_SOURCE:{} disabled".format(source_config.pretty_name))
def post_snapshot_cbbkpmgr(staged_source, repository, source_config, dsource_type): logger.info("In Post snapshot...") post_snapshot_process = CouchbaseOperation( Resource.ObjectBuilder.set_staged_source(staged_source).set_repository( repository).set_source_config(source_config).build()) rx_connection = staged_source.staged_connection post_snapshot_process.start_couchbase() snapshot = SnapshotDefinition(validate=False) bucket_list = [] bucket_details = post_snapshot_process.bucket_list() # if len(staged_source.parameters.config_settings_prov) != 0: # bucket_list = [] # for config_setting in staged_source.parameters.config_settings_prov: # bucket_list.append(helper_lib.get_bucket_name_with_size(bucket_details, config_setting["bucketName"])) # else: # bucket_list = helper_lib.get_stg_all_bucket_list_with_ramquota_size(bucket_details) # extract index ind = post_snapshot_process.get_indexes_definition() logger.debug("indexes definition : {}".format(ind)) snapshot.indexes = ind snapshot.db_path = staged_source.parameters.mount_path snapshot.couchbase_port = source_config.couchbase_src_port snapshot.couchbase_host = source_config.couchbase_src_host snapshot.bucket_list = json.dumps(bucket_details) snapshot.time_stamp = helper_lib.current_time() snapshot.snapshot_id = str(helper_lib.get_snapshot_id()) snapshot.couchbase_admin = post_snapshot_process.parameters.couchbase_admin snapshot.couchbase_admin_password = post_snapshot_process.parameters.couchbase_admin_password #logger.debug("snapshot schema: {}".format(snapshot)) logger.debug("Deleting the lock files") helper_lib.delete_file(rx_connection, config.SNAP_SYNC_FILE_NAME) helper_lib.delete_file(rx_connection, config.SYNC_FILE_NAME) # for Prox investigation #post_snapshot_process.stop_couchbase() #helper_lib.unmount_file_system(rx_connection, staged_source.parameters.mount_path) #logger.debug("Un mounting completed") return snapshot