def install(self, dmd):
         ZenPackBase.install(self, dmd)
         #
         # To create an organizer when the ZenPack is installed, uncomment the next few lines
         #
         dc = dmd.Devices.createOrganizer('/Example/TestClass')
         dc.setZenProperty('zCollectorPlugins',
                                 ('zenoss.snmp.NewDeviceMap',
                                  'zenoss.snmp.DeviceMap',
                                  'zenoss.snmp.InterfaceMap',
                                  'zenoss.snmp.RouteMap',
                                  'community.snmp.ExampleSNMP',
                                  'community.snmp.ExampleHostResourcesSNMP',
                                  'community.cmd.ExampleCMD',))
         # If we want to use a Command modeler plugin, then cmd userid and password need to be setup
         dc.setZenProperty('zCommandUsername', 'mollie')
         dc.setZenProperty('zCommandPassword', 'fiddle')

         #
         # Ensure that properties for this organizer class will be of device object class ExampleDevice
         #
         dc.setZenProperty('zPythonClass', 'ZenPacks.community.MenuExamples.ExampleDevice')
         #
         #Create an instance of this device class, checking first whether such a an instance exists

         if dc.devices._getOb('ExampleDevice1', None): return
         myInst = dc.createInstance('ExampleDevice1')
         myInst.setPerformanceMonitor('localhost')
    def install(self, dmd):
        ZenPackBase.install(self, dmd)
        #
        # To create an organizer when the ZenPack is installed, uncomment the next few lines
        #
        dc = dmd.Devices.createOrganizer("/Example/TestClass")
        dc.setZenProperty(
            "zCollectorPlugins",
            (
                "zenoss.snmp.NewDeviceMap",
                "zenoss.snmp.DeviceMap",
                "zenoss.snmp.InterfaceMap",
                "zenoss.snmp.RouteMap",
                "community.snmp.ExampleSNMP",
                "community.snmp.ExampleHostResourcesSNMP",
                "community.cmd.ExampleCMD",
            ),
        )
        # If we want to use a Command modeler plugin, then cmd userid and password need to be setup
        dc.setZenProperty("zCommandUsername", "mollie")
        dc.setZenProperty("zCommandPassword", "fiddle")

        #
        # Ensure that properties for this organizer class will be of device object class ExampleDevice
        #
        dc.setZenProperty("zPythonClass", "ZenPacks.skills1st.MenuExamples.ExampleDevice")
        #
        # Create an instance of this device class, checking first whether sucha an instance exists

        if dc.devices._getOb("ExampleDevice1", None):
            return
        myInst = dc.createInstance("ExampleDevice1")
        myInst.setPerformanceMonitor("localhost")
Example #3
0
    def install(self, dmd):
        ZenPackBase.install(self, dmd)
        #
        # To create an organizer when the ZenPack is installed, uncomment the next few lines
        #
        dc = dmd.Devices.createOrganizer('/Example/TestClass')
        dc.setZenProperty('zCollectorPlugins', (
            'zenoss.snmp.NewDeviceMap',
            'zenoss.snmp.DeviceMap',
            'zenoss.snmp.InterfaceMap',
            'zenoss.snmp.RouteMap',
            'community.snmp.ExampleSNMP',
            'community.snmp.ExampleHostResourcesSNMP',
            'community.cmd.ExampleCMD',
        ))
        # If we want to use a Command modeler plugin, then cmd userid and password need to be setup
        dc.setZenProperty('zCommandUsername', 'mollie')
        dc.setZenProperty('zCommandPassword', 'fiddle')

        #
        # Ensure that properties for this organizer class will be of device object class ExampleDevice
        #
        dc.setZenProperty('zPythonClass',
                          'ZenPacks.skills1st.MenuExamples.ExampleDevice')
        #
        #Create an instance of this device class, checking first whether such a an instance exists

        if dc.devices._getOb('ExampleDevice1', None): return
        myInst = dc.createInstance('ExampleDevice1')
        myInst.setPerformanceMonitor('localhost')
 def install(self, dmd):
     if yaml_installed():
         ZenPackBase.install(self, dmd)
         self.check_permissions()
         self.create_symlink()
     else:
         sys.exit(1)
 def install(self, app):
     for c in self.constructs: c.buildZenPackFiles()
     ZenPackBase.install(self, app)
     self.updateRelations(app)
     if self.shouldLoad() is True:
         log.info("loading components")
         try: self.loadComponents(app)
         except:  log.warn("problem loading components")
     else: log.info("not loading components")
    def install(self, dmd):
        ZenPackBase.install(self, dmd)
        torque = dmd.Devices.createOrganizer('/Server/SSH/Linux/Torque')

        # add our modeler
        collectors = torque.getProperty('zCollectorPlugins') or []
        torque.setZenProperty('zCollectorPlugins',
            collectors+['CERIT_SC.cmd.pbsnodes'])

        for device in self.dmd.Devices.getSubDevices():
            ddevice.buildRelations()
Example #7
0
 def install(self, app):
     self._removePreviousZenPacks(self.dmd)
     ZenPackBase.install(self, app)
     _addPluginsToDiscovered(self.dmd)
     self.createZProperties(self.dmd.getPhysicalRoot())
     if not self.dmd.Devices.Discovered.hasProperty('zWmiMonitorIgnore'):
         self.dmd.Devices.Discovered.setZenProperty('zWmiMonitorIgnore',
                                                    False)
     if not self.dmd.Devices.Server.Windows.hasProperty(
             'zWmiMonitorIgnore'):
         self.dmd.Devices.Server.Windows.setZenProperty(
             'zWmiMonitorIgnore', False)
     if not self.dmd.Devices.Server.Windows.hasProperty('zWinEventlog'):
         self.dmd.Devices.Server.Windows.setZenProperty(
             'zWinEventlog', True)
Example #8
0
 def install(self, packName):
     zp = None
     # We wrap our try in a try to abort our tansaction, but make sure we
     # unpause applyDataMap functionality
     try:
         try:
             # hide uncatalog error messages since they do not do any harm
             log = logging.getLogger('Zope.ZCatalog')
             oldLevel = log.getEffectiveLevel()
             log.setLevel(HIGHER_THAN_CRITICAL)
             zp = self.dmd.ZenPackManager.packs._getOb(packName)
             self.log.info('Upgrading %s', packName)
             self.dmd.startPauseADM()
             zp.upgrade(self.app)
         except AttributeError:
             try:
                 module =  __import__('Products.' + packName, globals(), {}, [''])
                 zp = module.ZenPack(packName)
             except (ImportError, AttributeError) as ex:
                 self.log.debug(
                     "Unable to find custom ZenPack (%s), defaulting to generic ZenPack", ex
                 )
                 zp = ZenPack(packName)
             self.dmd.ZenPackManager.packs._setObject(packName, zp)
             zp = self.dmd.ZenPackManager.packs._getOb(packName)
             zp.install(self.app)
         finally:
             log.setLevel(oldLevel)
         if zp:
             for required in zp.requires:
                 try:
                     self.dmd.ZenPackManager.packs._getOb(required)
                 except Exception:
                     self.log.error(
                         "Pack %s requires pack %s: not installing",
                         packName, required
                     )
                     return
     except Exception:
         transaction.abort()
     finally:
         self.dmd.stopPauseADM()
Example #9
0
 def install(self, packName):
     zp = None
     try:
         # hide uncatalog error messages since they do not do any harm
         log = logging.getLogger('Zope.ZCatalog')
         oldLevel = log.getEffectiveLevel()
         log.setLevel(HIGHER_THAN_CRITICAL)
         zp = self.dmd.ZenPackManager.packs._getOb(packName)
         self.log.info('Upgrading %s' % packName)
         zp.upgrade(self.app)
     except AttributeError:
         try:
             module =  __import__('Products.' + packName, globals(), {}, [''])
             zp = module.ZenPack(packName)
         except (ImportError, AttributeError), ex:
             self.log.debug("Unable to find custom ZenPack (%s), "
                            "defaulting to generic ZenPack",
                            ex)
             zp = ZenPack(packName)
         self.dmd.ZenPackManager.packs._setObject(packName, zp)
         zp = self.dmd.ZenPackManager.packs._getOb(packName)
         zp.install(self.app)
Example #10
0
 def install(self, packName):
     zp = None
     # We wrap our try in a try to abort our tansaction, but make sure we
     # unpause applyDataMap functionality
     try:
         try:
             # hide uncatalog error messages since they do not do any harm
             log = logging.getLogger('Zope.ZCatalog')
             oldLevel = log.getEffectiveLevel()
             log.setLevel(HIGHER_THAN_CRITICAL)
             zp = self.dmd.ZenPackManager.packs._getOb(packName)
             self.log.info('Upgrading %s', packName)
             self.dmd.startPauseADM()
             zp.upgrade(self.app)
         except AttributeError:
             try:
                 module =  __import__('Products.' + packName, globals(), {}, [''])
                 zp = module.ZenPack(packName)
             except (ImportError, AttributeError), ex:
                 self.log.debug(
                     "Unable to find custom ZenPack (%s), defaulting to generic ZenPack", ex
                 )
                 zp = ZenPack(packName)
             self.dmd.ZenPackManager.packs._setObject(packName, zp)
             zp = self.dmd.ZenPackManager.packs._getOb(packName)
             zp.install(self.app)
         finally:
             log.setLevel(oldLevel)
         if zp:
             for required in zp.requires:
                 try:
                     self.dmd.ZenPackManager.packs._getOb(required)
                 except:
                     self.log.error(
                         "Pack %s requires pack %s: not installing",
                         packName, required
                     )
                     return
Example #11
0
 def install(self, packName):
     zp = None
     try:
         # hide uncatalog error messages since they do not do any harm
         log = logging.getLogger('Zope.ZCatalog')
         oldLevel = log.getEffectiveLevel()
         log.setLevel(HIGHER_THAN_CRITICAL)
         zp = self.dmd.ZenPackManager.packs._getOb(packName)
         self.log.info('Upgrading %s' % packName)
         zp.upgrade(self.app)
     except AttributeError:
         try:
             module = __import__('Products.' + packName, globals(), {},
                                 [''])
             zp = module.ZenPack(packName)
         except (ImportError, AttributeError), ex:
             self.log.debug(
                 "Unable to find custom ZenPack (%s), "
                 "defaulting to generic ZenPack", ex)
             zp = ZenPack(packName)
         self.dmd.ZenPackManager.packs._setObject(packName, zp)
         zp = self.dmd.ZenPackManager.packs._getOb(packName)
         zp.install(self.app)
 def install(self, app):
     # productName is used in the UpdateCheck call to dev.zenoss.org to
     # identify what product is checking version.
     app.zport.dmd.productName = 'trebortechlayout'
     ZenPackBase.install(self, app)
     app = self.dmd.getPhysicalRoot()
 def install(self, app):
     for c in self.constructs:
         c.buildZenPackFiles()
     ZenPackBase.install(self, app)
     self.updateRelations(app)
 def install(self, dmd):
   # create the required device class 
   dc = dmd.Devices.createOrganizer('/Storage/IBMV7000')
   ZenPackBase.install(self, dmd)
Example #15
0
    def install(self, app):
        ZenPackBase.install(self, app)

        self.install_modeler_plugins(app.zport.dmd)
        self.rebuildRelations(app.zport.dmd)
 def install(self, app):
     ZenPackBase.install(self, app)
     for d in self.dmd.Devices.getSubDevices():
         d.buildRelations()
Example #17
0
 def install(self, app):
     self._removePreviousZenPacks(self.dmd)
     ZenPackBase.install(self, app)
     _addPluginsToDiscovered(self.dmd)
 def install(self, dmd):
     ZenPackBase.install(self, dmd)
     self.symlinkScript()
     for d in self.dmd.Devices.getSubDevices():
         d.buildRelations()
 def install(self, app):
     # productName is used in the UpdateCheck call to dev.zenoss.org to
     # identify what product is checking version.
     app.zport.dmd.productName = 'trebortechlayout'
     ZenPackBase.install(self, app)
     app = self.dmd.getPhysicalRoot()
Example #20
0
 def install(self, app):
     Base.install(self, app)
     self.migrate()
Example #21
0
 def install(self, app):
     Base.install(self, app)
     self.migrate()
 def install(self, app):
     Base.install(self, app)
 def install(self, dmd):
     ZenPackBase.install(self, dmd)
     # TODO libexec binary selection
     pass
Example #24
0
 def install(self, dmd):
     # create the required device class
     dc = dmd.Devices.createOrganizer('/Storage/IBMV7000')
     ZenPackBase.install(self, dmd)
 def install(self, app):
     ZenPackBase.install(self, app)
     # enable globally, for all device classes and devices:
     self.enable_modeler_plugins( app.zport.dmd, self.modeler_plugins, self.devices_or_classes_to_modify_iterator(app) )
Example #26
0
    def transactional_actions():
        # Instantiate ZenPack
        entryMap = pkg_resources.get_entry_map(dist, ZENPACK_ENTRY_POINT)
        if not entryMap or len(entryMap) > 1:
            raise ZenPackException('A ZenPack egg must contain exactly one'
                    ' zenoss.zenpacks entry point.  This egg appears to contain'
                    ' %s such entry points.' % len(entryMap))
        packName, packEntry = entryMap.items()[0]
        runExternalZenpack = True
        #if zenpack with same name exists we can't load both modules
        #installing new egg zenpack will be done in a sub process
        existing = dmd.ZenPackManager.packs._getOb(packName, None)
        if existing:
            log.info("Previous ZenPack exists with same name %s" % packName)
        if filesOnly or not existing:
            #running files only or zenpack by same name doesn't already exists
            # so no need to install the zenpack in an external process
            runExternalZenpack = False
            module = packEntry.load()
            if hasattr(module, 'ZenPack'):
                zenPack = module.ZenPack(packName)
            else:
                zenPack = ZenPack(packName)
            zenPack.eggPack = True
            CopyMetaDataToZenPackObject(dist, zenPack)
            if filesOnly:
                for loader in (ZPL.ZPLDaemons(), ZPL.ZPLBin(), ZPL.ZPLLibExec()):
                    loader.load(zenPack, None)
            if fromUI and not zenPack.installableFromUI:
                raise ZenPackException("This ZenPack cannot be installed through the UI.")

        if not filesOnly:
            # Look for an installed ZenPack to be upgraded.  In this case
            # upgraded means that it is removed before the new one is installed
            # but that its objects are not removed and the packables are
            # copied to the new instance.
            existing = dmd.ZenPackManager.packs._getOb(packName, None)
            if not existing and zenPack.prevZenPackName:
                existing = dmd.ZenPackManager.packs._getOb(
                                    zenPack.prevZenPackName, None)

            deferFileDeletion = False
            packables = []
            upgradingFrom = None
            if existing:
                upgradingFrom = existing.version
                for p in existing.packables():
                    packables.append(p)
                    existing.packables.removeRelation(p)
                if existing.isEggPack():
                    forceNoFileDeletion = existing.eggPath() == dist.location
                    RemoveZenPack(dmd, existing.id,
                                    skipDepsCheck=True, leaveObjects=True,
                                    forceNoFileDeletion=forceNoFileDeletion,
                                    uninstallEgg=False)
                else:
                    # Don't delete files, might still be needed for
                    # migrate scripts to be run below.
                    deferFileDeletion = True
                    oldzenpack.RemoveZenPack(dmd, existing.id,
                                    skipDepsCheck=True, leaveObjects=True,
                                    deleteFiles=False)

            if runExternalZenpack or forceRunExternal:
                log.info("installing zenpack %s; launching process" % packName)
                cmd = [binPath('zenpack')]
                if link:
                    cmd += ["--link"]
                cmd += ["--install", eggPath]
                if upgradingFrom:
                    cmd += ['--previousversion', upgradingFrom]
                if fromUI:
                    cmd += ["--fromui"]
                if serviceId:
                    cmd += ['--service-id', serviceId]

                cmdStr = " ".join(cmd)
                log.debug("launching sub process command: %s" % cmdStr)
                p = subprocess.Popen(cmdStr,
                                shell=True)
                out, err = p.communicate()
                p.wait()
                if p.returncode:
                    raise ZenPackException('Error installing the egg (%s): %s' %
                                           (p.returncode, err))
                dmd._p_jar.sync()
            else:
                dmd.ZenPackManager.packs._setObject(packName, zenPack)
                zenPack = dmd.ZenPackManager.packs._getOb(packName)
                #hack because ZenPack.install is overridden by a lot of zenpacks
                #so we can't change the signature of install to take the
                #previousVerison
                zenPack.prevZenPackVersion = previousVersion
                zenPack.install(dmd)
                zenPack.prevZenPackVersion = None

            try:
                zenPack = dmd.ZenPackManager.packs._getOb(packName)
                for p in packables:
                    pId = p.getPrimaryId()
                    try:
                        # make sure packable still exists; could be deleted by a
                        # migrate
                        getObjByPath(dmd, pId)
                        log.debug("adding packable relation for id %s", pId)
                        zenPack.packables.addRelation(p)
                    except (KeyError, zExceptions.NotFound):
                        log.debug('did not find packable %s',pId)
            except AttributeError, e:
                # If this happens in the child process or during the non-upgrade
                # flow, reraise the exception
                if not runExternalZenpack:
                    raise

                # This specific error will occur when the version of the ZenPack
                # being installed subclasses Products.ZenModel.ZenPack, but the
                # previous version of the ZenPack did not.
                if str(e) == "'ZenPack' object has no attribute '__of__'":
                    zenPack = ZenPack(packName)
                else:
                    # This is the signature error of class-loading issues
                    # during zenpack upgrade.  The final state should be okay,
                    # except that modified packables may be lost.
                    message = "There has been an error during the post-" + \
                              "installation steps for the zenpack %s.  In " + \
                              "most cases, no further action is required.  If " + \
                              "issues persist, please reinstall this zenpack."
                    message = message % packName
                    log.warning( message )
                    raise NonCriticalInstallError( message )

            cleanupSkins(dmd)
            return zenPack, deferFileDeletion, existing
Example #27
0
    def transactional_actions():
        # Instantiate ZenPack
        entryMap = pkg_resources.get_entry_map(dist, ZENPACK_ENTRY_POINT)
        if not entryMap or len(entryMap) > 1:
            raise ZenPackException(
                'A ZenPack egg must contain exactly one'
                ' zenoss.zenpacks entry point.  This egg appears to contain'
                ' %s such entry points.' % len(entryMap))
        packName, packEntry = entryMap.items()[0]
        runExternalZenpack = True
        #if zenpack with same name exists we can't load both modules
        #installing new egg zenpack will be done in a sub process
        existing = dmd.ZenPackManager.packs._getOb(packName, None)
        if existing:
            log.info("Previous ZenPack exists with same name %s" % packName)
        if filesOnly or not existing:
            #running files only or zenpack by same name doesn't already exists
            # so no need to install the zenpack in an external process
            runExternalZenpack = False
            module = packEntry.load()
            if hasattr(module, 'ZenPack'):
                zenPack = module.ZenPack(packName)
            else:
                zenPack = ZenPack(packName)
            zenPack.eggPack = True
            CopyMetaDataToZenPackObject(dist, zenPack)
            if filesOnly:
                for loader in (ZPL.ZPLDaemons(), ZPL.ZPLBin(),
                               ZPL.ZPLLibExec()):
                    loader.load(zenPack, None)
            if fromUI and not zenPack.installableFromUI:
                raise ZenPackException(
                    "This ZenPack cannot be installed through the UI.")

        if not filesOnly:
            # Look for an installed ZenPack to be upgraded.  In this case
            # upgraded means that it is removed before the new one is installed
            # but that its objects are not removed and the packables are
            # copied to the new instance.
            existing = dmd.ZenPackManager.packs._getOb(packName, None)
            if not existing and zenPack.prevZenPackName:
                existing = dmd.ZenPackManager.packs._getOb(
                    zenPack.prevZenPackName, None)

            deferFileDeletion = False
            packables = []
            upgradingFrom = None
            if existing:
                upgradingFrom = existing.version
                for p in existing.packables():
                    packables.append(p)
                    existing.packables.removeRelation(p)
                if existing.isEggPack():
                    forceNoFileDeletion = existing.eggPath() == dist.location
                    RemoveZenPack(dmd,
                                  existing.id,
                                  skipDepsCheck=True,
                                  leaveObjects=True,
                                  forceNoFileDeletion=forceNoFileDeletion,
                                  uninstallEgg=False)
                else:
                    # Don't delete files, might still be needed for
                    # migrate scripts to be run below.
                    deferFileDeletion = True
                    oldzenpack.RemoveZenPack(dmd,
                                             existing.id,
                                             skipDepsCheck=True,
                                             leaveObjects=True,
                                             deleteFiles=False)

            if runExternalZenpack or forceRunExternal:
                log.info("installing zenpack %s; launching process" % packName)
                cmd = [binPath('zenpack')]
                if link:
                    cmd += ["--link"]
                cmd += ["--install", eggPath]
                if upgradingFrom:
                    cmd += ['--previousversion', upgradingFrom]
                if fromUI:
                    cmd += ["--fromui"]

                cmdStr = " ".join(cmd)
                log.debug("launching sub process command: %s" % cmdStr)
                p = subprocess.Popen(cmdStr, shell=True)
                out, err = p.communicate()
                p.wait()
                if p.returncode:
                    raise ZenPackException(
                        'Error installing the egg (%s): %s' %
                        (p.returncode, err))
                dmd._p_jar.sync()
            else:
                dmd.ZenPackManager.packs._setObject(packName, zenPack)
                zenPack = dmd.ZenPackManager.packs._getOb(packName)
                #hack because ZenPack.install is overridden by a lot of zenpacks
                #so we can't change the signature of install to take the
                #previousVerison
                zenPack.prevZenPackVersion = previousVersion
                zenPack.install(dmd)
                zenPack.prevZenPackVersion = None

            try:
                zenPack = dmd.ZenPackManager.packs._getOb(packName)
                for p in packables:
                    pId = p.getPrimaryId()
                    try:
                        # make sure packable still exists; could be deleted by a
                        # migrate
                        getObjByPath(dmd, pId)
                        log.debug("adding packable relation for id %s", pId)
                        zenPack.packables.addRelation(p)
                    except (KeyError, zExceptions.NotFound):
                        log.debug('did not find packable %s', pId)
            except AttributeError, e:
                # If this happens in the child process or during the non-upgrade
                # flow, reraise the exception
                if not runExternalZenpack:
                    raise

                # This specific error will occur when the version of the ZenPack
                # being installed subclasses Products.ZenModel.ZenPack, but the
                # previous version of the ZenPack did not.
                if str(e) == "'ZenPack' object has no attribute '__of__'":
                    zenPack = ZenPack(packName)
                else:
                    # This is the signature error of class-loading issues
                    # during zenpack upgrade.  The final state should be okay,
                    # except that modified packables may be lost.
                    message = "There has been an error during the post-" + \
                              "installation steps for the zenpack %s.  In " + \
                              "most cases, no further action is required.  If " + \
                              "issues persist, please reinstall this zenpack."
                    message = message % packName
                    log.warning(message)
                    raise NonCriticalInstallError(message)

            cleanupSkins(dmd)
            return zenPack, deferFileDeletion, existing
 def install(self, app):
     self._removePreviousZenPacks(self.dmd)
     ZenPackBase.install(self, app)
     _addPluginsToDiscovered(self.dmd)