filter exclude instances during migration
Change-Id: Ib5e0d285de0f25515702890778aca5e6417befaf Implements:blueprint compute-cdm-include-all-instances
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
Openstack implementation of the cluster graph.
|
||||
"""
|
||||
|
||||
import ast
|
||||
from lxml import etree
|
||||
import networkx as nx
|
||||
from oslo_concurrency import lockutils
|
||||
@@ -225,6 +226,8 @@ class ModelRoot(nx.DiGraph, base.Model):
|
||||
|
||||
for inst in root.findall('.//Instance'):
|
||||
instance = element.Instance(**inst.attrib)
|
||||
instance.watcher_exclude = ast.literal_eval(
|
||||
inst.attrib["watcher_exclude"])
|
||||
model.add_instance(instance)
|
||||
|
||||
parent = inst.getparent()
|
||||
|
||||
@@ -372,6 +372,11 @@ class BasicConsolidation(base.ServerConsolidationBaseStrategy):
|
||||
sorted_score):
|
||||
number_migrations = 0
|
||||
for mig_instance, __ in sorted_instances:
|
||||
# skip exclude instance when migrating
|
||||
if mig_instance.watcher_exclude:
|
||||
LOG.debug("Instance is excluded by scope, "
|
||||
"skipped: %s", mig_instance.uuid)
|
||||
continue
|
||||
for node_uuid, __ in sorted_score:
|
||||
mig_source_node = self.compute_model.get_node_by_uuid(
|
||||
node_to_release)
|
||||
|
||||
@@ -211,6 +211,11 @@ class OutletTempControl(base.ThermalOptimizationBaseStrategy):
|
||||
mig_source_node)
|
||||
for instance in instances_of_src:
|
||||
try:
|
||||
# NOTE: skip exclude instance when migrating
|
||||
if instance.watcher_exclude:
|
||||
LOG.debug("Instance is excluded by scope, "
|
||||
"skipped: %s", instance.uuid)
|
||||
continue
|
||||
# select the first active instance to migrate
|
||||
if (instance.state !=
|
||||
element.InstanceState.ACTIVE.value):
|
||||
|
||||
@@ -240,6 +240,11 @@ class UniformAirflow(base.BaseStrategy):
|
||||
else:
|
||||
# migrate the first active instance
|
||||
for instance in source_instances:
|
||||
# NOTE: skip exclude instance when migrating
|
||||
if instance.watcher_exclude:
|
||||
LOG.debug("Instance is excluded by scope, "
|
||||
"skipped: %s", instance.uuid)
|
||||
continue
|
||||
if (instance.state !=
|
||||
element.InstanceState.ACTIVE.value):
|
||||
LOG.info(
|
||||
|
||||
@@ -504,6 +504,11 @@ class VMWorkloadConsolidation(base.ServerConsolidationBaseStrategy):
|
||||
key=lambda x: self.get_instance_utilization(
|
||||
x)['cpu']
|
||||
):
|
||||
# skip exclude instance when migrating
|
||||
if instance.watcher_exclude:
|
||||
LOG.debug("Instance is excluded by scope, "
|
||||
"skipped: %s", instance.uuid)
|
||||
continue
|
||||
for destination_node in reversed(sorted_nodes):
|
||||
if self.instance_fits(
|
||||
instance, destination_node, cc):
|
||||
@@ -536,6 +541,11 @@ class VMWorkloadConsolidation(base.ServerConsolidationBaseStrategy):
|
||||
self.compute_model.get_node_instances(node),
|
||||
key=lambda x: self.get_instance_utilization(x)['cpu'])
|
||||
for instance in reversed(instances):
|
||||
# skip exclude instance when migrating
|
||||
if instance.watcher_exclude:
|
||||
LOG.debug("Instance is excluded by scope, "
|
||||
"skipped: %s", instance.uuid)
|
||||
continue
|
||||
dsc = len(sorted_nodes) - 1
|
||||
for destination_node in reversed(sorted_nodes):
|
||||
if asc >= dsc:
|
||||
|
||||
@@ -208,6 +208,11 @@ class WorkloadBalance(base.WorkloadStabilizationBaseStrategy):
|
||||
instance_id = None
|
||||
for instance in source_instances:
|
||||
try:
|
||||
# NOTE: skip exclude instance when migrating
|
||||
if instance.watcher_exclude:
|
||||
LOG.debug("Instance is excluded by scope, "
|
||||
"skipped: %s", instance.uuid)
|
||||
continue
|
||||
# select the first active VM to migrate
|
||||
if (instance.state !=
|
||||
element.InstanceState.ACTIVE.value):
|
||||
|
||||
@@ -347,10 +347,15 @@ class WorkloadStabilization(base.WorkloadStabilizationBaseStrategy):
|
||||
c_nodes.remove(src_host)
|
||||
node_list = yield_nodes(c_nodes)
|
||||
for instance in self.compute_model.get_node_instances(src_node):
|
||||
min_sd_case = {'value': current_weighted_sd}
|
||||
# NOTE: skip exclude instance when migrating
|
||||
if instance.watcher_exclude:
|
||||
LOG.debug("Instance is excluded by scope, "
|
||||
"skipped: %s", instance.uuid)
|
||||
continue
|
||||
if instance.state not in [element.InstanceState.ACTIVE.value,
|
||||
element.InstanceState.PAUSED.value]:
|
||||
continue
|
||||
min_sd_case = {'value': current_weighted_sd}
|
||||
for dst_host in next(node_list):
|
||||
dst_node = self.compute_model.get_node_by_uuid(dst_host)
|
||||
sd_case = self.calculate_migration_case(
|
||||
|
||||
Reference in New Issue
Block a user