summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugins/Metadata.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2013-08-29 08:04:31 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2013-08-29 08:04:31 -0400
commit557446e489f3fdf6a66a6d2494cbda726117c7ac (patch)
treea09e6c18ef482411ee4609d076ac468e8d6bb005 /src/lib/Bcfg2/Server/Plugins/Metadata.py
parent7c4692049d3c50de30127dae5555b7f228375c57 (diff)
downloadbcfg2-557446e489f3fdf6a66a6d2494cbda726117c7ac.tar.gz
bcfg2-557446e489f3fdf6a66a6d2494cbda726117c7ac.tar.bz2
bcfg2-557446e489f3fdf6a66a6d2494cbda726117c7ac.zip
Metadata: get_client_names_by_* fixes
Fixed long lines. Improved efficiency by avoiding multiple loops over the same data.
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins/Metadata.py')
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Metadata.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Metadata.py b/src/lib/Bcfg2/Server/Plugins/Metadata.py
index ece852ad7..abda4376e 100644
--- a/src/lib/Bcfg2/Server/Plugins/Metadata.py
+++ b/src/lib/Bcfg2/Server/Plugins/Metadata.py
@@ -1274,7 +1274,7 @@ class Metadata(Bcfg2.Server.Plugin.Metadata,
def get_client_names_by_profiles(self, profiles):
""" return a list of names of clients in the given profile groups """
rv = []
- for client in list(self.list_clients()):
+ for client in self.list_clients():
mdata = self.core.build_metadata(client)
if mdata.profile in profiles:
rv.append(client)
@@ -1282,14 +1282,22 @@ class Metadata(Bcfg2.Server.Plugin.Metadata,
def get_client_names_by_groups(self, groups):
""" return a list of names of clients in the given groups """
- mdata = [self.core.build_metadata(client) for client in self.list_clients()]
- return [md.hostname for md in mdata if md.groups.issuperset(groups)]
+ rv = []
+ for client in self.list_clients():
+ mdata = self.core.build_metadata(client)
+ if mdata.groups.issuperset(groups):
+ rv.append(client)
+ return rv
def get_client_names_by_bundles(self, bundles):
""" given a list of bundles, return a list of names of clients
that use those bundles """
- mdata = [self.core.build_metadata(client) for client in self.list_clients()]
- return [md.hostname for md in mdata if md.bundles.issuperset(bundles)]
+ rv = []
+ for client in self.list_clients():
+ mdata = self.core.build_metadata(client)
+ if mdata.bundles.issuperset(bundles):
+ rv.append(client)
+ return rv
def merge_additional_groups(self, imd, groups):
for group in groups: