def move_bucket(self, bucket_name, direction): logger.debug("Rename folder") if direction == 'save': src = join(self.virtual_source.parameters.mount_path, 'data', bucket_name) dst = join(self.virtual_source.parameters.mount_path, 'data', ".{}.delphix".format(bucket_name)) command = CommandFactory.os_mv(src, dst, self.need_sudo, self.uid) logger.debug("rename command: {}".format(command)) stdout, error, exit_code = utilities.execute_bash( self.connection, command) elif direction == 'restore': dst = join(self.virtual_source.parameters.mount_path, 'data', bucket_name) src = join(self.virtual_source.parameters.mount_path, 'data', ".{}.delphix".format(bucket_name)) command = CommandFactory.delete_dir(dst, self.need_sudo, self.uid) logger.debug("delete command: {}".format(command)) stdout, error, exit_code = utilities.execute_bash( self.connection, command) command = CommandFactory.os_mv(src, dst, self.need_sudo, self.uid) logger.debug("rename command: {}".format(command)) stdout, error, exit_code = utilities.execute_bash( self.connection, command)
def delete_config(self): # TODO: # error handling logger.debug("start delete_config") filename = "{}/../var/lib/couchbase/config/config.dat".format( helper_lib.get_base_directory_of_given_path( self.repository.cb_shell_path)) cmd = CommandFactory.check_file(filename, self.need_sudo, self.uid) logger.debug("check file cmd: {}".format(cmd)) command_output, std_err, exit_code = utilities.execute_bash( self.connection, command_name=cmd, callback_func=self.ignore_err) if exit_code == 0 and "Found" in command_output: cmd = CommandFactory.os_mv(filename, "{}.bak".format(filename), self.need_sudo, self.uid) logger.debug("rename config cmd: {}".format(cmd)) command_output, std_err, exit_code = utilities.execute_bash( self.connection, command_name=cmd) logger.debug( "rename config.dat to bak - exit_code: {} stdout: {} std_err: {}" .format(exit_code, command_output, std_err)) filename = "{}/../etc/couchdb/local.ini".format( helper_lib.get_base_directory_of_given_path( self.repository.cb_shell_path)) command_output, std_err, exit_code = self.run_os_command( os_command='sed', filename=filename, regex='s/view_index_dir.*//') logger.debug( "clean local.ini index - exit_code: {} stdout: {} std_err: {}". format(exit_code, command_output, std_err)) command_output, std_err, exit_code = self.run_os_command( os_command='sed', filename=filename, regex='s/database_dir.*//') logger.debug( "clean local.ini data - exit_code: {} stdout: {} std_err: {}". format(exit_code, command_output, std_err)) command_output, std_err, exit_code = self.run_os_command( os_command='change_permission', path=filename) logger.debug( "fix local.ini permission - exit_code: {} stdout: {} std_err: {}". format(exit_code, command_output, std_err))