if ssh_config is None or len(ssh_config.strip()) == 0:
raise OrchestratorValidationError('ssh_config cannot be empty')
# StrictHostKeyChecking is [yes|no] ?
- l = re.findall(r'StrictHostKeyChecking\s+.*', ssh_config)
- if not l:
+ res = re.findall(r'StrictHostKeyChecking\s+.*', ssh_config)
+ if not res:
raise OrchestratorValidationError('ssh_config requires StrictHostKeyChecking')
- for s in l:
+ for s in res:
if 'ask' in s.lower():
raise OrchestratorValidationError(f'ssh_config cannot contain: \'{s}\'')
return existing
-def merge_hostspecs(l: List[HostPlacementSpec], r: List[HostPlacementSpec]) -> Iterable[HostPlacementSpec]:
+def merge_hostspecs(lh: List[HostPlacementSpec], rh: List[HostPlacementSpec]) -> Iterable[HostPlacementSpec]:
"""
- Merge two lists of HostPlacementSpec by hostname. always returns `l` first.
+ Merge two lists of HostPlacementSpec by hostname. always returns `lh` first.
>>> list(merge_hostspecs([HostPlacementSpec(hostname='h', name='x', network='')],
... [HostPlacementSpec(hostname='h', name='y', network='')]))
[HostPlacementSpec(hostname='h', network='', name='x')]
"""
- l_names = {h.hostname for h in l}
- yield from l
- yield from (h for h in r if h.hostname not in l_names)
+ lh_names = {h.hostname for h in lh}
+ yield from lh
+ yield from (h for h in rh if h.hostname not in lh_names)
-def difference_hostspecs(l: List[HostPlacementSpec], r: List[HostPlacementSpec]) -> List[HostPlacementSpec]:
+def difference_hostspecs(lh: List[HostPlacementSpec], rh: List[HostPlacementSpec]) -> List[HostPlacementSpec]:
"""
- returns l "minus" r by hostname.
+ returns lh "minus" rh by hostname.
>>> list(difference_hostspecs([HostPlacementSpec(hostname='h1', name='x', network=''),
... HostPlacementSpec(hostname='h2', name='y', network='')],
[HostPlacementSpec(hostname='h1', network='', name='x')]
"""
- r_names = {h.hostname for h in r}
- return [h for h in l if h.hostname not in r_names]
+ rh_names = {h.hostname for h in rh}
+ return [h for h in lh if h.hostname not in rh_names]
def _get_device_locations(self, dev_id):
# type: (str) -> List[DeviceLightLoc]
locs = [d['location'] for d in self.get('devices')['devices'] if d['devid'] == dev_id]
- return [DeviceLightLoc(**l) for l in sum(locs, [])]
+ return [DeviceLightLoc(**loc) for loc in sum(locs, [])]
@_cli_read_command(prefix='device ls-lights')
def _device_ls(self) -> HandleCommandResult: