Skip to content

Commit

Permalink
Merge branch 'release/1.0.12'
Browse files Browse the repository at this point in the history
  • Loading branch information
eedgar committed Aug 21, 2013
2 parents b425481 + b913a30 commit b41e398
Show file tree
Hide file tree
Showing 20 changed files with 387 additions and 37 deletions.
10 changes: 10 additions & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Examples of JSON input files
==============================================================================

Netbotz
--------------------

NetBotz II Example::

{
Expand Down Expand Up @@ -42,6 +45,10 @@ NetBotz II Example::
}]
}


Genbotz Generalization of Netbotz
----------------------------------

GenBotz Example with Organizers (DeviceClasses)::


Expand Down Expand Up @@ -101,6 +108,9 @@ GenBotz Example with Organizers (DeviceClasses)::
}]
}

NetScalar
--------------------

NetScaler Example::

{
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This is the documentation for the ZenPack Generator tool.
usage
jsonformat
examples
use_cases


Indices and tables
Expand Down
23 changes: 20 additions & 3 deletions docs/jsonformat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,12 @@ Json Options for a ComponentType::

.. _deviceType:

deviceType []
deviceType {}
-------------

Json Options for a DeviceType::

"deviceType": [{
"deviceType": {
"name": "DeviceName",
"names": "DeviceNames",
"klasses": ['DeviceComponent'],
Expand All @@ -228,7 +228,7 @@ Json Options for a DeviceType::
"componentTypes": [],
"impacts": [],
"impactedBy": []
}]
}

* name: The Name of the Device Component, Used to define the Module and Class of a Component. [required]
* names: The Plural Form of the Device Component Name. [optional]
Expand Down Expand Up @@ -271,6 +271,10 @@ Json Options for a Property::
"mode": 'w',
"value": 10,
"detailDisplay": True,
readonly=True,
detail_group=None,
detail_order=None,
addl_detail_args=None,
"gridDisplay": True,
"sortable": True,
"width": 10,
Expand All @@ -291,6 +295,19 @@ Json Options for a Property::
* True
* False
* Defaults to True
* readonly: Allow the property to be modified from the detail pane.
* Valid Inputs:
* True
* False
* Defaults to True
* detail_group: Group the property in the details pane. [Currently unsupported in Zenoss]
* Valid Inputs:
* string
* detail_order: Order the property in the details pane. [Currently unsupported in Zenoss]
* Valid Inputs:
* positive or negative integer
* addl_detail_args: A free form string to pass the details pane.
* A string
* gridDisplay: Display the property in the Grid Component Panel section.
* Valid Inputs:
* True
Expand Down
64 changes: 64 additions & 0 deletions docs/use_cases.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
==============================================================================
Specific Examples of ZPG Use Cases
==============================================================================
This document will provide specific use cases and fragments that will
hopefully guide the users onto a higher plane of ZPG conciousness.

Devices without a Root
==============================================================================

OracleDB::

In this example OracleDB is a device that inherits its /Device base from the
parent server, be it Linux, AIX, Solaris, or some "other" operating system.
This means that it needs to be able to patch itself underneath the device tree
of that server target type and not have a stand-alone device root.

Thus inside of ZenPacks.zenoss.OracleDB/ZenPacks/zenoss/OracleDB/__init__.py
we should see:

__init__.py::

# Define new device relations.
NEW_DEVICE_RELATIONS = (
('instance', 'OracleInstance'),
('storage', 'OracleStorage'),
('rac', 'OracleRAC'),
('schema', 'OracleSchema'),
)

In order to achieve this you must remove the entire "deviceType" structure out of
the ZPG json file;

OracleDB.json Example::

{
"id": "ZenPacks.zenoss.OracleDB",
"author": "Zenoss",
"version": "0.0.1",
"compat_zenoss_vers": ">=4.2",

"deviceClasses": [{
"path": "",

"componentTypes": [
{
"name": "Instance",
"meta_type": "OracleInstance",
"properties": [
{"name": "sid"},
{"name": "name_label"},
{"name": "connectionString", "Type": "string"},
{"name": "hostname"},
{"name": "oracleVersion"},
{"name": "databaseName"},
{"name": "databaseDBID"},
{"name": "databasePlatformName"},
{"name": "RACnetworkPeers"},
{"name": "instanceRole"},
{"name": "publicIP"},
{"name": "interconnectIP"}
]
},...
}]....
}
1 change: 1 addition & 0 deletions docs/zenpackgenerator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Prerequisites

* Linux or Mac
* Python 2.7
* Python setuptools

This tool does NOT require a zenoss server.

Expand Down
14 changes: 14 additions & 0 deletions zpg/Component.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
#
#

import logging

import inflect

from .colors import error, warn, debug, info, green, red, yellow
from ._defaults import Defaults
from ._zenoss_utils import KlassExpand, zpDir
from .Property import Property
Expand Down Expand Up @@ -41,6 +44,8 @@ def __init__(self,
componentTypes=None,
impacts=None,
impactedBy=None,
*args,
**kwargs
):
"""Args:
name: Component Name
Expand All @@ -65,6 +70,15 @@ def __init__(self,
"""
super(Component, self).__init__(zenpack)
self.logger = logger = logging.getLogger('ZenPack Generator')
for key in kwargs:
do_not_warn = False
clsname = self.__class__.__name__
layer = "%s:%s" % (clsname, name)
msg = "WARNING: [%s] unknown keyword ignored in file: '%s'"
margs = (layer, key)
if not do_not_warn:
warn(self.logger, yellow(msg) % margs)
self.source_template = 'component.tmpl'
self.name = name.split('.')[-1]
self.names = names
Expand Down
17 changes: 15 additions & 2 deletions zpg/DeviceClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
# file at the top-level directory of this package.
#
#
import logging

from .colors import error, warn, debug, info, green, red, yellow
from ._zenoss_utils import KlassExpand
from .Relationship import Relationship
find = Relationship.find
Expand All @@ -24,14 +26,17 @@ def __init__(self,
prefix='/zport/dmd',
zPythonClass='Products.ZenModel.Device.Device',
componentTypes=None,
deviceType=None):
deviceType=None,
*args,
**kwargs
):
'''Args:
path: Destination device class path (the prefix is
automatically prepended)
ZenPack: ZenPack Class Instance
prefix: Destination device class prefix [/zport/dmd]
zPythonClass: The zPythonClass this Device Class references.
[Products.ZenModel.Device.Device]
[Products.ZenModel.Device]
componentTypes: an array of dictionaries used to create
components.
deviceType: a dictionary used to create a device component.
Expand All @@ -42,6 +47,14 @@ def __init__(self,
self.id = self.path
self.subClasses = {}
self.zPythonClass = KlassExpand(self.zenpack, zPythonClass)
self.logger = logger = logging.getLogger('ZenPack Generator')
for key in kwargs:
do_not_warn = False
layer = self.__class__.__name__
msg = "WARNING: JSON keyword ignored in layer '%s': '%s'"
margs = (layer, key)
if not do_not_warn:
warn(self.logger, yellow(msg) % margs)
if deviceType:
self.DeviceType(**deviceType)
else:
Expand Down
8 changes: 4 additions & 4 deletions zpg/License.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ def __init__(self, zenpack, id_):

elif id_ in dflt_licenses:
self.id = id_
self.header = load_header('Licenses', self.id)
self.license = load_license('Licenses', self.id)
self.header = load_header(tpath, self.id)
self.license = load_license(tpath, self.id)
else:
# Default GPlv2
info(log,
red('Specified License [%s] not known. Defaulting to GPLv2.'
% id_))
self.id = 'GPLv2'
self.header = load_header('Licenses', self.id)
self.license = load_license('Licenses', self.id)
self.header = load_header(tpath, self.id)
self.license = load_license(tpath, self.id)

def header(self):
return self.header
Expand Down
29 changes: 27 additions & 2 deletions zpg/Organizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
#
#

import logging
import sys

from lxml import etree

from .colors import error, warn, debug, info, green, red, yellow
from .Property import Property
from ._zenoss_utils import KlassExpand

Expand All @@ -23,8 +25,10 @@ class Organizer(object):
def __init__(self,
zenpack,
name,
type_,
properties=None
type_=None,
properties=None,
*args,
**kwargs
):
"""Args:
name: Organizer Name in the form of a Slash separated path.
Expand All @@ -36,6 +40,27 @@ def __init__(self,
self.id = name
self.type_ = type_
self.properties = {}
self.logger = logger = logging.getLogger('ZenPack Generator')
for key in kwargs:
do_not_warn = False
layer = self.__class__.__name__
msg = "WARNING: JSON keyword ignored in layer '%s': '%s'"
margs = (layer, key)
if key == "Type":
msg = "WARNING: JSON keyword deprecated in '%s' layer. "\
"'%s' is now '%s'."
margs = (layer, key, key.lower())
self.type_ = kwargs[key]
elif key == "type":
self.type_ = type_ = kwargs[key]
do_not_warn = True
elif key == "Contained":
msg = "WARNING: JSON keyword deprecated in '%s' layer. "\
"'%s' is now '%s'."
margs = (layer, key, key.lower())
self.contained = kwargs[key]
if not do_not_warn:
warn(self.logger, yellow(msg) % margs)
# Dict loading
if properties:
for p in properties:
Expand Down
Loading

0 comments on commit b41e398

Please sign in to comment.