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

# Source Code for Module Products.ZenModel.OSComponent

      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 ManagedEntity import ManagedEntity
     15  from DeviceComponent import DeviceComponent
     16  from Products.ZenRelations.RelSchema import ToMany
     17
     18
     19 -class OSComponent(DeviceComponent, ManagedEntity):
     20      """
     21      Logical Operating System component like a Process, IpInterface, etc.
     22      """
     23      isUserCreatedFlag = False
     24
     25      _relations = ManagedEntity._relations + (
     26          ("links", ToMany(ToMany, "Products.ZenModel.Link", "endpoints")),
     27      )
     28
     29 -    def setUserCreateFlag(self):
     30          """
     31          Sets self.isUserCreatedFlag to True.  This indicated that the
     32          component was created by a user rather than via modelling.
     33          """
     34          self.isUserCreatedFlag = True
     35
     36
     37 -    def isUserCreated(self):
     38          """
     39          Returns the value of isUserCreated.  See setUserCreatedFlag() above.
     40          """
     41          return self.isUserCreatedFlag
     42
     43
     44 -    def device(self):
     45          """
     46          Return our device object for DeviceResultInt.
     47          """
     48          os = self.os()
     49          if os: return os.device()
     50
     51
     52 -    def manage_deleteComponent(self, REQUEST=None):
     53          """
     54          Delete OSComponent
     55          """
     56          url = None
     57          if REQUEST is not None:
     58              url = self.device().os.absolute_url()
     59          self.getPrimaryParent()._delObject(self.id)
     60          '''
     61          eventDict = {
     62              'eventClass': Change_Remove,
     63              'device': self.device().id,
     64              'component': self.id or '',
     65              'summary': 'Deleted by user: %s' % 'user',
     66              'severity': Event.Info,
     67              }
     68          self.dmd.ZenEventManager.sendEvent(eventDict)
     69          '''
     70          if REQUEST is not None:
     71              REQUEST['RESPONSE'].redirect(url)
     72
     73
     74 -    def manage_updateComponent(self, datamap, REQUEST=None):
     75          """
     76          Update OSComponent
     77          """
     78          url = None
     79          if REQUEST is not None:
     80              url = self.device().os.absolute_url()
     81          self.getPrimaryParent()._updateObject(self, datamap)
     82          '''
     83          eventDict = {
     84              'eventClass': Change_Set,
     85              'device': self.device().id,
     86              'component': self.id or '',
     87              'summary': 'Updated by user: %s' % 'user',
     88              'severity': Event.Info,
     89              }
     90          self.dmd.ZenEventManager.sendEvent(eventDict)
     91          '''
     92          if REQUEST is not None:
     93              REQUEST['RESPONSE'].redirect(url)
     94
     95
     96 -    def getIconPath(self):
     97          """
     98          Override the device's zProperty and return an icon based on the class
     99          name
    100          """
    101          return "/zport/dmd/img/icons/%s.png" % self.meta_type.lower()
    102
    103
    104 -    def getPrettyLink(self):
    105          """
    106          Gets a link to this object, plus an icon
    107          """
    108          template = ("<a href='%s' class='prettylink'>"
    109                      "<div class='device-icon-container'> "
    110                      "<img class='device-icon' src='%s'/> "
    111                      "</div>%s</a>")
    112          icon = self.getIconPath()
    113          href = self.getPrimaryUrlPath()
    114          name = self.titleOrId()
    115          return template % (href, icon, name)
    116