Skip to content

Commit

Permalink
Merge pull request #4628 from zenoss/release/6.8.0
Browse files Browse the repository at this point in the history
ZEN-34845: Release 6.8.0
  • Loading branch information
Deer-WarLord authored Dec 12, 2024
2 parents 702af9c + 427bfa0 commit e15846d
Show file tree
Hide file tree
Showing 544 changed files with 40,287 additions and 22,258 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Products/ZenUI3/node_modules
dist
build
Zenoss.egg-info
install-zenoss.mk
lib/python2.7/site-packages/Zenoss-nspkg.pth
lib/python2.7/site-packages/Zenoss.egg-link

Expand Down
3 changes: 1 addition & 2 deletions Products/DataCollector/ApplyDataMap/datamaputils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import logging
import sys

from six import string_types
from zope.event import notify

from Products.DataCollector.plugins.DataMaps import MultiArgs
Expand Down Expand Up @@ -155,7 +154,7 @@ def _get_attr_value(obj, attr):


def _sanitize_value(value, obj):
if isinstance(value, string_types):
if isinstance(value, basestring):
try:
return _decode_value(value, obj)
except UnicodeDecodeError:
Expand Down
2 changes: 1 addition & 1 deletion Products/DataCollector/ApplyDataMap/incrementalupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def _add(self):
for objId, obj in self.relationship.objectItemsAll()
if objId == self._target_id
),
_NOTSET
_NOTSET,
)
if self._target is _NOTSET:
changed = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@

from ..applydatamap import ApplyDataMap, ObjectMap

PATH = {'src': 'Products.DataCollector.ApplyDataMap.applydatamap'}
PATH = {"src": "Products.DataCollector.ApplyDataMap.applydatamap"}


class TestImplicitAdd(BaseTestCase):
"""Test ApplyDataMap directives.
"""
"""Test ApplyDataMap directives."""

def afterSetUp(t):
super(TestImplicitAdd, t).afterSetUp()
Expand Down Expand Up @@ -52,7 +51,6 @@ def test_implicit_update_twice_with_same_data(t):


class TestExplicitAdd(BaseTestCase):

def afterSetUp(t):
super(TestExplicitAdd, t).afterSetUp()
t.om1 = ObjectMap(
Expand Down Expand Up @@ -125,8 +123,7 @@ def test_explicit_add_false_with_existing_device_with_changes(t):


class TestAddSequence(BaseTestCase):
"""Test ApplyDataMap directives.
"""
"""Test ApplyDataMap directives."""

def afterSetUp(t):
super(TestAddSequence, t).afterSetUp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
##############################################################################

from base64 import b64encode

from mock import Mock, sentinel, patch

from Products.DataCollector.plugins.DataMaps import ObjectMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ def setup_mock_environment(t):
t.relationship = Mock(
name="relationship",
spec_set=[
t.target.id, "_getOb", "hasobject", "_setObject", "objectItemsAll"
t.target.id,
"_getOb",
"hasobject",
"_setObject",
"objectItemsAll",
],
)
setattr(t.relationship, t.target.id, t.target)
Expand Down
1 change: 0 additions & 1 deletion Products/DataCollector/ApplyDataMap/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


class BaseTestCase(TestCase):

def setUp(t):
logging.disable(logging.CRITICAL)

Expand Down
4 changes: 1 addition & 3 deletions Products/DataCollector/Plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,7 @@ def getPluginLoaders(self, packs):
if modname not in self.loadedZenpacks:
self.loadedZenpacks.append(modname)
modPathPrefix = ".".join(
(modname,)
+ self.packPath
+ (self.lastModName,)
(modname,) + self.packPath + (self.lastModName,)
)
factory = PackLoaderFactory(OsWalker(), modPathPrefix)
package = pack.path(*self.packPath + (self.lastModName,))
Expand Down
50 changes: 29 additions & 21 deletions Products/DataCollector/SnmpClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
from twisted.internet import reactor, error, defer
from twisted.python import failure
from twisted.internet.error import TimeoutError
from pynetsnmp.twistedsnmp import snmpprotocol, Snmpv3Error
from pynetsnmp.twistedsnmp import snmpprotocol, SnmpUsmError

from Products.ZenCollector.interfaces import IEventService
from Products.ZenEvents import Event
from Products.ZenEvents.ZenEventClasses import Status_Snmp
from Products.ZenHub.interfaces import IEventService
from Products.ZenUtils.Driver import drive
from Products.ZenUtils.snmp import (
SnmpAgentDiscoverer,
Expand Down Expand Up @@ -48,15 +48,15 @@ def __init__(
options=None,
device=None,
datacollector=None,
plugins=[],
plugins=None,
):
BaseClient.__init__(self, device, datacollector)
super(SnmpClient, self).__init__(device, datacollector)
global defaultTries, defaultTimeout
self.hostname = hostname
self.device = device
self.options = options
self.datacollector = datacollector
self.plugins = plugins
self.plugins = plugins if plugins else []

self._getdata = {}
self._tabledata = {}
Expand All @@ -71,12 +71,16 @@ def initSnmpProxy(self):
if self.proxy is not None:
self.proxy.close()
srcport = snmpprotocol.port()
self.proxy = self.connInfo.createSession(srcport.protocol)
self.proxy.open()
try:
self.proxy = self.connInfo.createSession(srcport.protocol)
self.proxy.open()
except Exception as ex:
log.error("failed to initialize SNMP session error=%s", ex)
self.proxy = None

def run(self):
"""Start snmp collection."""
log.debug("Starting %s", self.connInfo.summary())
log.debug("starting %s", self.connInfo.summary())
self.initSnmpProxy()
drive(self.doRun).addBoth(self.clientFinished)

Expand All @@ -98,18 +102,20 @@ def checkCiscoChange(self, driver):
result = False
else:
device.setLastPollSnmpUpTime(lastchange)
except Exception:
pass
except Exception as ex:
log.debug("failed to check Cisco change: %s", ex)
yield defer.succeed(result)

def doRun(self, driver):
if self.proxy is None:
return
# test snmp connectivity
log.debug("Testing SNMP configuration")
yield self.proxy.walk(".1.3")
try:
driver.next()
except TimeoutError:
log.info("Device timed out: %s", self.connInfo.summary())
log.info("device timed out %s", self.connInfo.summary())
if self.options.discoverCommunity:
yield self.findSnmpCommunity()
snmp_config = driver.next()
Expand All @@ -129,13 +135,14 @@ def doRun(self, driver):
self.initSnmpProxy()
else:
raise
except Snmpv3Error:
except SnmpUsmError as ex:
log.error(
"Cannot connect to SNMP agent: %s", self.connInfo.summary()
"cannot connect to SNMP agent error=%s %s",
ex, self.connInfo.summary()
)
raise
except Exception:
log.exception("Unable to talk: %s", self.connInfo.summary())
log.exception("unable to talk %s", self.connInfo.summary())
raise

changed = True
Expand Down Expand Up @@ -266,16 +273,16 @@ def clientFinished(self, result):

if isinstance(result.value, error.TimeoutError):
log.error(
"Device %s timed out: are " "your SNMP settings correct?",
"device %s timed out: are your SNMP settings correct?",
self.hostname,
)
summary = "SNMP agent down - no response received"
log.info("Sending event: %s", summary)
elif isinstance(result.value, Snmpv3Error):
elif isinstance(result.value, SnmpUsmError):
log.error(
"Connection to device %s failed: %s",
"SNMP connection failed device=%s error=%s",
self.hostname,
result.value.message,
result.value,
)
summary = "SNMP v3 specific error during SNMP collection"
else:
Expand All @@ -286,13 +293,14 @@ def clientFinished(self, result):
self._sendStatusEvent(summary, eventKey="agent_down")
else:
self._sendStatusEvent(
"SNMP agent up", eventKey="agent_down", severity=Event.Clear
"SNMP agent up",
eventKey="agent_down",
severity=Event.Clear,
)
try:
self.proxy.close()
except AttributeError:
log.info("Caught AttributeError closing SNMP connection.")
"""tell the datacollector that we are all done"""
log.info("caught AttributeError closing SNMP connection.")
if self.datacollector:
self.datacollector.clientFinished(self)
else:
Expand Down
2 changes: 1 addition & 1 deletion Products/DataCollector/SshClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@

from Products.DataCollector import CollectorClient
from Products.DataCollector.Exceptions import LoginFailed
from Products.ZenCollector.interfaces import IEventService
from Products.ZenEvents import Event
from Products.ZenHub.interfaces import IEventService
from Products.ZenUtils.IpUtil import getHostByName
from Products.ZenUtils.Utils import getExitMessage

Expand Down
4 changes: 2 additions & 2 deletions Products/DataCollector/plugins/CollectorPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ def copyDataToProxy(self, device, proxy):

def asdate(self, val):
"""Convert a byte string to the date string 'YYYY/MM/DD HH:MM:SS'"""
datear = (1968, 1, 8, 10, 15, 00)
datear = (1968, 1, 8, 10, 15, 0)
try:
datear = struct.unpack("!h5B", val[0:7])
except Exception:
pass
if datear[0] == 0:
datear = (1968, 1, 8, 10, 15, 00)
datear = (1968, 1, 8, 10, 15, 0)
return "%d/%02d/%02d %02d:%02d:%02d" % datear[:6]


Expand Down
2 changes: 2 additions & 0 deletions Products/DataCollector/plugins/zenoss/snmp/RouteMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,6 @@ def mapSnmpVal(self, value, map):
"bbnSpfIgrp",
"ospf",
"bgp",
"idpr",
"ciscoEigrp",
)
Loading

0 comments on commit e15846d

Please sign in to comment.