Adam Litke has posted comments on this change.

Change subject: GuestMemory fields should be optional
......................................................................


Patch Set 4:

(2 comments)

http://gerrit.ovirt.org/#/c/34528/4/mom/Entity.py
File mom/Entity.py:

Line 90:         Get the most-recently recorded value of a statistic
Line 91:         Returns None if no statistics are available
Line 92:         """
Line 93:         if len(self.statistics) > 0:
Line 94:             return self.statistics[-1].get('name', default)
> oops.  you want name, not 'name'.
Also, see my comment below.  I think if the value is missing and a default was 
not passed in we should report a special error and abort the policy execution 
for this cycle.  We should treat this case as an error in the policy file.
Line 95:         else:
Line 96:             return None
Line 97: 
Line 98:     def StatAvg(self, name):


Line 106:                          if x.get(name, None) is not None]
Line 107:         for row in nonEmptyStats:
Line 108:             total = total + row[name]
Line 109:         if (len(nonEmptyStats) == 0):
Line 110:             return float(0)
> I'd prefer that we use the same logic as for Stat().  That is, we add a def
Actually, I'm not sure I support the use of None at all.

Since the policy needs to be modified anyway to handle this, we might as well 
just specify a default value to StatAvg.  I think we should have a special 
error message that is printed when a value is missing and a default value was 
not requested.  In such cases we should abort the entire policy execution cycle 
since there was technically an error in the policy.
Line 111:         else:
Line 112:             return float(total / len(nonEmptyStats))
Line 113: 
Line 114:     def SetVar(self, name, val):


-- 
To view, visit http://gerrit.ovirt.org/34528
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I631056568b5a69e18f6ed02730c41ab59f460aad
Gerrit-PatchSet: 4
Gerrit-Project: mom
Gerrit-Branch: master
Gerrit-Owner: Roy Golan <rgo...@redhat.com>
Gerrit-Reviewer: Adam Litke <ali...@redhat.com>
Gerrit-Reviewer: Martin Sivák <msi...@redhat.com>
Gerrit-Reviewer: Roy Golan <rgo...@redhat.com>
Gerrit-Reviewer: automat...@ovirt.org
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to