Use hostgroup_find(all=True) returns member hosts of all hostgroups in a single call (#29106)
This commit is contained in:
parent
2cdbde524b
commit
b34d150bec
1 changed files with 1 additions and 6 deletions
|
@ -5,7 +5,6 @@
|
||||||
import argparse
|
import argparse
|
||||||
from ipalib import api
|
from ipalib import api
|
||||||
import json
|
import json
|
||||||
from distutils.version import StrictVersion
|
|
||||||
|
|
||||||
|
|
||||||
def initialize():
|
def initialize():
|
||||||
|
@ -35,15 +34,11 @@ def list_groups(api):
|
||||||
inventory = {}
|
inventory = {}
|
||||||
hostvars = {}
|
hostvars = {}
|
||||||
|
|
||||||
ipa_version = api.Command.env()['result']['version']
|
result = api.Command.hostgroup_find(all=True)['result']
|
||||||
result = api.Command.hostgroup_find()['result']
|
|
||||||
|
|
||||||
for hostgroup in result:
|
for hostgroup in result:
|
||||||
# Get direct and indirect members (nested hostgroups) of hostgroup
|
# Get direct and indirect members (nested hostgroups) of hostgroup
|
||||||
members = []
|
members = []
|
||||||
if StrictVersion(ipa_version) >= StrictVersion('4.0.0'):
|
|
||||||
hostgroup_name = hostgroup['cn'][0]
|
|
||||||
hostgroup = api.Command.hostgroup_show(hostgroup_name)['result']
|
|
||||||
|
|
||||||
if 'member_host' in hostgroup:
|
if 'member_host' in hostgroup:
|
||||||
members = [host for host in hostgroup['member_host']]
|
members = [host for host in hostgroup['member_host']]
|
||||||
|
|
Loading…
Reference in a new issue