-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
15 changed files
with
250 additions
and
25 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
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,9 @@ | ||
{ | ||
"deviceClasses": [ { "path": "Device" } ], | ||
"discoveryMappings": [ | ||
{ "oid": "1.2.3.4.5", | ||
"deviceClass": "Network/Example"}, | ||
{ "oid": "1.2.3.4.5.6", | ||
"deviceClass": "Network/Example"}], | ||
"id": "ZenPacks.training.AutoClassification" | ||
} |
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 |
---|---|---|
|
@@ -47,6 +47,7 @@ | |
'Mock', | ||
'nose', | ||
'pep8', | ||
'argparse' | ||
] | ||
|
||
|
||
|
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,44 @@ | ||
#!/usr/bin/env python | ||
############################################################################## | ||
# | ||
# Copyright (C) Zenoss, Inc. 2013, all rights reserved. | ||
# | ||
# This content is made available according to terms specified in the LICENSE | ||
# file at the top-level directory of this package. | ||
# | ||
############################################################################## | ||
|
||
from ._defaults import Defaults | ||
from ._zenoss_utils import KlassExpand, zpDir | ||
from .Template import Template | ||
defaults = Defaults() | ||
|
||
|
||
class AutoClassificationZcml(Template): | ||
"""Build the autoclassification.zcml file""" | ||
|
||
def __init__(self, | ||
zenpack, | ||
): | ||
'''Args: | ||
zenpack: ZenPack class instance | ||
''' | ||
|
||
super(AutoClassificationZcml, self).__init__(zenpack) | ||
self.source_template = 'autoclassification.zcml.tmpl' | ||
self.zenpack = zenpack | ||
self.components = zenpack.components | ||
|
||
self.dest_file = "%s/autoclassification.zcml" % zpDir(zenpack) | ||
|
||
def discoveryMappings(self): | ||
if self.zenpack.discoveryMappings: | ||
return True | ||
return False | ||
|
||
def write(self): | ||
'''Write the file''' | ||
|
||
if self.discoveryMappings(): | ||
self.processTemplate() |
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
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
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
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,46 @@ | ||
#!/usr/bin/env python | ||
# | ||
# | ||
# Copyright (C) Zenoss, Inc. 2013, all rights reserved. | ||
# | ||
# This content is made available according to terms specified in the LICENSE | ||
# file at the top-level directory of this package. | ||
# | ||
# | ||
|
||
from .colors import error, warn, debug, info, green, red, yellow | ||
|
||
|
||
class DiscoveryMapping(object): | ||
''' Discovery Mapping Object ''' | ||
|
||
discoveryMappings = {} | ||
|
||
def __init__(self, | ||
zenpack, | ||
oid, | ||
deviceClass, | ||
*args, | ||
**kwargs | ||
): | ||
"""Args: | ||
zenpack: the containing zenpack | ||
oid: a devices snmpoid to match | ||
deviceClass: destination device class to move the | ||
discovered device | ||
""" | ||
self.zenpack = zenpack | ||
self.oid = oid | ||
self.deviceClass = deviceClass | ||
|
||
for key in kwargs: | ||
do_not_warn = False | ||
clsname = self.__class__.__name__ | ||
layer = "%s:%s" % (clsname, self.name) | ||
msg = "WARNING: [%s] unknown keyword ignored in file: '%s'" | ||
margs = (layer, key) | ||
if not do_not_warn: | ||
warn(self.logger, yellow(msg) % margs) | ||
|
||
DiscoveryMapping.discoveryMappings[self.oid] = self | ||
self.zenpack.registerDiscoveryMapping(self) |
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
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
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
############################################################################## | ||
# | ||
# 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. | ||
# | ||
############################################################################## | ||
--> | ||
|
||
<configure xmlns="http://namespaces.zope.org/zope"> | ||
|
||
<!-- Import discovery mapping directives. --> | ||
<include package="ZenPacks.zenoss.DiscoveryMapping" file="meta.zcml"/> | ||
|
||
#for $discoveryMapping in $zenpack.discoveryMappings.values | ||
<discoveryMapping | ||
oid="$discoveryMapping.oid" | ||
deviceClass="$discoveryMapping.deviceClass" | ||
/> | ||
|
||
#end for | ||
</configure> | ||
|
||
|
||
|
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
Oops, something went wrong.