def test_transitions2(self): transitions = etree.parse(rc("transitions02.xml")) self.assertEqual([{ "primitive_id": "RemoteNode", "primitive_long_id": "RemoteNode", "operation": "stop", "on_node": "virt-143", }, { "primitive_id": "RemoteNode", "primitive_long_id": "RemoteNode", "operation": "migrate_to", "on_node": "virt-143", }, { "primitive_id": "RemoteNode", "primitive_long_id": "RemoteNode", "operation": "migrate_from", "on_node": "virt-142", }, { "primitive_id": "dummy8", "primitive_long_id": "dummy8", "operation": "stop", "on_node": "virt-143", }, { "primitive_id": "dummy8", "primitive_long_id": "dummy8", "operation": "start", "on_node": "virt-142", }], simulate.get_operations_from_transitions(transitions))
def disable_safe(env, resource_ids, strict, wait): """ Disallow specified resource to be started by the cluster only if there is no effect on other resources LibraryEnvironment env -- strings resource_ids -- ids of the resources to be disabled bool strict -- if False, allow resources to be migrated mixed wait -- False: no wait, None: wait default timeout, int: wait timeout """ if not env.is_cib_live: raise LibraryError( reports.live_environment_required([file_type_codes.CIB])) with resource_environment( env, wait, resource_ids, _ensure_disabled_after_wait(True)) as resources_section: id_provider = IdProvider(resources_section) resource_el_list = _find_resources_or_raise(resources_section, resource_ids) env.report_processor.process_list( _resource_list_enable_disable(resource_el_list, resource.common.disable, id_provider, env.get_cluster_state())) inner_resources_names_set = set() for resource_el in resource_el_list: inner_resources_names_set.update({ inner_resource_el.get("id") for inner_resource_el in resource.common.get_all_inner_resources(resource_el) }) plaintext_status, transitions, dummy_cib = simulate_cib( env.cmd_runner(), get_root(resources_section)) simulated_operations = ( simulate_tools.get_operations_from_transitions(transitions)) other_affected = set() if strict: other_affected = set( simulate_tools.get_resources_from_operations( simulated_operations, exclude=resource_ids)) else: other_affected = set( simulate_tools.get_resources_left_stopped( simulated_operations, exclude=resource_ids) + simulate_tools.get_resources_left_demoted( simulated_operations, exclude=resource_ids)) # Stopping a clone stops all its inner resources. That should not block # stopping the clone. other_affected = other_affected - inner_resources_names_set if other_affected: raise LibraryError( reports.resource_disable_affects_other_resources( resource_ids, other_affected, plaintext_status, ))
def test_transitions1(self): transitions = etree.parse(rc("transitions01.xml")) self.assertEqual( [ simulate.SimulationOperation( operation_id=17, primitive_id="dummy", primitive_long_id="dummy", operation_type=simulate.OPERATION_STOP, on_node="rh7-3", ), simulate.SimulationOperation( operation_id=18, primitive_id="dummy", primitive_long_id="dummy", operation_type=simulate.OPERATION_START, on_node="rh7-2", ), simulate.SimulationOperation( operation_id=22, primitive_id="d0", primitive_long_id="d0:1", operation_type=simulate.OPERATION_STOP, on_node="rh7-1", ), simulate.SimulationOperation( operation_id=23, primitive_id="d0", primitive_long_id="d0:1", operation_type=simulate.OPERATION_START, on_node="rh7-2", ), simulate.SimulationOperation( operation_id=29, primitive_id="state", primitive_long_id="state:0", operation_type=simulate.OPERATION_STOP, on_node="rh7-3", ), simulate.SimulationOperation( operation_id=30, primitive_id="state", primitive_long_id="state:0", operation_type=simulate.OPERATION_START, on_node="rh7-2", ), ], simulate.get_operations_from_transitions(transitions), )
def test_transitions1(self): transitions = etree.parse(rc("transitions01.xml")) self.assertEqual( [ { "primitive_id": "dummy", "primitive_long_id": "dummy", "operation": "stop", "on_node": "rh7-3", }, { "primitive_id": "dummy", "primitive_long_id": "dummy", "operation": "start", "on_node": "rh7-2", }, { "primitive_id": "d0", "primitive_long_id": "d0:1", "operation": "stop", "on_node": "rh7-1", }, { "primitive_id": "d0", "primitive_long_id": "d0:1", "operation": "start", "on_node": "rh7-2", }, { "primitive_id": "state", "primitive_long_id": "state:0", "operation": "stop", "on_node": "rh7-3", }, { "primitive_id": "state", "primitive_long_id": "state:0", "operation": "start", "on_node": "rh7-2", }, ], simulate.get_operations_from_transitions(transitions), )
def test_transitions2(self): transitions = etree.parse(rc("transitions02.xml")) self.assertEqual( [ simulate.SimulationOperation( operation_id=26, primitive_id="RemoteNode", primitive_long_id="RemoteNode", operation_type=simulate.OPERATION_STOP, on_node="virt-143", ), simulate.SimulationOperation( operation_id=29, primitive_id="RemoteNode", primitive_long_id="RemoteNode", operation_type=simulate.OPERATION_MIGRATE_TO, on_node="virt-143", ), simulate.SimulationOperation( operation_id=30, primitive_id="RemoteNode", primitive_long_id="RemoteNode", operation_type=simulate.OPERATION_MIGRATE_FROM, on_node="virt-142", ), simulate.SimulationOperation( operation_id=45, primitive_id="dummy8", primitive_long_id="dummy8", operation_type=simulate.OPERATION_STOP, on_node="virt-143", ), simulate.SimulationOperation( operation_id=46, primitive_id="dummy8", primitive_long_id="dummy8", operation_type=simulate.OPERATION_START, on_node="virt-142", ), ], simulate.get_operations_from_transitions(transitions), )
def disable_safe(env, resource_ids, strict, wait): """ Disallow specified resource to be started by the cluster only if there is no effect on other resources LibraryEnvironment env -- strings resource_ids -- ids of the resources to be disabled bool strict -- if False, allow resources to be migrated mixed wait -- False: no wait, None: wait default timeout, int: wait timeout """ if not env.is_cib_live: raise LibraryError( reports.live_environment_required([file_type_codes.CIB])) with resource_environment( env, wait, resource_ids, _ensure_disabled_after_wait(True)) as resources_section: _disable_validate_and_edit_cib(env, resources_section, resource_ids) plaintext_status, transitions, dummy_cib = simulate_cib( env.cmd_runner(), get_root(resources_section)) simulated_operations = ( simulate_tools.get_operations_from_transitions(transitions)) other_affected = set() if strict: other_affected = set( simulate_tools.get_resources_from_operations( simulated_operations, exclude=resource_ids)) else: other_affected = set( simulate_tools.get_resources_left_stopped( simulated_operations, exclude=resource_ids) + simulate_tools.get_resources_left_demoted( simulated_operations, exclude=resource_ids)) if other_affected: raise LibraryError( reports.resource_disable_affects_other_resources( resource_ids, other_affected, plaintext_status, ))