def upgrade_control_plane(orig_id, seed_id):
    orig_env = environment_obj.Environment(orig_id)
    seed_env = environment_obj.Environment(seed_id)
    controllers = list(env_util.get_controllers(seed_env))
    update_neutron_config(orig_env, seed_env)
    # enable all services on seed env
    if len(controllers) > 1:
        maintenance.stop_cluster(seed_env)
    else:
        maintenance.start_corosync_services(seed_env)
        maintenance.start_upstart_services(seed_env)
    # disable cluster services on orig env
    maintenance.stop_cluster(orig_env)
    # switch networks to seed env
    roles = ['primary-controller', 'controller']
    # disable physical connectivity for orig env
    for node, info in env_util.iter_deployment_info(orig_env, roles):
        network.delete_patch_ports(node, info)
    # enable physical connectivity for seed env
    for node, info in env_util.iter_deployment_info(seed_env, roles):
        network.delete_overlay_networks(node, info)
        network.create_patch_ports(node, info)
    # enable all services on seed env
    if len(controllers) > 1:
        maintenance.start_cluster(seed_env)
        maintenance.start_corosync_services(seed_env)
        maintenance.start_upstart_services(seed_env)
def upgrade_control_plane(orig_id, seed_id):
    orig_env = environment_obj.Environment(orig_id)
    seed_env = environment_obj.Environment(seed_id)
    controllers = list(env_util.get_controllers(seed_env))
    # enable all services on seed env
    if len(controllers) > 1:
        maintenance.stop_cluster(seed_env)
    else:
        maintenance.start_corosync_services(seed_env)
        maintenance.start_upstart_services(seed_env)
    # disable cluster services on orig env
    maintenance.stop_cluster(orig_env)
    # switch networks to seed env
    roles = ['primary-controller', 'controller']
    # disable physical connectivity for orig env
    for node, info in env_util.iter_deployment_info(orig_env, roles):
        network.delete_patch_ports(node, info)
    # enable physical connectivity for seed env
    for node, info in env_util.iter_deployment_info(seed_env, roles):
        network.delete_overlay_networks(node, info)
        network.create_patch_ports(node, info)
    # enable all services on seed env
    if len(controllers) > 1:
        maintenance.start_cluster(seed_env)
        maintenance.start_corosync_services(seed_env)
        maintenance.start_upstart_services(seed_env)
    # NOTE(akscram): Remove replaced deployment info with
    # the isolation mode and the alternative gateway.
    # CAUTION: This method removes replaced deployment
    # information for all nodes in an environment.
    seed_env.delete_facts("deployment")
def upgrade_control_plane(orig_id, seed_id):
    orig_env = environment_obj.Environment(orig_id)
    seed_env = environment_obj.Environment(seed_id)
    controllers = list(env_util.get_controllers(seed_env))
    update_neutron_config(orig_env, seed_env)
    # enable all services on seed env
    if len(controllers) > 1:
        maintenance.stop_cluster(seed_env)
    else:
        maintenance.start_corosync_services(seed_env)
        maintenance.start_upstart_services(seed_env)
    # disable cluster services on orig env
    maintenance.stop_cluster(orig_env)
    # switch networks to seed env
    roles = ['primary-controller', 'controller']
    # disable physical connectivity for orig env
    for node, info in env_util.iter_deployment_info(orig_env, roles):
        network.delete_patch_ports(node, info)
    # enable physical connectivity for seed env
    for node, info in env_util.iter_deployment_info(seed_env, roles):
        network.delete_overlay_networks(node, info)
        network.create_patch_ports(node, info)
    # enable all services on seed env
    if len(controllers) > 1:
        maintenance.start_cluster(seed_env)
        maintenance.start_corosync_services(seed_env)
        maintenance.start_upstart_services(seed_env)
def rollback_control_plane(seed_id, orig_id):
    seed_env = environment_obj.Environment(seed_id)
    orig_env = environment_obj.Environment(orig_id)
    # switch physical networks connectivity to orig_env
    roles = ['primary-controller', 'controller']
    for node, info in env_util.iter_deployment_info(seed_env, roles):
        network.delete_patch_ports(node, info)
    for node, info in env_util.iter_deployment_info(orig_env, roles):
        network.create_patch_ports(node, info)
    # enable cluster's services for orig_env
    maintenance.start_cluster(orig_env)
    maintenance.start_corosync_services(orig_env)
    maintenance.enable_apis(orig_env)
def rollback_control_plane(seed_id, orig_id):
    seed_env = environment_obj.Environment(seed_id)
    orig_env = environment_obj.Environment(orig_id)
    # switch physical networks connectivity to orig_env
    roles = ['primary-controller', 'controller']
    for node, info in env_util.iter_deployment_info(seed_env, roles):
        network.delete_patch_ports(node, info)
    for node, info in env_util.iter_deployment_info(orig_env, roles):
        network.create_patch_ports(node, info)
    # enable cluster's services for orig_env
    maintenance.start_cluster(orig_env)
    maintenance.start_corosync_services(orig_env)
    maintenance.enable_apis(orig_env)
def test_start_corosync_services(mocker, mock_ssh_call, mock_ssh_call_output, mock_subprocess, node):
    get_controllers = mocker.patch("octane.util.env.get_controllers")
    get_controllers.return_value = iter([node])
    get_crm_services = mocker.patch.object(maintenance, "get_crm_services")
    get_crm_services.return_value = ["test_service1", "test_service2"]
    mock_ssh_call.side_effect = [None, subprocess.CalledProcessError(1, "cmd"), None]

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

    maintenance.start_corosync_services("env")

    mock_ssh_call_output.assert_called_once_with(["cibadmin", "--query", "--scope", "resources"], node=node)

    assert wait_for_services.call_args_list == [mock.call("env", ["test_service1", "test_service2"], "start")]
    assert mock_ssh_call.call_args_list == [
        mock.call(["crm", "resource", "start", "test_service1"], node=node),
        mock.call(["crm", "resource", "start", "test_service2"], node=node),
        mock.call(["crm", "resource", "start", "test_service2"], node=node),
    ]
Beispiel #7
0
def test_start_corosync_services(mocker, mock_ssh_call, mock_ssh_call_output,
                                 mock_subprocess, node):
    get_controllers = mocker.patch('octane.util.env.get_controllers')
    get_controllers.return_value = iter([node])
    get_crm_services = mocker.patch.object(maintenance, 'get_crm_services')
    get_crm_services.return_value = ['test_service1', 'test_service2']
    mock_ssh_call.side_effect = \
        [None, subprocess.CalledProcessError(1, 'cmd'), None]

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

    maintenance.start_corosync_services('env')

    mock_ssh_call_output.assert_called_once_with(
        ['cibadmin', '--query', '--scope', 'resources'], node=node)

    assert wait_for_services.call_args_list == \
        [mock.call('env', ['test_service1', 'test_service2'], 'start')]
    assert mock_ssh_call.call_args_list == [
        mock.call(['crm', 'resource', 'start', 'test_service1'], node=node),
        mock.call(['crm', 'resource', 'start', 'test_service2'], node=node),
        mock.call(['crm', 'resource', 'start', 'test_service2'], node=node),
    ]