1717from pprint import pprint as pp
1818
1919from f5 .bigip .mixins import UnsupportedTmosVersion
20- from f5 .bigip .resource import OrganizingCollection
2120from f5 .bigip .resource import Collection
21+ from f5 .bigip .resource import OrganizingCollection
22+
2223
2324def register_collection_atoms (collection ):
2425 '''Given a collection return a registry of all of its atoms (elements).
@@ -39,7 +40,7 @@ def register_collection_atoms(collection):
3940 pp (resource .raw )
4041 raise ex
4142 return resource_registry
42-
43+
4344
4445def register_OC_atoms (organizing_collection ):
4546 '''Given an OrganizingCollection (OC) return a registry of its atoms.
@@ -60,11 +61,18 @@ def register_OC_atoms(organizing_collection):
6061 OC_atoms_registry .update (register_collection_atoms (lazy_instance ))
6162 elif isinstance (lazy_instance , OrganizingCollection ):
6263 OC_atoms_registry .update (register_OC_atoms (lazy_instance ))
63- #else:
64- # OC_atoms_registry.update({lazy_instance.selfLink: lazy_instance})
6564 return OC_atoms_registry
6665
6766
67+ def register_device (mgmt_rt ):
68+ OCs = [getattr (mgmt_rt , c .__name__ .lower ())
69+ for c in mgmt_rt ._meta_data ['allowed_lazy_attributes' ]]
70+ grand_registry = {}
71+ for OC in OCs :
72+ grand_registry .update (register_OC_atoms (OC ))
73+ return grand_registry
74+
75+
6876def register_loadbalancer_elements (mgmt_rt ):
6977 monitor_registry = register_OC_atoms (mgmt_rt .tm .ltm .monitor )
7078 pool_registry = register_collection_atoms (mgmt_rt .tm .ltm .pools )
@@ -75,7 +83,7 @@ def register_loadbalancer_elements(mgmt_rt):
7583 member_registry = {}
7684 for pool in pool_registry .values ():
7785 mc = pool .members_s
78- member_registry .update (reqister_collection_atoms (mc ))
86+ member_registry .update (register_collection_atoms (mc ))
7987 folder_registry = register_collection_atoms (mgmt_rt .tm .sys .folders )
8088 registries = {'monitor_registry' : monitor_registry ,
8189 'pool_registry' : pool_registry ,
0 commit comments