def upgrade_node(env_id, node_ids, isolated=False): # From check_deployment_status env = environment_obj.Environment(env_id) if env.data['status'] != 'new': raise Exception("Environment must be in 'new' status") nodes = [node_obj.Node(node_id) for node_id in node_ids] # Sanity check one_orig_id = None for node in nodes: orig_id = node.data['cluster'] if orig_id == env_id: raise Exception( "Cannot upgrade node with ID %s: it's already in cluster with " "ID %s", node_id, env_id, ) if orig_id: if one_orig_id and orig_id != one_orig_id: raise Exception( "Not upgrading nodes from different clusters: %s and %s", orig_id, one_orig_id, ) one_orig_id = orig_id call_handlers = upgrade_handlers.get_nodes_handlers(nodes, env, isolated) call_handlers('preupgrade') call_handlers('prepare') env_util.move_nodes(env, nodes) env_util.provision_nodes(env, nodes) call_handlers('predeploy') env_util.deploy_nodes(env, nodes) call_handlers('postdeploy')
def upgrade_node(env_id, node_ids, isolated=False, network_template=None): # From check_deployment_status env = environment_obj.Environment(env_id) nodes = [node_obj.Node(node_id) for node_id in node_ids] # Sanity check one_orig_id = None for node in nodes: orig_id = node.data['cluster'] if orig_id == env_id: raise Exception( "Cannot upgrade node with ID %s: it's already in cluster with " "ID %s", node_id, env_id, ) if orig_id: if one_orig_id and orig_id != one_orig_id: raise Exception( "Not upgrading nodes from different clusters: %s and %s", orig_id, one_orig_id, ) one_orig_id = orig_id patch_partition_generator(one_orig_id) call_handlers = upgrade_handlers.get_nodes_handlers(nodes, env, isolated) call_handlers('preupgrade') call_handlers('prepare') env_util.move_nodes(env, nodes) call_handlers('predeploy') if network_template: env_util.set_network_template(env, network_template) if isolated or len(nodes) == 1: env_util.deploy_nodes(env, nodes) else: env_util.deploy_changes(env, nodes) call_handlers('postdeploy')
def upgrade_node(env_id, node_ids, isolated=False): # From check_deployment_status env = environment_obj.Environment(env_id) if env.data['status'] != 'new': raise Exception("Environment must be in 'new' status") nodes = [node_obj.Node(node_id) for node_id in node_ids] # Sanity check one_orig_id = None for node in nodes: orig_id = node.data['cluster'] if orig_id == env_id: raise Exception( "Cannot upgrade node with ID %s: it's already in cluster with " "ID %s", node_id, env_id, ) if orig_id: if one_orig_id and orig_id != one_orig_id: raise Exception( "Not upgrading nodes from different clusters: %s and %s", orig_id, one_orig_id, ) one_orig_id = orig_id call_handlers = upgrade_handlers.get_nodes_handlers(nodes, env, isolated) call_handlers('preupgrade') call_handlers('prepare') env_util.move_nodes(env, nodes) env_util.provision_nodes(env, nodes) call_handlers('predeploy') env_util.deploy_nodes(env, nodes) call_handlers('postdeploy')
def upgrade_node(env_id, node_ids, isolated=False, network_template=None): # From check_deployment_status env = environment_obj.Environment(env_id) nodes = [node_obj.Node(node_id) for node_id in node_ids] # Sanity check one_orig_id = None for node in nodes: orig_id = node.data['cluster'] if orig_id == env_id: raise Exception( "Cannot upgrade node with ID %s: it's already in cluster with " "ID %s", node_id, env_id, ) if orig_id: if one_orig_id and orig_id != one_orig_id: raise Exception( "Not upgrading nodes from different clusters: %s and %s", orig_id, one_orig_id, ) one_orig_id = orig_id call_handlers = upgrade_handlers.get_nodes_handlers(nodes, env, isolated) copy_patches_folder_to_nailgun() disk.update_partition_generator() call_handlers('preupgrade') call_handlers('prepare') env_util.move_nodes(env, nodes) call_handlers('predeploy') if network_template: env_util.set_network_template(env, network_template) env_util.deploy_nodes(env, nodes) call_handlers('postdeploy')
def test_move_nodes(mocker, mock_subprocess, provision, compat): env = mock.Mock() env.data = { 'id': 'test-id', } nodes = [mock.Mock(), mock.Mock()] for idx, node in enumerate(nodes, 1): node.data = {'id': str(idx)} mock_move_nodes = mocker.patch( "octane.util.env.fuel2_env_call") mock_create_configdrive = mocker.patch( "octane.util.disk.create_configdrive_partition") mock_wait_for = mocker.patch( "octane.util.env.wait_for_nodes") mock_get_provision_method = mocker.patch( "octane.util.env.incompatible_provision_method") mock_get_provision_method.return_value = compat env_util.move_nodes(env, nodes, provision) if provision: assert mock_create_configdrive.call_args_list == \ [mock.call(node) for node in nodes] mock_wait_for.assert_called_once_with(nodes, 'provisioned') mock_move_nodes.assert_called_once_with( ["move", "node", "test-id", "1", "2"]) else: mock_move_nodes.assert_called_once_with( ["move", "node", "--no-provision", "test-id", "1", "2"]) assert mock_create_configdrive.call_args_list == [] assert mock_wait_for.call_args_list == []
def upgrade_node(env_id, node_ids, isolated=False, network_template=None): # From check_deployment_status env = environment_obj.Environment(env_id) nodes = [node_obj.Node(node_id) for node_id in node_ids] # Sanity check one_orig_id = None for node in nodes: orig_id = node.data['cluster'] if orig_id == env_id: raise Exception( "Cannot upgrade node with ID %s: it's already in cluster with " "ID %s", node_id, env_id, ) if orig_id: if one_orig_id and orig_id != one_orig_id: raise Exception( "Not upgrading nodes from different clusters: %s and %s", orig_id, one_orig_id, ) one_orig_id = orig_id patch_partition_generator(one_orig_id) call_handlers = upgrade_handlers.get_nodes_handlers(nodes, env, isolated) call_handlers('preupgrade') call_handlers('prepare') env_util.move_nodes(env, nodes) # NOTE(aroma): copying of VIPs must be done after node reassignment # as according to [1] otherwise the operation will not take any effect # [1]: https://bugs.launchpad.net/fuel/+bug/1549254 env_util.copy_vips(env) call_handlers('predeploy') if network_template: env_util.set_network_template(env, network_template) if isolated or len(nodes) == 1: env_util.deploy_nodes(env, nodes) else: env_util.deploy_changes(env, nodes) call_handlers('postdeploy')