-
-
Save denismakogon/7526170 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from trove.guestagent.strategies.backup import base | |
from trove.guestagent.datastore.cassandra import service | |
from trove.common import utils | |
class CassandraDump(base.BackupRunner): | |
""" Implementation of Backup Strategy for CassandraDump """ | |
__strategy_name__ = 'cassandradump' | |
# The '-' will redirect the output to stdout for streaming | |
storage = service.get_parameter('data_file_directories', '/var/lib/cassandra/data') | |
address = service.get_parameter('rpc_host', '127.0.0.1') | |
cmd = ( | |
'sudo tar cpfP - $(sudo find %(data_dir)s -type d -name backup)' | |
% {'data_dir': self.storage} | |
) | |
def pre_cmd(self): | |
# TODO: Need to add pre_command to base class | |
# TODO: Add kwargs to base class | |
pre_cmd = 'nodetool -h %(address)s snapshot -t backup' % {'address': self.address} | |
out, _ = utils.execute_with_timeout(pre_cmd, shell=True) | |
LOG.info(out) | |
def run(self): | |
self.pre_cmd() | |
super(CassandraDump, self).run() | |
def check_process(): | |
# see https://review.openstack.org/#/c/55311/ | |
# TODO: Do some post processing to see if nodetool worked? | |
out, _ = utils.execute_with_timeout('nodetool -h %(address)s clearsnapshot' | |
% {'address': self.address}, shell=True) | |
return 'Exception in thread' not in out | |
@property | |
def filename(self): | |
return '%s.tar' % self.base_filename |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment