Package Products :: Package ZenModel :: Module DeviceManagerBase |
[hide private]
[frames] | no frames]

# Source Code for Module Products.ZenModel.DeviceManagerBase

     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 or (at your
     8  # option) any later version as published by the Free Software Foundation.
     9  #
    10  # For complete information please visit: http://www.zenoss.com/oss/
    11  #
    12  ###########################################################################
    13
    14  from ZenossSecurity import ZEN_VIEW
    15  from Products.ZenMessaging.actions import sendUserAction
    16  from Products.ZenMessaging.actions.constants import ActionTargetType, ActionName
    17
    18 -class DeviceManagerBase:
    19      """
    20      Default implementation of IDeviceManager interface.  This interface
    21      is implemented by classes that have a device relationship to allow them
    22      to manage their device relations.
    23      """
    24
    25 -    def getDevices(self):
    26          return [ dev for dev in self.devices()
    27                      if self.checkRemotePerm(ZEN_VIEW, dev)]
    28
    29 -    def deviceMoveTargets(self):
    30          """see IManageDevice"""
    31          raise NotImplementedError
    32
    33 -    def removeDevices(self, deviceNames=None, deleteStatus=False,
    34                        deleteHistory=False, deletePerf=False,REQUEST=None):
    35          """see IManageDevice"""
    36          from Products.ZenUtils.Utils import unused
    37          unused(deleteHistory, deletePerf, deleteStatus)
    38          if not deviceNames: return self()
    39          if isinstance(deviceNames, basestring): deviceNames = (deviceNames,)
    40          for devname in deviceNames:
    41              self.devices._delObject(devname)
    42              if sendUserAction and REQUEST:
    43                  # TODO: replace check with a MetaClass-To-PrettyName method.
    44                  if self.meta_type == 'PerformanceConf':
    45                      actionName = 'RemoveFromCollector'
    46                      objType = 'Collector'
    47                      objId = self.id
    48                  else:
    49                      actionName = ActionName.Remove
    50                      objType = self.meta_type
    51                      objId = self.getPrimaryId()
    52                  sendUserAction(ActionTargetType.Device,
    53                                 actionName,
    54                                 device=devname,
    55                                 extra={objType:objId})
    56          if REQUEST:
    57              return self()
    58