Merge "Add debug logs to server_group_affinity_constraint"
This commit is contained in:
commit
5af1c0bd5b
|
@ -13,8 +13,12 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
||||
from nova_solverscheduler.scheduler.solvers import constraints
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ServerGroupAffinityConstraint(constraints.BaseLinearConstraint):
|
||||
"""Force to select hosts which host given server group."""
|
||||
|
@ -36,6 +40,9 @@ class ServerGroupAffinityConstraint(constraints.BaseLinearConstraint):
|
|||
|
||||
group_hosts = filter_properties.get('group_hosts')
|
||||
|
||||
LOG.debug('Group hosts: %(hosts)s.',
|
||||
{'hosts': ', '.join(group_hosts)})
|
||||
|
||||
if not group_hosts:
|
||||
constraint_matrix = [
|
||||
([False for j in xrange(num_instances - 1)] + [True])
|
||||
|
@ -45,6 +52,9 @@ class ServerGroupAffinityConstraint(constraints.BaseLinearConstraint):
|
|||
if hosts[i].host not in group_hosts:
|
||||
constraint_matrix[i] = [False for
|
||||
j in xrange(num_instances)]
|
||||
else:
|
||||
LOG.debug('%(host)s is in group hosts.',
|
||||
{'host': hosts[i].host})
|
||||
|
||||
return constraint_matrix
|
||||
|
||||
|
@ -70,9 +80,14 @@ class ServerGroupAntiAffinityConstraint(constraints.BaseLinearConstraint):
|
|||
|
||||
group_hosts = filter_properties.get('group_hosts')
|
||||
|
||||
LOG.debug('Group hosts: %(hosts)s.',
|
||||
{'hosts': ', '.join(group_hosts)})
|
||||
|
||||
for i in xrange(num_hosts):
|
||||
if hosts[i].host in group_hosts:
|
||||
constraint_matrix[i] = [False for j in xrange(num_instances)]
|
||||
LOG.debug('%(host)s is in group hosts.',
|
||||
{'host': hosts[i].host})
|
||||
else:
|
||||
constraint_matrix[i] = ([True] + [False for
|
||||
j in xrange(num_instances - 1)])
|
||||
|
|
Loading…
Reference in New Issue