Permalink
Browse files

Sets the Location via SNMP 0.1

git-svn-id: http://zenpacks.zenoss.org/svn/zenpacks@725 db08cffe-75b9-45d1-af1a-46ad9ef135f6
  • Loading branch information...
0 parents commit 2bd66c2bc85b32a928b249215fbfdcb0cab04b68 Matt Ray committed Jun 9, 2010
@@ -0,0 +1,16 @@
+All files in this directory and below are:
+
+Copyright (c) 2010 Zenoss, Inc. All rights reserved.
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 2 as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -0,0 +1 @@
+graft ZenPacks
@@ -0,0 +1 @@
+__import__('pkg_resources').declare_namespace(__name__)
@@ -0,0 +1,8 @@
+
+import Globals
+import os.path
+
+skinsDir = os.path.join(os.path.dirname(__file__), 'skins')
+from Products.CMFCore.DirectoryView import registerDirectory
+if os.path.isdir(skinsDir):
+ registerDirectory(skinsDir, globals())
@@ -0,0 +1,22 @@
+import re
+import sys
+from Products.DataCollector.plugins.CollectorPlugin import SnmpPlugin, GetMap, GetTableMap
+
+class LocationMap(SnmpPlugin):
+
+ maptype = "LocationMap"
+
+ snmpGetMap = GetMap({
+ '.1.3.6.1.2.1.1.6.0' : 'setLocation',
+ })
+
+ def process(self, device, results, log):
+ """Collect SNMP location information from this device"""
+ log.info('processing %s for device %s', self.name(), device.id)
+ getdata, tabledata = results
+ om = self.objectMap(getdata)
+ om.setLocation = '/%s' % (self.prepId(om.setLocation))
+
+ log.info('Location: %s', om.setLocation)
+ return om
+
@@ -0,0 +1,3 @@
+<?xml version="1.0"?>
+<objects>
+</objects>
@@ -0,0 +1 @@
+__import__('pkg_resources').declare_namespace(__name__)
@@ -0,0 +1,69 @@
+################################
+# These variables are overwritten by Zenoss when the ZenPack is exported
+# or saved. Do not modify them directly here.
+# NB: PACKAGES is deprecated
+NAME = 'ZenPacks.community.SNMPLocation'
+VERSION = '0.1'
+AUTHOR = 'Matt Ray'
+LICENSE = 'GPLv2'
+NAMESPACE_PACKAGES = ['ZenPacks', 'ZenPacks.community']
+PACKAGES = ['ZenPacks', 'ZenPacks.community', 'ZenPacks.community.SNMPLocation']
+INSTALL_REQUIRES = []
+COMPAT_ZENOSS_VERS = '>=2.5'
+PREV_ZENPACK_NAME = ''
+# STOP_REPLACEMENTS
+################################
+# Zenoss will not overwrite any changes you make below here.
+
+from setuptools import setup, find_packages
+
+setup(
+ # This ZenPack metadata should usually be edited with the Zenoss
+ # ZenPack edit page. Whenever the edit page is submitted it will
+ # overwrite the values below (the ones it knows about) with new values.
+ name = NAME,
+ version = VERSION,
+ author = AUTHOR,
+ license = LICENSE,
+
+ # This is the version spec which indicates what versions of Zenoss
+ # this ZenPack is compatible with
+ compatZenossVers = COMPAT_ZENOSS_VERS,
+
+ # previousZenPackName is a facility for telling Zenoss that the name
+ # of this ZenPack has changed. If no ZenPack with the current name is
+ # installed then a zenpack of this name if installed will be upgraded.
+ prevZenPackName = PREV_ZENPACK_NAME,
+
+ # Indicate to setuptools which namespace packages the zenpack
+ # participates in
+ namespace_packages = NAMESPACE_PACKAGES,
+
+ # Tell setuptools what packages this zenpack provides.
+ packages = find_packages(),
+
+ # Tell setuptools to figure out for itself which files to include
+ # in the binary egg when it is built.
+ include_package_data = True,
+
+ # The MANIFEST.in file is the recommended way of including additional files
+ # in your ZenPack. package_data is another.
+ #package_data = {}
+
+ # Indicate dependencies on other python modules or ZenPacks. This line
+ # is modified by zenoss when the ZenPack edit page is submitted. Zenoss
+ # tries to put add/delete the names it manages at the beginning of this
+ # list, so any manual additions should be added to the end. Things will
+ # go poorly if this line is broken into multiple lines or modified to
+ # dramatically.
+ install_requires = INSTALL_REQUIRES,
+
+ # Every ZenPack egg must define exactly one zenoss.zenpacks entry point
+ # of this form.
+ entry_points = {
+ 'zenoss.zenpacks': '%s = %s' % (NAME, NAME),
+ },
+
+ # All ZenPack eggs must be installed in unzipped form.
+ zip_safe = False,
+)

0 comments on commit 2bd66c2

Please sign in to comment.