Martin Sivák has posted comments on this change.

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


Patch Set 4:

(2 comments)

I think the example policy will have to be modified as well. And also the 
policy shipped with vdsm.

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

Line 101:         """
Line 102:         if (len(self.statistics) == 0):
Line 103:             raise EntityError("Statistic '%s' not available" % name)
Line 104:         total = 0
Line 105:         nonEmptyStats = [x for x in self.statistics \
I agree with this.
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 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)
But I do not like this. This will cause the ballooning logic to see all zeros 
when no guest agent is available and I have no idea what will happen...

I would prefer returning None here and conditionally checking it in the policy 
using:

(if (valid guest.mem_total guest.StatAvg("field")) (do something))

Adding valid to Parser.py would be easy:

    def c_valid(self, *args):
        try:
            return not any(v is None for v in args)
        except TypeError:
            # some value is not null and not iterable
            return False
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