# Path: mom/Collectors/GuestMemory.py
# class GuestMemory(Collector):
#     """
#     This Collector uses hypervisor interface to collect guest memory statistics
#     """
#     def getFields(self):
#         return {'mem_available', 'mem_unused', 'major_fault', 'minor_fault',
#                 'swap_in', 'swap_out'}
# 
#     def getOptionalFields(self):
#         return {"swap_total", "swap_usage"}
# 
#     def __init__(self, properties):
#         self.hypervisor_iface = properties['hypervisor_iface']
#         self.uuid = properties['uuid']
#         self.logger = logging.getLogger('mom.Collectors.GuestMemory')
#         self.hypervisor_iface.startVmMemoryStats(self.uuid)
#         self.memstats_available = True
# 
#     def stats_error(self, msg):
#         """
#         Only print stats interface errors one time when we first discover a
#         problem.  Otherwise the log will be overrun with noise.
#         """
#         if self.memstats_available:
#             self.logger.warn(msg)
#         self.memstats_available = False
# 
#     def collect(self):
#         try:
#             stat = self.hypervisor_iface.getVmMemoryStats(self.uuid)
#         except HypervisorInterfaceError as e:
#             self.stats_error('getVmMemoryStats(): %s' % e)
#             # We don't raise a CollectionError here because a different
#             # Collector (such as GuestQemuAgent) may be able to get them.
#             # If not, the Monitor's collect method will detect the missing
#             # fields anyway.
#             return {}
#         else:
#             self.memstats_available = True
#             return stat


from mom.Collectors.GuestMemory import GuestMemory


class GuestMemoryOptional(GuestMemory):
    """
    This Collector gets memory statistics in the same way GuestMemory does.
    The only difference is that it reports all the fields as optional and thus
    allows the policy to be evaluated even when the guest agent is not running.
    """

    def getFields(self):
        return set()

    def getOptionalFields(self):

# Path: mom/Collectors/GuestMemory.py
# class GuestMemory(Collector):
#     """
#     This Collector uses hypervisor interface to collect guest memory statistics
#     """
#     def getFields(self):
#         return {'mem_available', 'mem_unused', 'major_fault', 'minor_fault',
#                 'swap_in', 'swap_out'}
# 
#     def getOptionalFields(self):
#         return {"swap_total", "swap_usage"}
# 
#     def __init__(self, properties):
#         self.hypervisor_iface = properties['hypervisor_iface']
#         self.uuid = properties['uuid']
#         self.logger = logging.getLogger('mom.Collectors.GuestMemory')
#         self.hypervisor_iface.startVmMemoryStats(self.uuid)
#         self.memstats_available = True
# 
#     def stats_error(self, msg):
#         """
#         Only print stats interface errors one time when we first discover a
#         problem.  Otherwise the log will be overrun with noise.
#         """
#         if self.memstats_available:
#             self.logger.warn(msg)
#         self.memstats_available = False
# 
#     def collect(self):
#         try:
#             stat = self.hypervisor_iface.getVmMemoryStats(self.uuid)
#         except HypervisorInterfaceError as e:
#             self.stats_error('getVmMemoryStats(): %s' % e)
#             # We don't raise a CollectionError here because a different
#             # Collector (such as GuestQemuAgent) may be able to get them.
#             # If not, the Monitor's collect method will detect the missing
#             # fields anyway.
#             return {}
#         else:
#             self.memstats_available = True
#             return stat


# Path: mom/Collectors/GuestMemoryOptional.py
from mom.Collectors.GuestMemory import GuestMemory



class GuestMemoryOptional(GuestMemory):
    """
    This Collector gets memory statistics in the same way GuestMemory does.
    The only difference is that it reports all the fields as optional and thus
    allows the policy to be evaluated even when the guest agent is not running.
    """

    def getFields(self):
        return set()

    def getOptionalFields(self):

        return GuestMemory.getFields(self).union(