Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4f7933b
Showing
45 changed files
with
1,706 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from Products.ZenModel.DeviceComponent import DeviceComponent | ||
from Products.ZenModel.ManagedEntity import ManagedEntity | ||
from Products.ZenModel.ZenossSecurity import ZEN_CHANGE_DEVICE | ||
from Products.ZenRelations.RelSchema import ToManyCont, ToOne | ||
|
||
|
||
class ExampleComponent(DeviceComponent, ManagedEntity): | ||
meta_type = portal_type = "ExampleComponent" | ||
|
||
attributeOne = None | ||
attributeTwo = None | ||
|
||
_properties = ManagedEntity._properties + ( | ||
{'id': 'attributeOne', 'type': 'int', 'mode': ''}, | ||
{'id': 'attributeTwo', 'type': 'string', 'mode': ''}, | ||
) | ||
|
||
_relations = ManagedEntity._relations + ( | ||
('exampleDevice', ToOne(ToManyCont, | ||
'ZenPacks.NAMESPACE.PACKNAME.ExampleDevice.ExampleDevice', | ||
'exampleComponents', | ||
), | ||
), | ||
) | ||
|
||
# Defining the "perfConf" action here causes the "Graphs" display to be | ||
# available for components of this type. | ||
factory_type_information = ({ | ||
'actions': ({ | ||
'id': 'perfConf', | ||
'name': 'Template', | ||
'action': 'objTemplates', | ||
'permissions': (ZEN_CHANGE_DEVICE,), | ||
},), | ||
},) | ||
|
||
# Custom components must always implement the device method. The method | ||
# should return the device object that contains the component. | ||
def device(self): | ||
return self.exampleDevice() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from Products.ZenModel.Device import Device | ||
from Products.ZenRelations.RelSchema import ToManyCont, ToOne | ||
|
||
|
||
class ExampleDevice(Device): | ||
""" | ||
Example device subclass. In this case the reason for creating a subclass of | ||
device is to add a new type of relation. We want many "ExampleComponent" | ||
components to be associated with each of these devices. | ||
If you set the zPythonClass of a device class to | ||
ZenPacks.NAMESPACE.PACKNAME.ExampleDevice, any devices created or moved | ||
into that device class will become this class and be able to contain | ||
ExampleComponents. | ||
""" | ||
|
||
meta_type = portal_type = 'ExampleDevice' | ||
|
||
# This is where we extend the standard relationships of a device to add | ||
# our "exampleComponents" relationship that must be filled with components | ||
# of our custom "ExampleComponent" class. | ||
_relations = Device._relations + ( | ||
('exampleComponents', ToManyCont(ToOne, | ||
'ZenPacks.NAMESPACE.PACKNAME.ExampleComponent.ExampleComponent', | ||
'exampleDevice', | ||
), | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Nothing is required in this __init__.py, but it is an excellent place to do | ||
# many things in a ZenPack. | ||
# | ||
# The example below which is commented out by default creates a custom subclass | ||
# of the ZenPack class. This allows you to define custom installation and | ||
# removal routines for your ZenPack. If you don't need this kind of flexibility | ||
# you should leave the section commented out and let the standard ZenPack | ||
# class be used. | ||
# | ||
# Code included in the global scope of this file will be executed at startup | ||
# in any Zope client. This includes Zope itself (the web interface) and zenhub. | ||
# This makes this the perfect place to alter lower-level stock behavior | ||
# through monkey-patching. | ||
|
||
# import Globals | ||
# | ||
# from Products.ZenModel.ZenPack import ZenPack as ZenPackBase | ||
# from Products.ZenUtils.Utils import unused | ||
# | ||
# unused(Globals) | ||
# | ||
# | ||
# class ZenPack(ZenPackBase): | ||
# | ||
# # All zProperties defined here will automatically be created when the | ||
# # ZenPack is installed. | ||
# packZProperties = [ | ||
# ('zExampleString', 'default value', 'string'), | ||
# ('zExampleInt', 411, 'int'), | ||
# ('zExamplePassword', 'notsecure', 'password'), | ||
# ] | ||
# | ||
# def install(self, dmd): | ||
# ZenPackBase.install(self, dmd) | ||
# | ||
# # Put your customer installation logic here. | ||
# pass | ||
# | ||
# def remove(self, dmd, leaveObjects=False): | ||
# if not leaveObjects: | ||
# # When a ZenPack is removed the remove method will be called with | ||
# # leaveObjects set to False. This means that you likely want to | ||
# # make sure that leaveObjects is set to false before executing | ||
# # your custom removal code. | ||
# pass | ||
# | ||
# ZenPackBase.remove(self, dmd, leaveObjects=leaveObjects) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from zope.component import adapts | ||
from zope.interface import implements | ||
|
||
from Products.Zuul.interfaces import IReportable | ||
|
||
from ZenPacks.zenoss.ZenETL.reportable \ | ||
import Reportable, MARKER_LENGTH, DEFAULT_STRING_LENGTH | ||
|
||
from .ExampleComponent import ExampleComponent | ||
|
||
|
||
class ExampleComponentReportable(Reportable): | ||
implements(IReportable) | ||
adapts(ExampleComponent) | ||
|
||
@property | ||
def entity_class_name(self): | ||
return 'example_component' | ||
|
||
def reportProperties(self): | ||
""" | ||
We want to export our two custom properties to the data warehouse for | ||
reporting. | ||
""" | ||
return [ | ||
('attributeOne', 'int', | ||
self.context.attribuetOne, MARKER_LENGTH), | ||
|
||
('attributeTwo', 'string', | ||
self.context.attributeTwo, DEFAULT_STRING_LENGTH), | ||
] |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configure xmlns="http://namespaces.zope.org/browser"> | ||
|
||
<!-- A resource directory contains static web content. | ||
<resourceDirectory | ||
name="example" | ||
directory="resources" | ||
/> | ||
--> | ||
|
||
<!-- Register custom JavaScript for ExampleDevices. | ||
<viewlet | ||
name="js-exampledevice" | ||
paths="/++resource++example/js/ExampleDevice.js" | ||
weight="10" | ||
for="..ExampleDevice.ExampleDevice" | ||
manager="Products.ZenUI3.browser.interfaces.IJavaScriptSrcManager" | ||
class="Products.ZenUI3.browser.javascript.JavaScriptSrcBundleViewlet" | ||
permission="zope2.Public" | ||
/> | ||
--> | ||
|
||
</configure> |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Based on the configuration in ../../configure.zcml this JavaScript will only | ||
* be loaded when the user is looking at an ExampleDevice in the web interface. | ||
*/ | ||
|
||
(function(){ | ||
|
||
var ZC = Ext.ns('Zenoss.component'); | ||
|
||
|
||
/* | ||
* Friendly names for the components. First parameter is the meta_type in your | ||
* custom component class. Second parameter is the singular form of the | ||
* friendly name to be displayed in the UI. Third parameter is the plural form. | ||
*/ | ||
ZC.registerName('ExampleComponent', _t('Example'), _t('Examples')); | ||
|
||
|
||
/* | ||
* Custom component grid panel. This controls the grid that gets displayed for | ||
* components of the type set in "componenType". | ||
*/ | ||
ZC.ExampleComponentGridPanel = Ext.extend(ZC.ComponentGridPanel, { | ||
subComponentGridPanel: false, | ||
|
||
constructor: function(config) { | ||
config = Ext.applyIf(config||{}, { | ||
autoExpandColumn: 'name', | ||
componentType: 'ExampleComponent', | ||
sortInfo: { | ||
field: 'name', | ||
direction: 'ASC' | ||
}, | ||
fields: [ | ||
{name: 'uid'}, | ||
{name: 'name'}, | ||
{name: 'severity'}, | ||
{name: 'attributeOne'}, | ||
{name: 'attributeTwo'}, | ||
{name: 'monitor'}, | ||
{name: 'monitored'} | ||
], | ||
columns: [{ | ||
id: 'severity', | ||
dataIndex: 'severity', | ||
header: _t('Events'), | ||
renderer: Zenoss.render.severity, | ||
sortable: true, | ||
width: 50 | ||
},{ | ||
id: 'name', | ||
dataIndex: 'name', | ||
header: _t('Name') | ||
},{ | ||
id: 'attributeOne', | ||
dataIndex: 'attributeOne', | ||
header: _t('Attribute #1'), | ||
sortable: true, | ||
width: 70 | ||
},{ | ||
id: 'attributeTwo', | ||
dataIndex: 'attributeTwo', | ||
header: _t('Attribute #2'), | ||
sortable: true, | ||
width: 70 | ||
},{ | ||
id: 'monitored', | ||
dataIndex: 'monitored', | ||
header: _t('Monitored'), | ||
renderer: Zenoss.render.checkbox, | ||
sortable: true, | ||
width: 65 | ||
}] | ||
}); | ||
ZC.ExampleComponentGridPanel.superclass.constructor.call(this, config); | ||
} | ||
}); | ||
|
||
Ext.reg('ExampleComponentGridPanel', ZC.ExampleComponentGridPanel); | ||
|
||
})(); |
Oops, something went wrong.