Beispiel #1
0
def test_stop_corosync_services(mocker, mock_ssh_call, mock_ssh_call_output,
                                mock_subprocess, node):
    get_one_controller = mocker.patch('octane.util.env.get_one_controller')
    get_one_controller.return_value = node

    get_crm_services = mocker.patch.object(maintenance, 'get_crm_services')
    get_crm_services.return_value = ['s1', 's2']

    mock_ssh_call.side_effect = \
        [subprocess.CalledProcessError(1, 'cmd'), None, None]

    mocker.patch('time.sleep')

    wait_for_services = \
        mocker.patch.object(maintenance, 'wait_for_corosync_services_sync')

    maintenance.stop_corosync_services('env')

    assert not mock_subprocess.called

    mock_ssh_call_output.assert_called_once_with(
        ['cibadmin', '--query', '--scope', 'resources'], node=node)
    assert wait_for_services.call_args_list == \
        [mock.call('env', ['s1', 's2'], 'stop')]
    assert mock_ssh_call.call_args_list == [
        mock.call(['crm', 'resource', 'stop', 's1'], node=node),
        mock.call(['crm', 'resource', 'stop', 's1'], node=node),
        mock.call(['crm', 'resource', 'stop', 's2'], node=node),
    ]
Beispiel #2
0
def upgrade_db(orig_id, seed_id, db_role_name):
    orig_env = environment_obj.Environment(orig_id)
    seed_env = environment_obj.Environment(seed_id)
    env_util.delete_fuel_resources(seed_env)
    # Wait for Neutron to reconfigure networks
    time.sleep(7)  # FIXME: Use more deterministic way
    maintenance.disable_apis(orig_env)
    maintenance.stop_corosync_services(seed_env)
    maintenance.stop_upstart_services(seed_env)

    expected_dbs = set(magic_consts.OS_SERVICES)
    existing_dbs = set(db.get_databases(orig_env))
    dbs = existing_dbs & expected_dbs
    if len(dbs) < len(magic_consts.OS_SERVICES):
        LOG.info('Skipping nonexistent tables: %s',
                 ', '.join(expected_dbs - existing_dbs))
    LOG.info('Will dump tables: %s', ', '.join(dbs))

    fname = os.path.join(magic_consts.FUEL_CACHE, 'dbs.original.sql.gz')
    db.mysqldump_from_env(orig_env, db_role_name, dbs, fname)

    fname2 = os.path.join(
        magic_consts.FUEL_CACHE,
        'dbs.original.cluster_%s.sql.gz' % (orig_env.data['id'],),
    )
    shutil.copy(fname, fname2)

    db.mysqldump_restore_to_env(seed_env, db_role_name, fname)
    db.db_sync(seed_env)
Beispiel #3
0
def upgrade_db(orig_id, seed_id, db_role_name):
    orig_env = environment_obj.Environment(orig_id)
    seed_env = environment_obj.Environment(seed_id)
    env_util.delete_fuel_resources(seed_env)
    # Wait for Neutron to reconfigure networks
    time.sleep(7)  # FIXME: Use more deterministic way
    maintenance.disable_apis(orig_env)
    maintenance.stop_corosync_services(seed_env)
    maintenance.stop_upstart_services(seed_env)

    expected_dbs = set(magic_consts.OS_SERVICES)
    existing_dbs = set(db.get_databases(orig_env))
    dbs = existing_dbs & expected_dbs
    if len(dbs) < len(magic_consts.OS_SERVICES):
        LOG.info('Skipping nonexistent tables: %s',
                 ', '.join(expected_dbs - existing_dbs))
    LOG.info('Will dump tables: %s', ', '.join(dbs))

    fname = os.path.join(magic_consts.FUEL_CACHE, 'dbs.original.sql.gz')
    db.mysqldump_from_env(orig_env, db_role_name, dbs, fname)

    fname2 = os.path.join(
        magic_consts.FUEL_CACHE,
        'dbs.original.cluster_%s.sql.gz' % (orig_env.data['id'], ),
    )
    shutil.copy(fname, fname2)

    db.mysqldump_restore_to_env(seed_env, db_role_name, fname)
    db.db_sync(seed_env)
Beispiel #4
0
def upgrade_db(orig_id, seed_id):
    orig_env = environment_obj.Environment(orig_id)
    seed_env = environment_obj.Environment(seed_id)
    env_util.delete_fuel_resources(seed_env)
    # Wait for Neutron to reconfigure networks
    time.sleep(7)  # FIXME: Use more deterministic way
    maintenance.disable_apis(orig_env)
    maintenance.stop_corosync_services(seed_env)
    maintenance.stop_upstart_services(seed_env)
    fname = mysqldump_from_env(orig_env)
    mysqldump_restore_to_env(seed_env, fname)
    db_sync(seed_env)
Beispiel #5
0
def test_stop_corosync_services(mocker, mock_ssh_call, mock_ssh_call_output,
                                mock_subprocess, node):
    get_one_controller = mocker.patch('octane.util.env.get_one_controller')
    get_one_controller.return_value = node

    parse_crm_status = mocker.patch.object(maintenance, 'parse_crm_status')
    parse_crm_status.return_value = ['s1', 's2']

    mock_ssh_call.side_effect = \
        [subprocess.CalledProcessError(1, 'cmd'), None, None]

    mocker.patch('time.sleep')

    maintenance.stop_corosync_services('env')

    assert not mock_subprocess.called
    mock_ssh_call_output.assert_called_once_with(['crm', 'status'], node=node)
    assert mock_ssh_call.call_args_list == [
        mock.call(['crm', 'resource', 'stop', 's1'], node=node),
        mock.call(['crm', 'resource', 'stop', 's1'], node=node),
        mock.call(['crm', 'resource', 'stop', 's2'], node=node),
    ]
def test_stop_corosync_services(mocker, mock_ssh_call, mock_ssh_call_output, mock_subprocess, node):
    get_one_controller = mocker.patch("octane.util.env.get_one_controller")
    get_one_controller.return_value = node

    get_crm_services = mocker.patch.object(maintenance, "get_crm_services")
    get_crm_services.return_value = ["s1", "s2"]

    mock_ssh_call.side_effect = [subprocess.CalledProcessError(1, "cmd"), None, None]

    mocker.patch("time.sleep")

    wait_for_services = mocker.patch.object(maintenance, "wait_for_corosync_services_sync")

    maintenance.stop_corosync_services("env")

    assert not mock_subprocess.called

    mock_ssh_call_output.assert_called_once_with(["cibadmin", "--query", "--scope", "resources"], node=node)
    assert wait_for_services.call_args_list == [mock.call("env", ["s1", "s2"], "stop")]
    assert mock_ssh_call.call_args_list == [
        mock.call(["crm", "resource", "stop", "s1"], node=node),
        mock.call(["crm", "resource", "stop", "s1"], node=node),
        mock.call(["crm", "resource", "stop", "s2"], node=node),
    ]