diff --git a/watcher/decision_engine/strategy/strategies/vm_workload_consolidation.py b/watcher/decision_engine/strategy/strategies/vm_workload_consolidation.py index 46d71df29..b1d9c1241 100644 --- a/watcher/decision_engine/strategy/strategies/vm_workload_consolidation.py +++ b/watcher/decision_engine/strategy/strategies/vm_workload_consolidation.py @@ -50,7 +50,7 @@ class VMWorkloadConsolidation(base.ServerConsolidationBaseStrategy): * Offload phase - handling over-utilized resources * Consolidation phase - handling under-utilized resources * Solution optimization - reducing number of migrations - * Deactivation of unused hypervisors + * Disability of unused hypervisors A capacity coefficients (cc) might be used to adjust optimization thresholds. Different resources may require different coefficient @@ -131,26 +131,26 @@ class VMWorkloadConsolidation(base.ServerConsolidationBaseStrategy): st=type(state)) raise exception.WatcherException - def add_action_activate_hypervisor(self, hypervisor): - """Add an action for hypervisor activation into the solution. + def add_action_enable_hypervisor(self, hypervisor): + """Add an action for hypervisor enabler into the solution. :param hypervisor: hypervisor object :return: None """ - params = {'state': hyper_state.HypervisorState.ONLINE.value} + params = {'state': hyper_state.HypervisorState.ENABLED.value} self.solution.add_action( action_type='change_nova_service_state', resource_id=hypervisor.uuid, input_parameters=params) self.number_of_released_hypervisors -= 1 - def add_action_deactivate_hypervisor(self, hypervisor): - """Add an action for hypervisor deactivation into the solution. + def add_action_disable_hypervisor(self, hypervisor): + """Add an action for hypervisor disablity into the solution. :param hypervisor: hypervisor object :return: None """ - params = {'state': hyper_state.HypervisorState.OFFLINE.value} + params = {'state': hyper_state.HypervisorState.DISABLED.value} self.solution.add_action( action_type='change_nova_service_state', resource_id=hypervisor.uuid, @@ -184,8 +184,8 @@ class VMWorkloadConsolidation(base.ServerConsolidationBaseStrategy): migration_type = 'live' dst_hyper_state_str = self.get_state_str(dst_hypervisor.state) - if dst_hyper_state_str == hyper_state.HypervisorState.OFFLINE.value: - self.add_action_activate_hypervisor(dst_hypervisor) + if dst_hyper_state_str == hyper_state.HypervisorState.DISABLED.value: + self.add_action_enable_hypervisor(dst_hypervisor) model.get_mapping().unmap(src_hypervisor, vm) model.get_mapping().map(dst_hypervisor, vm) @@ -197,8 +197,8 @@ class VMWorkloadConsolidation(base.ServerConsolidationBaseStrategy): input_parameters=params) self.number_of_migrations += 1 - def deactivate_unused_hypervisors(self, model): - """Generate actions for deactivation of unused hypervisors. + def disable_unused_hypervisors(self, model): + """Generate actions for disablity of unused hypervisors. :param model: model_root object :return: None @@ -207,7 +207,7 @@ class VMWorkloadConsolidation(base.ServerConsolidationBaseStrategy): if (len(model.get_mapping().get_node_vms(hypervisor)) == 0 and hypervisor.status != hyper_state.HypervisorState.DISABLED.value): - self.add_action_deactivate_hypervisor(hypervisor) + self.add_action_disable_hypervisor(hypervisor) def get_prediction_model(self): """Return a deepcopy of a model representing current cluster state. @@ -339,7 +339,7 @@ class VMWorkloadConsolidation(base.ServerConsolidationBaseStrategy): counters = {} for hypervisor in hypervisors: hyper_state_str = self.get_state_str(hypervisor.state) - if hyper_state_str == hyper_state.HypervisorState.ONLINE.value: + if hyper_state_str == hyper_state.HypervisorState.ENABLED.value: rhu = self.get_relative_hypervisor_utilization( hypervisor, model) for k in rhu.keys(): @@ -437,12 +437,12 @@ class VMWorkloadConsolidation(base.ServerConsolidationBaseStrategy): the least CPU utilized VM first as live migration these generaly causes less troubles. This phase results in a cluster with no overloaded hypervisors. - * This phase is be able to activate turned off hypervisors (if needed + * This phase is be able to enable disabled hypervisors (if needed and any available) in the case of the resource capacity provided by active hypervisors is not able to accomodate all the load. As the offload phase is later followed by the consolidation phase, - the hypervisor activation in this phase doesn't necessarily results - in more activated hypervisors in the final solution. + the hypervisor enabler in this phase doesn't necessarily results + in more enabled hypervisors in the final solution. :param model: model_root object :param cc: dictionary containing resource capacity coefficients @@ -514,7 +514,7 @@ class VMWorkloadConsolidation(base.ServerConsolidationBaseStrategy): * Offload phase - handling over-utilized resources * Consolidation phase - handling under-utilized resources * Solution optimization - reducing number of migrations - * Deactivation of unused hypervisors + * Disability of unused hypervisors :param original_model: root_model object """ @@ -534,8 +534,8 @@ class VMWorkloadConsolidation(base.ServerConsolidationBaseStrategy): # Optimize solution self.optimize_solution(model) - # Deactivate unused hypervisors - self.deactivate_unused_hypervisors(model) + # disable unused hypervisors + self.disable_unused_hypervisors(model) rcu_after = self.get_relative_cluster_utilization(model) info = { diff --git a/watcher/tests/decision_engine/strategy/strategies/faker_cluster_and_metrics.py b/watcher/tests/decision_engine/strategy/strategies/faker_cluster_and_metrics.py index 5801c5ae9..c96189646 100644 --- a/watcher/tests/decision_engine/strategy/strategies/faker_cluster_and_metrics.py +++ b/watcher/tests/decision_engine/strategy/strategies/faker_cluster_and_metrics.py @@ -56,7 +56,7 @@ class FakerModelCollector(base.BaseClusterModelCollector): node = hypervisor.Hypervisor() node.uuid = node_uuid node.hostname = "hostname_{0}".format(i) - node.state = 'up' + node.state = 'enabled' mem.set_capacity(node, 64) disk_capacity.set_capacity(node, 250) diff --git a/watcher/tests/decision_engine/strategy/strategies/test_vm_workload_consolidation.py b/watcher/tests/decision_engine/strategy/strategies/test_vm_workload_consolidation.py index d53db73f5..5dbd1b101 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_vm_workload_consolidation.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_vm_workload_consolidation.py @@ -149,44 +149,44 @@ class TestVMWorkloadConsolidation(base.BaseTestCase): res = self.strategy.vm_fits(vm_uuid, h, model, cc) self.assertEqual(False, res) - def test_add_action_activate_hypervisor(self): + def test_add_action_enable_hypervisor(self): model = self.fake_cluster.generate_scenario_1() self.m_model.return_value = model self.fake_metrics.model = model h = model.get_hypervisor_from_id('Node_0') - self.strategy.add_action_activate_hypervisor(h) + self.strategy.add_action_enable_hypervisor(h) expected = [{'action_type': 'change_nova_service_state', - 'input_parameters': {'state': 'up', + 'input_parameters': {'state': 'enabled', 'resource_id': 'Node_0'}}] self.assertEqual(expected, self.strategy.solution.actions) - def test_add_action_deactivate_hypervisor(self): + def test_add_action_disable_hypervisor(self): model = self.fake_cluster.generate_scenario_1() self.m_model.return_value = model self.fake_metrics.model = model h = model.get_hypervisor_from_id('Node_0') - self.strategy.add_action_deactivate_hypervisor(h) + self.strategy.add_action_disable_hypervisor(h) expected = [{'action_type': 'change_nova_service_state', - 'input_parameters': {'state': 'down', + 'input_parameters': {'state': 'disabled', 'resource_id': 'Node_0'}}] self.assertEqual(expected, self.strategy.solution.actions) - def test_deactivate_unused_hypervisors(self): + def test_disable_unused_hypervisors(self): model = self.fake_cluster.generate_scenario_1() self.m_model.return_value = model self.fake_metrics.model = model h1 = model.get_hypervisor_from_id('Node_0') h2 = model.get_hypervisor_from_id('Node_1') vm_uuid = 'VM_0' - self.strategy.deactivate_unused_hypervisors(model) + self.strategy.disable_unused_hypervisors(model) self.assertEqual(0, len(self.strategy.solution.actions)) # Migrate VM to free the hypervisor self.strategy.add_migration(vm_uuid, h1, h2, model) - self.strategy.deactivate_unused_hypervisors(model) + self.strategy.disable_unused_hypervisors(model) expected = {'action_type': 'change_nova_service_state', - 'input_parameters': {'state': 'down', + 'input_parameters': {'state': 'disabled', 'resource_id': 'Node_0'}} self.assertEqual(2, len(self.strategy.solution.actions)) self.assertEqual(expected, self.strategy.solution.actions[1])