Пример #1
0
def setDescriptors(dmd):
    """
    Set the property descriptors on the ZenPropertyManager class.  The
    transformerFactories parameter is a dictionary that maps a property type
    to a callable factory that produces instances with transformForGet and
    transformForSet methods.
    """
    zprops = set()
    
    # copy the core zProps
    # Z_PROPERTIES = id, defaultValue, type , label, description
    for item in Z_PROPERTIES:
        id = item[0]
        type = item[2]
        zprops.add((id, type))
        Z_PROPERTY_META_DATA[id] = dict()
        Z_PROPERTY_META_DATA[id]['type'] = type
        Z_PROPERTY_META_DATA[id]['defaultValue'] = item[1]
        if len(item) >= 4:
            Z_PROPERTY_META_DATA[id]['label'] = item[3]
        if len(item) >= 5:
            Z_PROPERTY_META_DATA[id]['description'] = item[4]
    
    # add zProps from zenpacks
    from Products.ZenUtils.PkgResources import pkg_resources
    for zpkg in pkg_resources.iter_entry_points('zenoss.zenpacks'):
        # fromlist is typically ZenPacks.zenoss
        fromlist = zpkg.module_name.split('.')[:-1]
        module = __import__(zpkg.module_name, globals(), locals(), fromlist)
        if hasattr(module, 'ZenPack'):
            for prop_id, propt_default_value, prop_type in module.ZenPack.packZProperties:
                zprops.add((prop_id, prop_type))
            if hasattr(module.ZenPack, 'packZProperties_data'):
                Z_PROPERTY_META_DATA.update(module.ZenPack.packZProperties_data)
                # check for category to update
                for key, value in module.ZenPack.packZProperties_data.iteritems():
                    # if zproperties are only defined in data
                    zprops.add((key, value.get('type')))
                    if value.get('category'):
                        setzPropertyCategory(key, value.get('category'))
                        
    # add zProps from dmd.Devices to catch any that are undefined elsewhere
    for prop_id in dmd.Devices.zenPropertyIds():
        prop_type = dmd.Devices.getPropertyType(prop_id)
        if (prop_id, prop_type) not in zprops:
            log.debug('Property {prop_id} is deprecated. It should be removed from the system.'.format(prop_id=prop_id))
            zprops.add((prop_id, prop_type))

    monkeypatchDescriptors(zprops, dmd.propertyTransformers)

_PACK_Z_PROPS = [
    ('zWinRMUser', '', 'string'),
    ('zWinRMPassword', '', 'password'),
    ('zWinRMPort', '5985', 'string'),
    ('zDBInstances', 'MSSQLSERVER;', 'string'),
    ('zDBInstancesPassword', '', 'password'),
    ('zWinKDC', '', 'string'),
    ('zWinKeyTabFilePath', '', 'string'),
    ('zWinScheme', 'http', 'string'),
    ('zWinPerfmonInterval', 300, 'int'),
    ]

for name, default_value, type_ in _PACK_Z_PROPS:
    setzPropertyCategory(name, 'Windows')

# General zProp for Instance logins
# Format example:
# zDBInstanceLogin = '******'
# zDBInstnacePassword = '******'


setzPropertyCategory('zDBInstances', 'Misc')
setzPropertyCategory('zDBInstancesPassword', 'Misc')

# Used by zenchkschema to validate relationship schema.
productNames = (
    'ClusterDevice',
    'ClusterResource',
    'ClusterService',
            (relname, ToManyCont(
                ToOne,
                '.'.join((ZENPACK_NAME, modname)),
                '%s_host' % modname)),
            )

# Useful to avoid making literal string references to module and class names
# throughout the rest of the ZenPack.
MODULE_NAME = {}
CLASS_NAME = {}

_PACK_Z_PROPS = [
    ('zEEProperty', 'Hello World', 'string'),
    ]

setzPropertyCategory('zEEProperty', 'None')

_plugins = (
    )


class ZenPack(ZenPackBase):
    packZProperties = _PACK_Z_PROPS

    def install(self, app):
        super(ZenPack, self).install(app)
        LOG.info('Adding ZenPacks.EE.HelloWorld relationships to existing devices')

        self._buildDeviceRelations()
        self.symlink_plugins()
Пример #4
0
from Products.ZenEvents.EventManagerBase import EventManagerBase
from Products.ZenModel.Device import Device
from Products.ZenModel.ZenPack import ZenPack as ZenPackBase
from Products.ZenRelations.RelSchema import ToManyCont, ToOne
from Products.ZenUtils.Utils import unused
from Products.Zuul.interfaces import ICatalogTool

from Products.ZenRelations.zPropertyCategory import setzPropertyCategory

unused(Globals)

ZENPACK_NAME = 'ZenPacks.zenoss.RabbitMQ'

# Set zProperty categories for RabbitMQAdmin zProperties
setzPropertyCategory('zRabbitMQAdminUser', 'RabbitMQ')
setzPropertyCategory('zRabbitMQAdminPassword', 'RabbitMQ')

# Define new device relations.
NEW_DEVICE_RELATIONS = (('rabbitmq_nodes', 'RabbitMQNode'), )

NEW_COMPONENT_TYPES = ('ZenPacks.zenoss.RabbitMQ.RabbitMQNode.RabbitMQNode', )

# Add new relationships to Device if they don't already exist.
for relname, modname in NEW_DEVICE_RELATIONS:
    if relname not in (x[0] for x in Device._relations):
        Device._relations += ((relname,
                               ToManyCont(ToOne, '.'.join(
                                   (ZENPACK_NAME, modname)),
                                          'rabbitmq_host')), )
Пример #5
0
import Globals

from Products.Zuul import getFacade
from Products.ZenEvents.EventManagerBase import EventManagerBase
from Products.ZenModel.Device import Device
from Products.ZenModel.ZenPack import ZenPack as ZenPackBase
from Products.ZenRelations.RelSchema import ToManyCont, ToOne
from Products.ZenRelations.zPropertyCategory import setzPropertyCategory
from Products.ZenUtils.Utils import unused, monkeypatch
from Products.Zuul.interfaces import ICatalogTool

unused(Globals)

# Categorize zProperties.
setzPropertyCategory('zHBaseScheme', 'HBase')
setzPropertyCategory('zHBaseUsername', 'HBase')
setzPropertyCategory('zHBasePassword', 'HBase')
setzPropertyCategory('zHBaseRestPort', 'HBase')
setzPropertyCategory('zHBaseMasterPort', 'HBase')
setzPropertyCategory('zHBaseRegionServerPort', 'HBase')

# Modules containing model classes. Used by zenchkschema to validate
# bidirectional integrity of defined relationships.
productNames = (
    'HBaseRegionServer',
    'HBaseTable',
    'HBaseHRegion'
    )

# Useful to avoid making literal string references to module and class names
Пример #6
0
import socket
import struct

import Globals

from Products.ZenUtils.Utils import unused
from Products.ZenModel.ZenPack import ZenPackBase
from Products.ZenRelations.zPropertyCategory import setzPropertyCategory

import ZenPacks.zenoss.Layer2.patches

unused(Globals)

log = logging.getLogger('zen.Layer2')

setzPropertyCategory('zZenossGateway', 'Misc')


class ZenPack(ZenPackBase):
    """ Layer2 zenpack loader """

    packZProperties = [
        ('zZenossGateway', '', 'string'),
    ]

    def install(self, app):
        super(ZenPack, self).install(app)
        self._buildDeviceRelations()
        self._getDefaultGateway(app.zport.dmd)

    def _buildDeviceRelations(self):
Пример #7
0
# Copyright (C) Zenoss, Inc. 2012, all rights reserved.
#
# This content is made available according to terms specified in
# License.zenoss under the directory where your Zenoss product is installed.
#
##############################################################################

import logging
LOG = logging.getLogger('zen.WBEM')

from Products.ZenModel.ZenPack import ZenPackBase
from Products.ZenRelations.zPropertyCategory import setzPropertyCategory


# Categorize our zProperties.
setzPropertyCategory('zWBEMPort', 'WBEM')
setzPropertyCategory('zWBEMUsername', 'WBEM')
setzPropertyCategory('zWBEMPassword', 'WBEM')
setzPropertyCategory('zWBEMUseSSL', 'WBEM')


class ZenPack(ZenPackBase):
    """WBEM ZenPack."""

    packZProperties = [
        ('zWBEMPort', '5989', 'integer'),
        ('zWBEMUsername', '', 'string'),
        ('zWBEMPassword', '', 'password'),
        ('zWBEMUseSSL', True, 'boolean'),
        ]
Пример #8
0
# Used by zenchkschema to validate consistency of relationships.
productNames = (
    'System',
    'DataCenter',
    'StorageDomain',
    'Cluster',
    'Host',
    'HostNic',
    'Vm',
    'VmNic',
    'VmDisk',
)

# Add categories to our contributed zProperties.
setzPropertyCategory('zOVirtUrl', 'oVirt')
setzPropertyCategory('zOVirtUser', 'oVirt')
setzPropertyCategory('zOVirtPassword', 'oVirt')
setzPropertyCategory('zOVirtDomain', 'oVirt')


class BaseComponent(DeviceComponent, ManagedEntity):
    """
    Abstract base class to avoid repeating boilerplate code in all of the
    DeviceComponent subclasses in this zenpack.
    """

    # Disambiguate multi-inheritence.
    _relations = ManagedEntity._relations

    # This makes the "Templates" component display available.
Пример #9
0
#
# This content is made available according to terms specified in
# License.zenoss under the directory where your Zenoss product is installed.
#
##############################################################################

import os
import json

from Products.ZenModel.ZenPack import ZenPackBase, ZenPackDependentsException
from Products.ZenRelations.zPropertyCategory import setzPropertyCategory

from collections import defaultdict

# Categorize zProperties.
setzPropertyCategory('zAWSDiscover', 'AWS')
setzPropertyCategory('zAWSRegionPEM', 'AWS')
setzPropertyCategory('zAWSRemodelEnabled', 'AWS')
setzPropertyCategory('zAWSAutoChangeProdState', 'AWS')
setzPropertyCategory('zAWSGuestCollector', 'AWS')
setzPropertyCategory('zAWSResetGuestCollector', 'AWS')
setzPropertyCategory('zAWSGuestUsePublicIPs', 'AWS')
setzPropertyCategory('zAWSRegionToModel', 'AWS')
setzPropertyCategory('zAWSCloudWatchSSL', 'AWS')
setzPropertyCategory('zAWSCloudWatchMaxParallel', 'AWS')
setzPropertyCategory('zAWSCloudWatchMaxRetries', 'AWS')


# Modules containing model classes. Used by zenchkschema to validate
# bidirectional integrity of defined relationships.
productNames = (
Пример #10
0
def setDescriptors(dmd):
    """
    Set the property descriptors on the ZenPropertyManager class.  The
    transformerFactories parameter is a dictionary that maps a property type
    to a callable factory that produces instances with transformForGet and
    transformForSet methods.
    """
    zprops = {}

    # copy the core zProps
    # Z_PROPERTIES = id, defaultValue, type , label, description
    for item in Z_PROPERTIES:
        id = item[0]
        type = item[2]
        zprops[id] = (id, type)
        Z_PROPERTY_META_DATA[id] = dict()
        Z_PROPERTY_META_DATA[id]['type'] = type
        Z_PROPERTY_META_DATA[id]['defaultValue'] = item[1]
        if len(item) >= 4:
            Z_PROPERTY_META_DATA[id]['label'] = item[3]
        if len(item) >= 5:
            Z_PROPERTY_META_DATA[id]['description'] = item[4]

    # add zProps from zenpacks
    from Products.ZenUtils.PkgResources import pkg_resources
    for zpkg in pkg_resources.iter_entry_points('zenoss.zenpacks'):
        # fromlist is typically ZenPacks.zenoss
        fromlist = zpkg.module_name.split('.')[:-1]
        module = __import__(zpkg.module_name, globals(), locals(), fromlist)
        if hasattr(module, 'ZenPack'):
            # Merge ZenPack.packZProperties and ZenPack.packZProperties_data.
            # packZProperties wins if they disagree about type or defaultValue.
            for p_id, p_data in module.ZenPack.getZProperties().items():
                if p_id in zprops:
                    log.warning(
                        "%s tried to override existing %s property.",
                        zpkg.module_name, p_id
                    )
                    continue

                zprops[p_id] = (p_id, p_data['type'])

                category = p_data.get('category')
                if category:
                    setzPropertyCategory(p_id, category)

                Z_PROPERTY_META_DATA[p_id] = {
                    'type': p_data.get('type', 'string'),
                    'defaultValue': p_data.get('defaultValue'),
                    'label': p_data.get('label'),
                    'description': p_data.get('description'),
                    'category': category,
                }

    # add zProps from dmd.Devices to catch any that are undefined elsewhere
    for p_id in dmd.Devices.zenPropertyIds():
        p_type = dmd.Devices.getPropertyType(p_id)
        if p_id not in zprops:
            zprops[p_id] = (p_id, p_type)
            log.debug(
                "Property %s is deprecated. It should be removed "
                "from the system.", p_id
            )

    monkeypatchDescriptors(zprops.values(), dmd.propertyTransformers)
Пример #11
0
    'RouterVM',
    'SystemVM',
    'VirtualMachine',
    'Zone',
    )

# Useful to avoid making literal string references to module and class names
# throughout the rest of the ZenPack.
MODULE_NAME = {}
CLASS_NAME = {}

for product_name in productNames:
    MODULE_NAME[product_name] = '.'.join([ZENPACK_NAME, product_name])
    CLASS_NAME[product_name] = '.'.join([ZENPACK_NAME, product_name, product_name])

setzPropertyCategory('zCloudStackURL', 'CloudStack')
setzPropertyCategory('zCloudStackAPIKey', 'CloudStack')
setzPropertyCategory('zCloudStackSecretKey', 'CloudStack')


class ZenPack(ZenPackBase):
    packZProperties = [
        ('zCloudStackURL', '', 'string'),
        ('zCloudStackAPIKey', '', 'string'),
        ('zCloudStackSecretKey', '', 'password'),
        ]

    _plugins = (
        'poll_cloudstack.py',
        )
Пример #12
0
import Globals

from Products.ZenModel.Device import Device
from Products.ZenUtils.Utils import unused
from Products.ZenModel.ZenPack import ZenPackBase
from Products.ZenRelations.RelSchema import ToManyCont, ToOne
from Products.ZenRelations.zPropertyCategory import setzPropertyCategory

import ZenPacks.zenoss.Layer2.patches

unused(Globals)

ZPROPERTY_CATEGORY = 'Layer 2'

setzPropertyCategory('zL2SuppressIfDeviceDown', ZPROPERTY_CATEGORY)
setzPropertyCategory('zL2SuppressIfPathsDown', ZPROPERTY_CATEGORY)
setzPropertyCategory('zL2PotentialRootCause', ZPROPERTY_CATEGORY)
setzPropertyCategory('zL2Gateways', ZPROPERTY_CATEGORY)
setzPropertyCategory('zZenossGateway', ZPROPERTY_CATEGORY)
setzPropertyCategory('zLocalMacAddresses', ZPROPERTY_CATEGORY)

# Relationships to patch onto Device.
DEVICE_RELATIONS = {
    'neighbor_switches': 'ZenPacks.zenoss.Layer2.NeighborSwitch',
}


class ZenPack(ZenPackBase):
    """ Layer2 zenpack loader """
Пример #13
0
#
# This content is made available according to terms specified in
# License.zenoss under the directory where your Zenoss product is installed.
#
##############################################################################

import os
import json

from Products.ZenModel.ZenPack import ZenPackBase, ZenPackDependentsException
from Products.ZenRelations.zPropertyCategory import setzPropertyCategory

from collections import defaultdict

# Categorize zProperties.
setzPropertyCategory('zAWSDiscover', 'AWS')
setzPropertyCategory('zAWSRegionPEM', 'AWS')
setzPropertyCategory('zAWSRemodelEnabled', 'AWS')

# Modules containing model classes. Used by zenchkschema to validate
# bidirectional integrity of defined relationships.
productNames = (
    'EC2Account',
    'EC2Instance',
    'EC2Region',
    'EC2Volume',
    'EC2VPC',
    'EC2VPCSubnet',
    'EC2Zone',
    'VPNGateway',
    'EC2ElasticIP',
Пример #14
0
import Globals

from Products.ZenModel.Device import Device
from Products.ZenModel.ZenPack import ZenPack as ZenPackBase
from Products.ZenRelations.RelSchema import ToManyCont, ToOne
from Products.ZenRelations.zPropertyCategory import setzPropertyCategory
from Products.ZenUtils.Utils import unused, monkeypatch
from Products.Zuul.interfaces import ICatalogTool

unused(Globals)


# Categorize zProperties.
# setzPropertyCategory('zHadoop', 'Hadoop')
setzPropertyCategory('zHBaseAutodiscover', 'Hadoop')
setzPropertyCategory('zHBaseDeviceClass', 'Hadoop')
setzPropertyCategory('zHadoopScheme', 'Hadoop')
setzPropertyCategory('zHadoopUsername', 'Hadoop')
setzPropertyCategory('zHadoopPassword', 'Hadoop')
setzPropertyCategory('zHadoopNameNodePort', 'Hadoop')


# Modules containing model classes. Used by zenchkschema to validate
# bidirectional integrity of defined relationships.
productNames = (
    'HadoopJobTracker',
    'HadoopTaskTracker',
    'HadoopSecondaryNameNode',
    'HadoopResourceManager',
    'HadoopNodeManager',
Пример #15
0
#
# Copyright (C) Zenoss, Inc. 2012, all rights reserved.
#
# This content is made available according to terms specified in
# License.zenoss under the directory where your Zenoss product is installed.
#
##############################################################################

import logging
LOG = logging.getLogger('zen.WBEM')

from Products.ZenModel.ZenPack import ZenPackBase
from Products.ZenRelations.zPropertyCategory import setzPropertyCategory

# Categorize our zProperties.
setzPropertyCategory('zWBEMPort', 'WBEM')
setzPropertyCategory('zWBEMUsername', 'WBEM')
setzPropertyCategory('zWBEMPassword', 'WBEM')
setzPropertyCategory('zWBEMUseSSL', 'WBEM')


class ZenPack(ZenPackBase):
    """WBEM ZenPack."""

    packZProperties = [
        ('zWBEMPort', '5989', 'integer'),
        ('zWBEMUsername', '', 'string'),
        ('zWBEMPassword', '', 'password'),
        ('zWBEMUseSSL', True, 'boolean'),
    ]
    '/Server/Linux',
    '/Server/Windows',
]

# Modelers
_MODELERS = [
    'Secure24.nrpe.Check_NRPE',
]

# Setup zProperties
_PACK_Z_PROPS = [
    ('zNRPEChecks', '', 'lines'),
]

for name, default_value, type_ in _PACK_Z_PROPS:
    setzPropertyCategory(name, 'NRPE')

# Setup relationship
OperatingSystem._relations += ((
    "nrpeComponent",
    ToManyCont(ToOne, "ZenPacks.Secure24.Check_NRPE.nrpeComponent", "os")), )


class ZenPack(ZenPackBase):

    packZProperties = [
        ('zNRPEChecks', '', 'lines'),
    ]

    def install(self, app):
Пример #17
0
from Products.ZenModel.Device import Device
from Products.ZenModel.PerformanceConf import PerformanceConf
from Products.ZenUtils.Utils import unused
from Products.ZenModel.ZenPack import ZenPackBase
from Products.ZenRelations.RelSchema import ToManyCont, ToOne
from Products.ZenRelations.zPropertyCategory import setzPropertyCategory
from Products.Zuul.interfaces import ICatalogTool

import ZenPacks.zenoss.Layer2.patches

unused(Globals)

ZPROPERTY_CATEGORY = 'Layer 2'

setzPropertyCategory('zL2SuppressIfDeviceDown', ZPROPERTY_CATEGORY)
setzPropertyCategory('zL2SuppressIfPathsDown', ZPROPERTY_CATEGORY)
setzPropertyCategory('zL2PotentialRootCause', ZPROPERTY_CATEGORY)
setzPropertyCategory('zL2Gateways', ZPROPERTY_CATEGORY)
setzPropertyCategory('zZenossGateway', ZPROPERTY_CATEGORY)
setzPropertyCategory('zLocalMacAddresses', ZPROPERTY_CATEGORY)

# Relationships to patch onto Device.
DEVICE_RELATIONS = {
    'neighbor_switches': 'ZenPacks.zenoss.Layer2.NeighborSwitch',
    }

# Increase this number if more custom relationships are added.
RELATIONS_REVISION = 2
RELATIONS_REVISION_ATTR = "layer2_relations_revision"
Пример #18
0
    'VDI',
    'VIF',
    'VM',
    'VMAppliance',
    )

# Useful to avoid making literal string references to module and class names
# throughout the rest of the ZenPack.
MODULE_NAME = {}
CLASS_NAME = {}

for product_name in productNames:
    MODULE_NAME[product_name] = '.'.join([ZENPACK_NAME, product_name])
    CLASS_NAME[product_name] = '.'.join([ZENPACK_NAME, product_name, product_name])

setzPropertyCategory('zXenServerAddresses', 'XenServer')
setzPropertyCategory('zXenServerUsername', 'XenServer')
setzPropertyCategory('zXenServerPassword', 'XenServer')
setzPropertyCategory('zXenServerPerfInterval', 'XenServer')
setzPropertyCategory('zXenServerModelInterval', 'XenServer')
setzPropertyCategory('zXenServerEventsInterval', 'XenServer')


class ZenPack(ZenPackBase):
    packZProperties = [
        ('zXenServerAddresses', [], 'lines'),
        ('zXenServerUsername', 'root', 'string'),
        ('zXenServerPassword', '', 'password'),
        ('zXenServerPerfInterval', 300, 'int'),
        ('zXenServerModelInterval', 60, 'int'),
        ('zXenServerEventsInterval', 60, 'int'),
import sys

from Products.ZenModel.ZenPack import ZenPack as ZenPackBase
from Products.ZenRelations.zPropertyCategory import setzPropertyCategory
from Products.ZenUtils.Utils import monkeypatch
from Products.ZenUtils.ZenTales import talesEvalStr

setzPropertyCategory('zExamplePath', 'Example')


class ZenPack(ZenPackBase):
    packZProperties = [
        ('zExamplePath', '/scripts', 'string'),
    ]


# SshClient does a relative import of CollectorClient. This means we
# have to monkeypatch the relative CollectorClient module already in
# sys.modules.
if 'CollectorClient' in sys.modules:
    CollectorClient = sys.modules['CollectorClient']

    @monkeypatch(CollectorClient.CollectorClient)
    def __init__(self, *args, **kwargs):
        # original is injected into locals by the monkeypatch decorator.
        original(self, *args, **kwargs)

        # Reset cmdmap and _commands.
        self.cmdmap = {}
        self._commands = []
Пример #20
0
from Products.ZenModel.ZenPack import ZenPackBase
from Products.ZenUtils.Utils import zenPath
from Products.CMFCore.DirectoryView import registerDirectory
from Products.ZenRelations.zPropertyCategory import setzPropertyCategory

skinsDir = os.path.join(os.path.dirname(__file__), 'skins')
if os.path.isdir(skinsDir):
    registerDirectory(skinsDir, globals())

_PACK_Z_PROPS = [
    ('zVSphereUsername', '', 'string'),
    ('zVSpherePassword', '', 'password'),
]

for name, default_value, type_ in _PACK_Z_PROPS:
    setzPropertyCategory(name, 'VMware')


class ZenPack(ZenPackBase):
    packZProperties = _PACK_Z_PROPS

    def install(self, app):
        if not hasattr(app.zport.dmd.Events.Status, 'VMware'):
            app.zport.dmd.Events.createOrganizer("/Status/VMware")
        app.zport.dmd.Reports.createOrganizer('/VMware Reports')
        ZenPackBase.install(self, app)
        log.info(
            'Linking icon into $ZENHOME/Products/ZenWidgets/skins/zenui/img/icons'
        )
        os.system('ln -sf %s %s' %
                  (self.path('resources/img/icons/server-vmware.png'),
Пример #21
0
#
# This content is made available according to terms specified in
# License.zenoss under the directory where your Zenoss product is installed.
#
##############################################################################

import logging
LOG = logging.getLogger('zen.WBEM')

from Products.ZenModel.ZenPack import ZenPackBase
from Products.ZenRelations.zPropertyCategory import setzPropertyCategory
import ZenPacks.zenoss.WBEM.patches


# Categorize our zProperties.
setzPropertyCategory('zWBEMPort', 'WBEM')
setzPropertyCategory('zWBEMUsername', 'WBEM')
setzPropertyCategory('zWBEMPassword', 'WBEM')
setzPropertyCategory('zWBEMUseSSL', 'WBEM')
setzPropertyCategory('zWBEMRequestTimeout', 'WBEM')
setzPropertyCategory('zWBEMMaxObjectCount', 'WBEM')
setzPropertyCategory('zWBEMOperationTimeout', 'WBEM')


class ZenPack(ZenPackBase):
    """WBEM ZenPack."""

    packZProperties = [
        ('zWBEMPort', '5989', 'integer'),
        ('zWBEMUsername', '', 'string'),
        ('zWBEMPassword', '', 'password'),
Пример #22
0
    'VIF',
    'VM',
    'VMAppliance',
)

# Useful to avoid making literal string references to module and class names
# throughout the rest of the ZenPack.
MODULE_NAME = {}
CLASS_NAME = {}

for product_name in productNames:
    MODULE_NAME[product_name] = '.'.join([ZENPACK_NAME, product_name])
    CLASS_NAME[product_name] = '.'.join(
        [ZENPACK_NAME, product_name, product_name])

setzPropertyCategory('zXenServerAddresses', 'XenServer')
setzPropertyCategory('zXenServerUsername', 'XenServer')
setzPropertyCategory('zXenServerPassword', 'XenServer')
setzPropertyCategory('zXenServerPerfInterval', 'XenServer')
setzPropertyCategory('zXenServerModelInterval', 'XenServer')
setzPropertyCategory('zXenServerEventsInterval', 'XenServer')


class ZenPack(ZenPackBase):
    packZProperties = [
        ('zXenServerAddresses', [], 'lines'),
        ('zXenServerUsername', 'root', 'string'),
        ('zXenServerPassword', '', 'password'),
        ('zXenServerPerfInterval', 300, 'int'),
        ('zXenServerModelInterval', 60, 'int'),
        ('zXenServerEventsInterval', 60, 'int'),
from Products.ZenModel.ZenPack import ZenPackBase
from Products.ZenUtils.Utils import zenPath
from Products.CMFCore.DirectoryView import registerDirectory
from Products.ZenRelations.zPropertyCategory import setzPropertyCategory

skinsDir = os.path.join(os.path.dirname(__file__), 'skins')
if os.path.isdir(skinsDir):
    registerDirectory(skinsDir, globals())

_PACK_Z_PROPS = [
    ('zVSphereUsername', '', 'string'),
    ('zVSpherePassword', '', 'password'),
]

for name, default_value, type_ in _PACK_Z_PROPS:
    setzPropertyCategory(name, 'VMware')

class ZenPack(ZenPackBase):
    packZProperties = _PACK_Z_PROPS

    def install(self, app):
        if not hasattr(app.zport.dmd.Events.Status, 'VMware'):
            app.zport.dmd.Events.createOrganizer("/Status/VMware")
        app.zport.dmd.Reports.createOrganizer('/VMware Reports')
        ZenPackBase.install(self, app)
        log.info('Linking icon into $ZENHOME/Products/ZenWidgets/skins/zenui/img/icons')
        os.system('ln -sf %s %s' % (self.path('resources/img/icons/server-vmware.png'), zenPath('Products/ZenWidgets/skins/zenui/img/icons', 'server-vmware.png')))
        os.system('chmod 0644 %s' % (zenPath('Products/ZenWidgets/skins/zenui/img/icons', 'server-vmware.png')))

    def upgrade(self, app):
        if not hasattr(app.zport.dmd.Events.Status, 'VMware'):
Пример #24
0
import Globals

from Products.Zuul import getFacade
from Products.ZenEvents.EventManagerBase import EventManagerBase
from Products.ZenModel.Device import Device
from Products.ZenModel.ZenPack import ZenPack as ZenPackBase
from Products.ZenRelations.RelSchema import ToManyCont, ToOne
from Products.ZenRelations.zPropertyCategory import setzPropertyCategory
from Products.ZenUtils.Utils import unused, monkeypatch
from Products.Zuul.interfaces import ICatalogTool

unused(Globals)

# Categorize zProperties.
setzPropertyCategory('zHBaseScheme', 'HBase')
setzPropertyCategory('zHBaseUsername', 'HBase')
setzPropertyCategory('zHBasePassword', 'HBase')
setzPropertyCategory('zHBaseRestPort', 'HBase')
setzPropertyCategory('zHBaseMasterPort', 'HBase')
setzPropertyCategory('zHBaseRegionServerPort', 'HBase')

# Modules containing model classes. Used by zenchkschema to validate
# bidirectional integrity of defined relationships.
productNames = ('HBaseRegionServer', 'HBaseTable', 'HBaseHRegion')

# Useful to avoid making literal string references to module and class names
# throughout the rest of the ZenPack.
ZP_NAME = 'ZenPacks.zenoss.HBase'
MODULE_NAME = {}
CLASS_NAME = {}
_discovery_plugins = ('zenoss.wmi.IpInterfaceMap', 'zenoss.wmi.IpRouteMap')

_PACK_Z_PROPS = [('zWinPerfCycleSeconds', 300, 'int'),
                 ('zWinPerfCyclesPerConnection', 5, 'int'),
                 ('zWinPerfTimeoutSeconds', 10, 'int'),
                 ('zWinEventlogClause', '', 'string'),
                 ('zWmiMonitorIgnore', True, 'boolean'),
                 ('zWinUser', '', 'string'),
                 ('zWinPassword', '', 'password'),
                 ('zWinEventlogMinSeverity', 2, 'int'),
                 ('zWinEventlog', False, 'boolean'),
                ]

for name, default_value, type_ in _PACK_Z_PROPS:
    setzPropertyCategory(name, 'Windows')

def _addPluginsToDiscovered(dmd):
    # Get a reference to the device class
    dmd = dmd.primaryAq()
    devcls = dmd.Devices.Discovered
    # Only add plugins that aren't already there
    current = tuple(devcls.zCollectorPlugins)
    new = _discovery_plugins
    toadd = tuple(set(new) - set(current))
    if not toadd: return
    newstate = current + toadd
    # Set the zProperty
    devcls.setZenProperty('zCollectorPlugins', newstate)

def _removePluginsFromDiscovered(dmd):
Пример #26
0
_discovery_plugins = ('zenoss.wmi.IpInterfaceMap', 'zenoss.wmi.IpRouteMap')

_PACK_Z_PROPS = [
    ('zWinPerfCycleSeconds', 300, 'int'),
    ('zWinPerfCyclesPerConnection', 5, 'int'),
    ('zWinPerfTimeoutSeconds', 10, 'int'),
    ('zWinEventlogClause', '', 'string'),
    ('zWmiMonitorIgnore', True, 'boolean'),
    ('zWinUser', '', 'string'),
    ('zWinPassword', '', 'password'),
    ('zWinEventlogMinSeverity', 2, 'int'),
    ('zWinEventlog', False, 'boolean'),
]

for name, default_value, type_ in _PACK_Z_PROPS:
    setzPropertyCategory(name, 'Windows')


def _addPluginsToDiscovered(dmd):
    # Get a reference to the device class
    dmd = dmd.primaryAq()
    devcls = dmd.Devices.Discovered
    # Only add plugins that aren't already there
    current = tuple(devcls.zCollectorPlugins)
    new = _discovery_plugins
    toadd = tuple(set(new) - set(current))
    if not toadd: return
    newstate = current + toadd
    # Set the zProperty
    devcls.setZenProperty('zCollectorPlugins', newstate)
Пример #27
0
# Used by zenchkschema to validate consistency of relationships.
productNames = (
    'System',
    'DataCenter',
    'StorageDomain',
    'Cluster',
    'Host',
    'HostNic',
    'Vm',
    'VmNic',
    'VmDisk',
    )


# Add categories to our contributed zProperties.
setzPropertyCategory('zOVirtUrl', 'oVirt')
setzPropertyCategory('zOVirtUser', 'oVirt')
setzPropertyCategory('zOVirtPassword', 'oVirt')
setzPropertyCategory('zOVirtDomain', 'oVirt')


class BaseComponent(DeviceComponent, ManagedEntity):
    """
    Abstract base class to avoid repeating boilerplate code in all of the
    DeviceComponent subclasses in this zenpack.
    """

    # Disambiguate multi-inheritence.
    _relations = ManagedEntity._relations

    # This makes the "Templates" component display available.
class ZenPack(ZenPackBase):
    """ zenpack installer

    setting zCiscoMonIgnoreNotPresent will drop alerts from components in the
    notPresent state
    setting zCiscoMonTemperatureFactor will set temperaturealert thresholds
    to be shutdown temp threshold - zCiscoMonTemperatureFactor (in celcius)
    zCiscoMonVoltageFactor works the same way (millivolts)
        note -2 temperature factore is about 4F
    """

    packZProperties = [
        ('zCiscoMonIgnoreNotPresent', True, 'boolean'),
        ('zCiscoMonTemperatureFactor', .90, 'float'),
        ('zCiscoMonVoltageFactor', .90, 'float'),
        ('zEnvMonMapIgnoreNames', '', 'string'),
    ]

    for i in packZProperties:
        setzPropertyCategory(i[0], "CiscoEnvMonE")

    def install(self, app):
        ZenPackBase.install(self, app)

        super(ZenPack, self).install(app)
        log.info("Adding ZenPacks.community.CiscoEnvmonE"
                 " relationships to existing devices")

        self._buildHWRelations()

    def remove(self, app, leaveObjects=False):
        if not leaveObjects:

            from Products.ZenModel.DeviceHW import DeviceHW

            NEW_COMPONENT_TYPES = tuple([x for x in productNames])

            log.info('Removing ZenPacks.community.CiscoEnvmonE components')
            cat = ICatalogTool(app.zport.dmd)

            # Search the catalog for components of this zenpacks type.
            if NEW_COMPONENT_TYPES:
                for brain in cat.search(types=NEW_COMPONENT_TYPES):
                    component = brain.getObject()
                    component.getPrimaryParent()._delObject(component.id)

            hw_relations = ("ciscoenvvoltagesensors", "ciscoenvtempsensors"
                            "ciscoenvfans"
                            "ciscoenvpowersupplies")

            # remote HW component relations
            DeviceHW._relations = tuple(
                [x for x in DeviceHW._relations if x[0] not in hw_relations])

            log.info('Removing ZenPacks.community.CiscoEnvMonE'
                     'relationships from existing devices')

            self._buildHWRelations()

        super(ZenPack, self).remove(app, leaveObjects=leaveObjects)

    def _buildHWRelations(self):
        for d in self.dmd.Devices.getSubDevicesGen():
            d.hw.buildRelations()
            d.buildRelations()
Пример #29
0
DEVTYPE_PROTOCOL = 'WMI'

_PACK_Z_PROPS = [
    ('zWinRMUser', '', 'string'),
    ('zWinRMPassword', '', 'password'),
    ('zWinRMPort', '5985', 'string'),
    ('zDBInstances', 'MSSQLSERVER;', 'string'),
    ('zDBInstancesPassword', '', 'password'),
    ('zWinKDC', '', 'string'),
    ('zWinKeyTabFilePath', '', 'string'),
    ('zWinScheme', 'http', 'string'),
    ('zWinPerfmonInterval', 300, 'int'),
]

for name, default_value, type_ in _PACK_Z_PROPS:
    setzPropertyCategory(name, 'Windows')

# General zProp for Instance logins
# Format example:
# zDBInstanceLogin = '******'
# zDBInstnacePassword = '******'

setzPropertyCategory('zDBInstances', 'Misc')
setzPropertyCategory('zDBInstancesPassword', 'Misc')

# Used by zenchkschema to validate relationship schema.
productNames = (
    'ClusterDevice',
    'ClusterResource',
    'ClusterService',
    'CPU',
Пример #30
0
#
# This content is made available according to terms specified in
# License.zenoss under the directory where your Zenoss product is installed.
#
##############################################################################

import os
import json

from Products.ZenModel.ZenPack import ZenPackBase, ZenPackDependentsException
from Products.ZenRelations.zPropertyCategory import setzPropertyCategory

from collections import defaultdict

# Categorize zProperties.
setzPropertyCategory('zAWSDiscover', 'AWS')
setzPropertyCategory('zAWSRegionPEM', 'AWS')
setzPropertyCategory('zAWSRemodelEnabled', 'AWS')
setzPropertyCategory('zAWSGuestCollector', 'AWS')
setzPropertyCategory('zAWSResetGuestCollector', 'AWS')
setzPropertyCategory('zAWSGuestUsePublicIPs', 'AWS')

# Modules containing model classes. Used by zenchkschema to validate
# bidirectional integrity of defined relationships.
productNames = (
    'EC2Account',
    'EC2Instance',
    'EC2Region',
    'EC2Volume',
    'EC2VPC',
    'EC2VPCSubnet',
Пример #31
0
from Products.ZenEvents.EventManagerBase import EventManagerBase
from Products.ZenModel.Device import Device
from Products.ZenModel.ZenPack import ZenPack as ZenPackBase
from Products.ZenRelations.RelSchema import ToManyCont, ToOne
from Products.ZenUtils.Utils import unused
from Products.Zuul.interfaces import ICatalogTool

from Products.ZenRelations.zPropertyCategory import setzPropertyCategory

unused(Globals)


ZENPACK_NAME = 'ZenPacks.zenoss.RabbitMQ'

# Set zProperty categories for RabbitMQAdmin zProperties
setzPropertyCategory('zRabbitMQAdminUser', 'RabbitMQ')
setzPropertyCategory('zRabbitMQAdminPassword', 'RabbitMQ')

# Define new device relations.
NEW_DEVICE_RELATIONS = (
    ('rabbitmq_nodes', 'RabbitMQNode'),
    )

NEW_COMPONENT_TYPES = (
    'ZenPacks.zenoss.RabbitMQ.RabbitMQNode.RabbitMQNode',
    )

# Add new relationships to Device if they don't already exist.
for relname, modname in NEW_DEVICE_RELATIONS:
    if relname not in (x[0] for x in Device._relations):
        Device._relations += (
    'RouterVM',
    'SystemVM',
    'VirtualMachine',
    'Zone',
    )

# Useful to avoid making literal string references to module and class names
# throughout the rest of the ZenPack.
MODULE_NAME = {}
CLASS_NAME = {}

for product_name in productNames:
    MODULE_NAME[product_name] = '.'.join([ZENPACK_NAME, product_name])
    CLASS_NAME[product_name] = '.'.join([ZENPACK_NAME, product_name, product_name])

setzPropertyCategory('zCloudStackURL', 'CloudStack')
setzPropertyCategory('zCloudStackAPIKey', 'CloudStack')
setzPropertyCategory('zCloudStackSecretKey', 'CloudStack')


class ZenPack(ZenPackBase):
    packZProperties = [
        ('zCloudStackURL', '', 'string'),
        ('zCloudStackAPIKey', '', 'string'),
        ('zCloudStackSecretKey', '', 'string'),
        ]

    _plugins = (
        'poll_cloudstack.py',
        )
Пример #33
0
import logging
log = logging.getLogger('zen.ZooKeeper')

import Globals

from Products.ZenModel.Device import Device
from Products.ZenModel.ZenPack import ZenPack as ZenPackBase
from Products.ZenRelations.RelSchema import ToManyCont, ToOne
from Products.ZenUtils.Utils import unused
from Products.Zuul.interfaces import ICatalogTool
from Products.ZenRelations.zPropertyCategory import setzPropertyCategory

unused(Globals)

# Categorize zProperties.
setzPropertyCategory('zZooKeeperPort', 'ZooKeeper')

# Modules containing model classes. Used by zenchkschema to validate
# bidirectional integrity of defined relationships.
productNames = ('ZooKeeper', )

# Useful to avoid making literal string references to module and class names
# throughout the rest of the ZenPack.
ZP_NAME = 'ZenPacks.zenoss.ZooKeeper'
MODULE_NAME = {}
CLASS_NAME = {}
for product_name in productNames:
    MODULE_NAME[product_name] = '.'.join([ZP_NAME, product_name])
    CLASS_NAME[product_name] = '.'.join([ZP_NAME, product_name, product_name])

# Define new device relations.
    '/Server/Linux',
    '/Server/Windows',
    ]

# Modelers
_MODELERS = [
    'Secure24.nrpe.Check_NRPE',
    ]

# Setup zProperties
_PACK_Z_PROPS = [
    ('zNRPEChecks', '', 'lines'),
    ]

for name, default_value, type_ in _PACK_Z_PROPS:
    setzPropertyCategory(name, 'NRPE')

# Setup relationship
OperatingSystem._relations += (
    ("nrpeComponent", ToManyCont(ToOne, "ZenPacks.Secure24.Check_NRPE.nrpeComponent", "os")),
)

class ZenPack(ZenPackBase):

    packZProperties = [
        ('zNRPEChecks', '', 'lines'),
        ]

    def install(self, app):

        super(ZenPack, self).install(app)
def setDescriptors(dmd):
    """
    Set the property descriptors on the ZenPropertyManager class.  The
    transformerFactories parameter is a dictionary that maps a property type
    to a callable factory that produces instances with transformForGet and
    transformForSet methods.
    """
    zprops = {}

    # copy the core zProps
    # Z_PROPERTIES = id, defaultValue, type , label, description
    for item in Z_PROPERTIES:
        id = item[0]
        type = item[2]
        zprops[id] = (id, type)
        Z_PROPERTY_META_DATA[id] = dict()
        Z_PROPERTY_META_DATA[id]['type'] = type
        Z_PROPERTY_META_DATA[id]['defaultValue'] = item[1]
        if len(item) >= 4:
            Z_PROPERTY_META_DATA[id]['label'] = item[3]
        if len(item) >= 5:
            Z_PROPERTY_META_DATA[id]['description'] = item[4]

    # add zProps from zenpacks
    from Products.ZenUtils.PkgResources import pkg_resources
    for zpkg in pkg_resources.iter_entry_points('zenoss.zenpacks'):
        # fromlist is typically ZenPacks.zenoss
        fromlist = zpkg.module_name.split('.')[:-1]
        module = __import__(zpkg.module_name, globals(), locals(), fromlist)
        if hasattr(module, 'ZenPack'):
            # Merge ZenPack.packZProperties and ZenPack.packZProperties_data.
            # packZProperties wins if they disagree about type or defaultValue.
            for p_id, p_data in module.ZenPack.getZProperties().items():
                if p_id in zprops:
                    log.warning("%s tried to override existing %s property.",
                                zpkg.module_name, p_id)
                    continue

                zprops[p_id] = (p_id, p_data['type'])

                category = p_data.get('category')
                if category:
                    setzPropertyCategory(p_id, category)

                Z_PROPERTY_META_DATA[p_id] = {
                    'type': p_data.get('type', 'string'),
                    'defaultValue': p_data.get('defaultValue'),
                    'label': p_data.get('label'),
                    'description': p_data.get('description'),
                    'category': category,
                }

    # add zProps from dmd.Devices to catch any that are undefined elsewhere
    for p_id in dmd.Devices.zenPropertyIds():
        p_type = dmd.Devices.getPropertyType(p_id)
        if p_id not in zprops:
            zprops[p_id] = (p_id, p_type)
            log.debug(
                "Property %s is deprecated. It should be removed "
                "from the system.", p_id)

    monkeypatchDescriptors(zprops.values(), dmd.propertyTransformers)
 def create(self):
     """Implement specification."""
     if self.category:
         setzPropertyCategory(self.name, self.category)
Пример #37
0
# License.zenoss under the directory where your Zenoss product is installed.
#
##############################################################################

import logging
LOG = logging.getLogger('zen.WBEM')

from Products.ZenModel.ZenPack import ZenPackBase
from Products.ZenRelations.zPropertyCategory import setzPropertyCategory
import ZenPacks.zenoss.WBEM.patches


# Categorize our zProperties.
ZPROPERTY_CATEGORY = 'WBEM'

setzPropertyCategory('zWBEMPort', ZPROPERTY_CATEGORY)
setzPropertyCategory('zWBEMUsername', ZPROPERTY_CATEGORY)
setzPropertyCategory('zWBEMPassword', ZPROPERTY_CATEGORY)
setzPropertyCategory('zWBEMUseSSL', ZPROPERTY_CATEGORY)
setzPropertyCategory('zWBEMRequestTimeout', ZPROPERTY_CATEGORY)
setzPropertyCategory('zWBEMMaxObjectCount', ZPROPERTY_CATEGORY)
setzPropertyCategory('zWBEMOperationTimeout', ZPROPERTY_CATEGORY)


class ZenPack(ZenPackBase):
    """WBEM ZenPack."""

    packZProperties = [
        ('zWBEMPort', 5989, 'int'),
        ('zWBEMUsername', '', 'string'),
        ('zWBEMPassword', '', 'password'),