Example #1
0
def mysqldump_from_env(env, role_name, dbs, fname):
    node = env_util.get_one_node_of(env, role_name)
    cmd = [
        'bash',
        '-c',
        'set -o pipefail; ' +  # We want to fail if mysqldump fails
        'mysqldump --add-drop-database --lock-all-tables '
        '--databases {0}'.format(' '.join(dbs)) + ' | gzip',
    ]
    with ssh.popen(cmd, stdout=ssh.PIPE, node=node) as proc:
        with open(fname, 'wb') as local_file:
            shutil.copyfileobj(proc.stdout, local_file)
Example #2
0
def mysqldump_from_env(env, role_name, dbs, fname):
    node = env_util.get_one_node_of(env, role_name)
    cmd = [
        'bash', '-c',
        'set -o pipefail; ' +  # We want to fail if mysqldump fails
        'mysqldump --add-drop-database --lock-all-tables '
        '--databases {0}'.format(' '.join(dbs)) +
        ' | gzip',
    ]
    with ssh.popen(cmd, stdout=ssh.PIPE, node=node) as proc:
        with open(fname, 'wb') as local_file:
            shutil.copyfileobj(proc.stdout, local_file)
def test_get_one_node_of(mocker):
    get_nodes = mocker.patch("octane.util.env.get_nodes")
    get_nodes.return_value = iter(["node1", "node2"])

    node = env_util.get_one_node_of(mock.Mock(), "controller")
    assert node == "node1"
Example #4
0
def test_get_one_node_of(mocker):
    get_nodes = mocker.patch('octane.util.env.get_nodes')
    get_nodes.return_value = iter(['node1', 'node2'])

    node = env_util.get_one_node_of(mock.Mock(), 'controller')
    assert node == 'node1'
Example #5
0
def test_get_one_node_of(mocker):
    get_nodes = mocker.patch('octane.util.env.get_nodes')
    get_nodes.return_value = iter(['node1', 'node2'])

    node = env_util.get_one_node_of(mock.Mock(), 'controller')
    assert node == 'node1'
Example #6
0
def mysqldump_restore_to_env(env, role_name, fname):
    node = env_util.get_one_node_of(env, role_name)
    with open(fname, 'rb') as local_file:
        with ssh.popen(['sh', '-c', 'zcat | mysql'], stdin=ssh.PIPE,
                       node=node) as proc:
            shutil.copyfileobj(local_file, proc.stdin)
Example #7
0
def mysqldump_restore_to_env(env, role_name, fname):
    node = env_util.get_one_node_of(env, role_name)
    with open(fname, 'rb') as local_file:
        with ssh.popen(['sh', '-c', 'zcat | mysql'],
                       stdin=ssh.PIPE, node=node) as proc:
            shutil.copyfileobj(local_file, proc.stdin)