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

# Source Code for Module Products.ZenModel.DeviceManagerBase

     1  ##############################################################################
     2  #
     3  # Copyright (C) Zenoss, Inc. 2007, all rights reserved.
     4  #
     5  # This content is made available according to terms specified in
     6  # License.zenoss under the directory where your Zenoss product is installed.
     7  #
     8  ##############################################################################
     9
    10
    11  from ZenossSecurity import ZEN_VIEW
    12  from Products.ZenUtils.Utils import getDisplayType, getDisplayId
    13  from Products.ZenMessaging.audit import audit
    14
    15 -class DeviceManagerBase:
    16      """
    17      Default implementation of IDeviceManager interface.  This interface
    18      is implemented by classes that have a device relationship to allow them
    19      to manage their device relations.
    20      """
    21
    22 -    def getDevices(self):
    23          return [ dev for dev in self.devices()
    24                      if self.checkRemotePerm(ZEN_VIEW, dev)]
    25
    26 -    def deviceMoveTargets(self):
    27          """see IManageDevice"""
    28          raise NotImplementedError
    29
    30 -    def removeDevices(self, deviceNames=None, deleteStatus=False,
    31                        deleteHistory=False, deletePerf=False,REQUEST=None):
    32          """see IManageDevice"""
    33          from Products.ZenUtils.Utils import unused
    34          unused(deleteHistory, deletePerf, deleteStatus)
    35          if not deviceNames: return self()
    36          if isinstance(deviceNames, basestring): deviceNames = (deviceNames,)
    37          for devname in deviceNames:
    38              self.devices._delObject(devname)
    39              if REQUEST:
    40                  if self.meta_type == 'PerformanceConf':
    41                      actionName = 'RemoveFromCollector'
    42                      objId = self.id
    43                  else:
    44                      actionName = 'Remove'
    45                      objId = self.getPrimaryId()
    46                  objType = getDisplayType(self)
    47                  audit(['UI.Device', actionName], devname, data_={objType:objId})
    48          if REQUEST:
    49              return self()
    50