def filter_hosts(self): """ Look for a 'hosts' list in self.config. Each item in the list may either be a role or a hostname. Builds a new Cluster object containing only those hosts which match one (or more) of the roles or hostnames specified. The filtered Cluster object is stored as self.cluster so that the task may only run against those hosts. """ if not hasattr(self.ctx, 'cluster'): return elif 'hosts' not in self.config: self.cluster = self.ctx.cluster return self.cluster host_specs = self.config.get('hosts', list()) cluster = Cluster() for host_spec in host_specs: role_matches = self.ctx.cluster.only(host_spec) if len(role_matches.remotes) > 0: for (remote, roles) in role_matches.remotes.iteritems(): cluster.add(remote, roles) elif isinstance(host_spec, basestring): for (remote, roles) in self.ctx.cluster.remotes.iteritems(): if remote.name.split('@')[-1] == host_spec or \ remote.shortname == host_spec: cluster.add(remote, roles) if not cluster.remotes: raise RuntimeError("All target hosts were excluded!") self.cluster = cluster hostnames = [h.shortname for h in self.cluster.remotes.keys()] self.log.debug("Restricting task {name} to hosts: {hosts}".format( name=self.name, hosts=' '.join(hostnames)) ) return self.cluster
def filter_hosts(self): """ Look for a 'hosts' list in self.config. Each item in the list may either be a role or a hostname. Builds a new Cluster object containing only those hosts which match one (or more) of the roles or hostnames specified. The filtered Cluster object is stored as self.cluster so that the task may only run against those hosts. """ if not hasattr(self.ctx, 'cluster'): return elif 'hosts' not in self.config: self.cluster = self.ctx.cluster return self.cluster host_specs = self.config.get('hosts', list()) cluster = Cluster() for host_spec in host_specs: role_matches = self.ctx.cluster.only(host_spec) if len(role_matches.remotes) > 0: for (remote, roles) in role_matches.remotes.iteritems(): cluster.add(remote, roles) elif isinstance(host_spec, basestring): for (remote, roles) in self.ctx.cluster.remotes.iteritems(): if remote.name.split('@')[-1] == host_spec or \ remote.shortname == host_spec: cluster.add(remote, roles) if not cluster.remotes: raise RuntimeError("All target hosts were excluded!") self.cluster = cluster hostnames = [h.shortname for h in self.cluster.remotes.keys()] self.log.debug("Restricting task {name} to hosts: {hosts}".format( name=self.name, hosts=' '.join(hostnames))) return self.cluster
def filter_hosts(self): """ Exclude any non-RPM-based hosts, and any downburst VMs """ super(SELinux, self).filter_hosts() new_cluster = Cluster() for (remote, roles) in self.cluster.remotes.items(): if remote.is_vm: msg = "Excluding {host}: VMs are not yet supported" log.info(msg.format(host=remote.shortname)) elif remote.is_container: msg = "Excluding {host}: containers are not yet supported" log.info(msg.format(host=remote.shortname)) elif remote.os.name in ['opensuse', 'sle']: msg = "Excluding {host}: \ SELinux is not supported for '{os}' os_type yet" log.info(msg.format(host=remote.shortname, os=remote.os.name)) elif remote.os.package_type == 'rpm': new_cluster.add(remote, roles) else: msg = "Excluding {host}: OS '{os}' does not support SELinux" log.debug(msg.format(host=remote.shortname, os=remote.os.name)) self.cluster = new_cluster return self.cluster
def filter_hosts(self): """ Exclude any non-RPM-based hosts, and any downburst VMs """ super(SELinux, self).filter_hosts() new_cluster = Cluster() for (remote, roles) in self.cluster.remotes.iteritems(): if remote.is_vm: msg = "Excluding {host}: VMs are not yet supported" log.info(msg.format(host=remote.shortname)) elif remote.os.package_type == 'rpm': new_cluster.add(remote, roles) else: msg = "Excluding {host}: OS '{os}' does not support SELinux" log.debug(msg.format(host=remote.shortname, os=remote.os.name)) self.cluster = new_cluster return self.cluster
def filter_hosts(self): """ Exclude any non-RPM-based hosts, and any downburst VMs """ super(SELinux, self).filter_hosts() new_cluster = Cluster() for (remote, roles) in self.cluster.remotes.iteritems(): if remote.shortname.startswith('vpm'): msg = "Excluding {host}: downburst VMs are not yet supported" log.info(msg.format(host=remote.shortname)) elif remote.os.package_type == 'rpm': new_cluster.add(remote, roles) else: msg = "Excluding {host}: OS '{os}' does not support SELinux" log.debug(msg.format(host=remote.shortname, os=remote.os.name)) self.cluster = new_cluster return self.cluster
def filter_hosts(self): super(ConsoleLog, self).filter_hosts() if not hasattr(self.ctx, 'cluster'): return new_cluster = Cluster() for (remote, roles) in self.cluster.remotes.iteritems(): if not hasattr(remote.console, 'spawn_sol_log'): log.debug("%s does not support IPMI; excluding", remote.shortname) elif not (remote.console.has_ipmi_credentials or remote.console.has_conserver): log.debug("Cannot find IPMI credentials or conserver settings " "for %s; excluding", remote.shortname) else: new_cluster.add(remote, roles) self.cluster = new_cluster return self.cluster
def filter_hosts(self): super(ConsoleLog, self).filter_hosts() if not hasattr(self.ctx, 'cluster'): return new_cluster = Cluster() for (remote, roles) in self.cluster.remotes.iteritems(): if not hasattr(remote.console, 'spawn_sol_log'): log.debug("%s does not support IPMI; excluding", remote.shortname) elif not (remote.console.has_ipmi_credentials or remote.console.has_conserver): log.debug( "Cannot find IPMI credentials or conserver settings " "for %s; excluding", remote.shortname) else: new_cluster.add(remote, roles) self.cluster = new_cluster return self.cluster