Skip to content

Commit

Permalink
Merge branch 'support/6.x' into feature/deprecate_use_of_long
Browse files Browse the repository at this point in the history
  • Loading branch information
jpeacock-zenoss authored Jun 4, 2024
2 parents 280fa64 + 8c6b797 commit 434acec
Show file tree
Hide file tree
Showing 344 changed files with 20,894 additions and 10,079 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
12 changes: 7 additions & 5 deletions Products/DataCollector/SnmpClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(
datacollector=None,
plugins=[],
):
BaseClient.__init__(self, device, datacollector)
super(SnmpClient, self).__init__(device, datacollector)
global defaultTries, defaultTimeout
self.hostname = hostname
self.device = device
Expand Down Expand Up @@ -266,7 +266,8 @@ 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"
Expand All @@ -286,13 +287,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
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
17 changes: 16 additions & 1 deletion Products/DataCollector/zendisc.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,13 @@ def discoverIps(self, nets):
)
continue
self.log.info("Discover network '%s'", net.getNetworkName())
results = yield self.pingMany(net.fullIpList())

full_ip_list = net.fullIpList()
if self.options.removeInterfaceIps:
full_ip_list = yield self.config().callRemote(
"removeInterfaces", net)

results = yield self.pingMany(full_ip_list)
goodips, badips = _partitionPingResults(results)
self.log.debug(
"Found %d good IPs and %d bad IPs", len(goodips), len(badips)
Expand Down Expand Up @@ -872,6 +878,15 @@ def buildOptions(self):
default=False,
help="Prefer SNMP name to DNS name when modeling via SNMP.",
)
self.parser.add_option(
"--remove-interface-ips",
dest="removeInterfaceIps",
action="store_true",
default=False,
help="Skip discovery on IPs already assigned to interfaces "
"(device components).",
)

# --job: a development-only option that jobs will use to communicate
# their existence to zendisc. Not for users, so help is suppressed.
self.parser.add_option("--job", dest="job", help=SUPPRESS_HELP)
Expand Down
Loading

0 comments on commit 434acec

Please sign in to comment.