Package Products :: Package ZenHub :: Package services :: Module PingConfig |
[hide private]
[frames] | no frames]

# Source Code for Module Products.ZenHub.services.PingConfig

     1  ###########################################################################
     2  #
     3  # This program is part of Zenoss Core, an open source monitoring platform.
     4  # Copyright (C) 2007, Zenoss Inc.
     5  #
     6  # This program is free software; you can redistribute it and/or modify it
     7  # under the terms of the GNU General Public License version 2 as published by
     8  # the Free Software Foundation.
     9  #
    10  # For complete information please visit: http://www.zenoss.com/oss/
    11  #
    12  ###########################################################################
    13
    14  from Products.ZenStatus import pingtree
    15  from Products.ZenHub.services.PerformanceConfig import PerformanceConfig
    16  from Products.ZenHub.PBDaemon import translateError
    17
    18 -class PingConfig(PerformanceConfig):
    19      "Support zenping configuration loading"
    20
    21      @translateError
    22 -    def remote_getPingTree(self, root, fallbackIp):
    23          return self.getPingTree(self.dmd, root, fallbackIp)
    24
    25 -    def getPingTree(self, dmd, root, fallbackIp):
    26          pm = dmd.Monitors.getPerformanceMonitor(self.instance)
    27          me = pm.findDevice(root)
    28          if not me:
    29              me = self.lookupByIp(dmd, pm, fallbackIp)
    30          if me:
    31              self.log.info("building pingtree from %s", me.id)
    32              tree = pingtree.buildTree(me)
    33          else:
    34              self.log.info("ZenPing '%s' not found, "
    35                                "ignoring network topology.",
    36                                root)
    37              tree = pingtree.PingTree(fallbackIp)
    38              tree.root = pingtree.RouterNode(fallbackIp, root, 0)
    39              tree.root.addNet(tree, "default", "default")
    40          config = dmd.Monitors.Performance._getOb(self.instance)
    41          devices = config.getPingDevices()
    42          self.prepDevices(tree, devices)
    43          return tree.root
    44
    45
    46 -    def getDeviceConfig(self, device):
    47          return device
    48
    49
    50 -    def lookupByIp(self, dmd, pm, fallbackIp):
    51          """Try to find the root device by our IP
    52          """
    53          ip = dmd.Networks.findIp(fallbackIp)
    54          if ip and ip.device() and \
    55              ip.device().getPerformanceServerName() == pm.id:
    56              return ip.device()
    57
    58
    59 -    def prepDevices(self, pingtree, devices):
    60          """resolve dns names and make StatusTest objects"""
    61          for device in devices:
    62              if not pingtree.hasDev(device):
    63                pingtree.addDevice(device)
    64
    65 -    def sendDeviceConfig(self, listener, config):
    66          return listener.callRemote('updateConfig')
    67