Martin Sivák has posted comments on this change.
Change subject: Remove Collector.instance
......................................................................
Patch Set 2: (2 inline comments)
This is just an idea, otherwise I am OK with the change.
....................................................
File mom/Collectors/Collector.py
Line 74:
Line 75: # Create an instance
Line 76: try:
Line 77: module = __import__('mom.Collectors.' + name, None, None,
name)
Line 78: collectors.append(getattr(module, name)(properties))
I would even go one step further to prevent possible naming mistakes (and to
allow multiple independent classes in one file).
collectors.extend([ getattr(module, n)(properties)
for n in dir(module)
if isinstance(getattr(module, n), type) and
issubclass(getattr(module, n), Collector) ])
But if that is too meta for you, just scratch that..
Line 79: except ImportError:
Line 80: logger.warn("Unable to import collector: %s", name)
Line 81: return None
Line 82: except FatalError, e:
....................................................
File mom/PolicyEngine.py
Line 98: self.logger.debug("Loaded %s controller", name)
Line 99: except ImportError:
Line 100: self.logger.warn("Unable to import controller: %s",
name)
Line 101: continue
Line 102: self.controllers.append(getattr(module,
name)(self.properties))
My other comment applies here as well.. I would enumerate all classes from the
module and use all that are derived from the proper parent.
Line 103:
Line 104: def do_controls(self):
Line 105: """
Line 106: Sample host and guest data, process the rule set and feed the
results
--
To view, visit http://gerrit.ovirt.org/13762
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: Icb49d7397fadae141caad61033151d527ea9752c
Gerrit-PatchSet: 2
Gerrit-Project: mom
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <[email protected]>
Gerrit-Reviewer: Adam Litke <[email protected]>
Gerrit-Reviewer: Martin Sivák <[email protected]>
Gerrit-Reviewer: Mei Liu <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches