diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-05-03 09:02:54 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-05-03 09:02:54 +0000 |
| commit | 00daebb7d12e6b78cc77f9d6eaaa19e940b21b38 (patch) | |
| tree | 24d07b1711e5ab4c92890da5f559c392810455c7 /nova/scheduler | |
| parent | 2299d37be96630108672d733de14df9b605d7e05 (diff) | |
| parent | c42fd6de5903cdb7c5519bd773e0859767f68043 (diff) | |
| download | nova-00daebb7d12e6b78cc77f9d6eaaa19e940b21b38.tar.gz nova-00daebb7d12e6b78cc77f9d6eaaa19e940b21b38.tar.xz nova-00daebb7d12e6b78cc77f9d6eaaa19e940b21b38.zip | |
Merge "Add force_nodes to filter properties"
Diffstat (limited to 'nova/scheduler')
| -rw-r--r-- | nova/scheduler/host_manager.py | 66 |
1 files changed, 46 insertions, 20 deletions
diff --git a/nova/scheduler/host_manager.py b/nova/scheduler/host_manager.py index d12f15f38..9dbe6bd67 100644 --- a/nova/scheduler/host_manager.py +++ b/nova/scheduler/host_manager.py @@ -300,40 +300,66 @@ class HostManager(object): def _strip_ignore_hosts(host_map, hosts_to_ignore): ignored_hosts = [] for host in hosts_to_ignore: - if host in host_map: - del host_map[host] - ignored_hosts.append(host) + for (hostname, nodename) in host_map.keys(): + if host == hostname: + del host_map[(hostname, nodename)] + ignored_hosts.append(host) ignored_hosts_str = ', '.join(ignored_hosts) - msg = _('Host filter ignoring hosts: %(ignored_hosts_str)s') - LOG.debug(msg, locals()) + msg = _('Host filter ignoring hosts: %s') + LOG.debug(msg % ignored_hosts_str) def _match_forced_hosts(host_map, hosts_to_force): - for host in host_map.keys(): - if host not in hosts_to_force: - del host_map[host] - if not host_map: + forced_hosts = [] + for (hostname, nodename) in host_map.keys(): + if hostname not in hosts_to_force: + del host_map[(hostname, nodename)] + else: + forced_hosts.append(hostname) + if host_map: + forced_hosts_str = ', '.join(forced_hosts) + msg = _('Host filter forcing available hosts to %s') + else: forced_hosts_str = ', '.join(hosts_to_force) - msg = _("No hosts matched due to not matching 'force_hosts'" - "value of '%(forced_hosts_str)s'") - LOG.debug(msg, locals()) - return - forced_hosts_str = ', '.join(host_map.iterkeys()) - msg = _('Host filter forcing available hosts to ' - '%(forced_hosts_str)s') - LOG.debug(msg, locals()) + msg = _("No hosts matched due to not matching " + "'force_hosts' value of '%s'") + LOG.debug(msg % forced_hosts_str) + + def _match_forced_nodes(host_map, nodes_to_force): + forced_nodes = [] + for (hostname, nodename) in host_map.keys(): + if nodename not in nodes_to_force: + del host_map[(hostname, nodename)] + else: + forced_nodes.append(nodename) + if host_map: + forced_nodes_str = ', '.join(forced_nodes) + msg = _('Host filter forcing available nodes to %s') + else: + forced_nodes_str = ', '.join(nodes_to_force) + msg = _("No nodes matched due to not matching " + "'force_nodes' value of '%s'") + LOG.debug(msg % forced_nodes_str) filter_classes = self._choose_host_filters(filter_class_names) ignore_hosts = filter_properties.get('ignore_hosts', []) force_hosts = filter_properties.get('force_hosts', []) - if ignore_hosts or force_hosts: - name_to_cls_map = dict([(x.host, x) for x in hosts]) + force_nodes = filter_properties.get('force_nodes', []) + + if ignore_hosts or force_hosts or force_nodes: + # NOTE(deva): we can't assume "host" is unique because + # one host may have many nodes. + name_to_cls_map = dict([((x.host, x.nodename), x) for x in hosts]) if ignore_hosts: _strip_ignore_hosts(name_to_cls_map, ignore_hosts) if not name_to_cls_map: return [] + # NOTE(deva): allow force_hosts and force_nodes independently if force_hosts: _match_forced_hosts(name_to_cls_map, force_hosts) - # NOTE(vish): Skip filters on forced hosts. + if force_nodes: + _match_forced_nodes(name_to_cls_map, force_nodes) + if force_hosts or force_nodes: + # NOTE(deva): Skip filters when forcing host or node if name_to_cls_map: return name_to_cls_map.values() hosts = name_to_cls_map.itervalues() |
