def init_resource(self): sections = self.cf.sections() for section in sections: if section.startswith(self.cf_item): hosts = [] host_names = utils.get_items(self.cf.get(section, 'targets')) for item in host_names: hosts.extend(operations.get_host_list(item)) all_hosts = self.vc.get_hosts() host_list = [host for host in all_hosts if host.name() in hosts] self.item_dict[section] = host_list
def maintenance(args): vc = _get_vc() hosts = operations.get_host_list(args.hosts) for host_name in hosts: host = vc.get_host_by_name(host_name) host.maintenance(args.action)