logger.debug('All hosts: {}'.format(candidates))
return candidates
+ # respect host_pattern
+ if self.spec.placement.host_pattern:
+ candidates = [
+ HostPlacementSpec(x, '', '')
+ for x in self.spec.placement.pattern_matches_hosts(self.get_hosts_func(None))
+ ]
+ logger.debug('All hosts: {}'.format(candidates))
+ return candidates
+
count = 0
if self.spec.placement.hosts and \
self.spec.placement.count and \
[],
['host1', 'host2', 'host3']
),
+ # host_pattern
+ NodeAssignmentTest(
+ 'mon',
+ PlacementSpec(host_pattern='mon*'),
+ 'monhost1 monhost2 datahost'.split(),
+ [],
+ ['monhost1', 'monhost2']
+ ),
])
def test_node_assignment(service_type, placement, hosts, daemons, expected):
hosts = HostAssignment(
def pattern_matches_hosts(self, all_hosts):
# type: (List[str]) -> List[str]
- return fnmatch.filter(all_hosts, self.host_pattern) # type: ignore
+ if not self.host_pattern:
+ return []
+ return fnmatch.filter(all_hosts, self.host_pattern)
def pretty_str(self):
kv = []