From d959a8063d2034a42de604614d64c9a613d2dfac Mon Sep 17 00:00:00 2001 From: Johanna England Date: Mon, 19 Aug 2024 16:13:41 +0200 Subject: [PATCH] Use return instead of twisted.defer.returnValue returnValue has been deprecated in twisted 24.7.0 --- changelog.d/2955.changed.md | 1 + .../adding-environment-probe-support.rst | 8 +++--- python/nav/bin/naventity.py | 4 +-- python/nav/bin/navoidverify.py | 6 ++--- python/nav/ipdevpoll/jobs.py | 10 +++---- python/nav/ipdevpoll/plugins/arp.py | 6 ++--- python/nav/ipdevpoll/plugins/bgp.py | 6 ++--- python/nav/ipdevpoll/plugins/bridge.py | 2 +- python/nav/ipdevpoll/plugins/cam.py | 14 +++++----- python/nav/ipdevpoll/plugins/cdp.py | 6 ++--- python/nav/ipdevpoll/plugins/ciscovlan.py | 2 +- python/nav/ipdevpoll/plugins/dot1q.py | 4 +-- python/nav/ipdevpoll/plugins/entity.py | 2 +- python/nav/ipdevpoll/plugins/extremevlan.py | 4 +-- python/nav/ipdevpoll/plugins/interfaces.py | 2 +- python/nav/ipdevpoll/plugins/juniperdot1q.py | 8 +++--- python/nav/ipdevpoll/plugins/linkaggregate.py | 6 ++--- python/nav/ipdevpoll/plugins/linkstate.py | 4 +-- python/nav/ipdevpoll/plugins/lldp.py | 6 ++--- python/nav/ipdevpoll/plugins/modules.py | 2 +- python/nav/ipdevpoll/plugins/paloaltoarp.py | 13 +++++----- python/nav/ipdevpoll/plugins/poe.py | 6 ++--- python/nav/ipdevpoll/plugins/prefix.py | 4 +-- python/nav/ipdevpoll/plugins/psuwatch.py | 6 ++--- python/nav/ipdevpoll/plugins/sensors.py | 2 +- python/nav/ipdevpoll/plugins/snmpcheck.py | 5 ++-- python/nav/ipdevpoll/plugins/statports.py | 4 +-- python/nav/ipdevpoll/plugins/statsensors.py | 6 ++--- python/nav/ipdevpoll/plugins/statsystem.py | 26 +++++++++---------- python/nav/ipdevpoll/plugins/typeoid.py | 4 +-- python/nav/ipdevpoll/plugins/uptime.py | 4 +-- python/nav/ipdevpoll/pool.py | 6 ++--- python/nav/ipdevpoll/timestamps.py | 4 +-- python/nav/ipdevpoll/utils.py | 8 +++--- python/nav/mibs/alcatel_ind1_port_mib.py | 5 ++-- python/nav/mibs/arista_vrf_mib.py | 4 +-- python/nav/mibs/bgp4_mib.py | 5 ++-- python/nav/mibs/bridge_mib.py | 8 +++--- python/nav/mibs/cd6c_mib.py | 4 +-- python/nav/mibs/cisco_cdp_mib.py | 4 +-- .../mibs/cisco_enhanced_memory_pool_mib.py | 2 +- .../nav/mibs/cisco_entity_fru_control_mib.py | 10 +++---- python/nav/mibs/cisco_envmon_mib.py | 2 +- python/nav/mibs/cisco_hsrp_mib.py | 2 +- python/nav/mibs/cisco_ietf_ip_mib.py | 4 +-- python/nav/mibs/cisco_memory_pool_mib.py | 2 +- python/nav/mibs/cisco_process_mib.py | 6 ++--- .../cisco_vlan_iftable_relationship_mib.py | 2 +- python/nav/mibs/cisco_vlan_membership_mib.py | 2 +- python/nav/mibs/cisco_vtp_mib.py | 15 ++++------- python/nav/mibs/comet.py | 11 ++++---- python/nav/mibs/coriant_groove_mib.py | 5 ++-- python/nav/mibs/cpqpower_mib.py | 6 ++--- python/nav/mibs/eltek_distributed_mib.py | 6 ++--- python/nav/mibs/entity_mib.py | 10 +++---- python/nav/mibs/entity_sensor_mib.py | 2 +- python/nav/mibs/esswitch_mib.py | 2 +- python/nav/mibs/etherlike_mib.py | 2 +- python/nav/mibs/hp_httpmanageable_mib.py | 2 +- python/nav/mibs/hpicf_fan_mib.py | 6 ++--- python/nav/mibs/hpicf_powersupply_mib.py | 6 ++--- python/nav/mibs/ibm_pdu_mib.py | 8 +++--- python/nav/mibs/ieee8023_lag_mib.py | 16 ++++++------ python/nav/mibs/if_mib.py | 12 ++++----- python/nav/mibs/ip_forward_mib.py | 8 +++--- python/nav/mibs/ip_mib.py | 16 ++++++------ python/nav/mibs/ipv6_mib.py | 4 +-- python/nav/mibs/itw_mib.py | 2 +- python/nav/mibs/itw_mibv3.py | 2 +- python/nav/mibs/juniper_alarm_mib.py | 2 +- python/nav/mibs/juniper_dom_mib.py | 5 ++-- python/nav/mibs/juniper_mib.py | 16 ++++++------ python/nav/mibs/lldp_mib.py | 12 ++++----- python/nav/mibs/mibretriever.py | 7 +++-- python/nav/mibs/netswitch_mib.py | 2 +- python/nav/mibs/old_cisco_cpu_mib.py | 2 +- python/nav/mibs/pdu2_mib.py | 9 +++---- python/nav/mibs/power_ethernet_mib.py | 4 +-- python/nav/mibs/powernet_mib.py | 6 ++--- python/nav/mibs/pwt_3phase_mibv1.py | 2 +- python/nav/mibs/qbridge_mib.py | 4 +-- python/nav/mibs/rittal_cmc_iii.py | 7 +++-- python/nav/mibs/snmpv2_mib.py | 6 ++--- python/nav/mibs/spagent_mib.py | 4 +-- python/nav/mibs/statistics_mib.py | 4 +-- python/nav/mibs/ups_mib.py | 2 +- python/nav/mibs/vrrp_mib.py | 2 +- python/nav/mibs/wlsx_systemext_mib.py | 2 +- 88 files changed, 244 insertions(+), 258 deletions(-) create mode 100644 changelog.d/2955.changed.md diff --git a/changelog.d/2955.changed.md b/changelog.d/2955.changed.md new file mode 100644 index 0000000000..2e12ba3559 --- /dev/null +++ b/changelog.d/2955.changed.md @@ -0,0 +1 @@ +Replace twisted.internet.defer.returnValue with return due to deprecation in newest twisted version diff --git a/doc/hacking/adding-environment-probe-support.rst b/doc/hacking/adding-environment-probe-support.rst index 0f7edc50d2..9384c88394 100644 --- a/doc/hacking/adding-environment-probe-support.rst +++ b/doc/hacking/adding-environment-probe-support.rst @@ -219,7 +219,7 @@ Let's hardcode an example result for a single temperature sensor, based on the 'mib': 'SPAGENT-MIB', } ] - defer.returnValue(result) + return result This returns a list of a single item: A dictionary describing the first temperature sensor from the snmpwalk from above. The dictionary should contain @@ -284,8 +284,8 @@ Let's rewrite ``SPAgentMib`` to collect actual temperature sensors: :emphasize-lines: 9, 20 from nav.models.manage import Sensor - - + + class SPAgentMib(MibRetriever): mib = get_mib('SPAGENT-MIB') @@ -300,7 +300,7 @@ Let's rewrite ``SPAgentMib`` to collect actual temperature sensors: sensors = (self._temp_row_to_sensor(index, row) for index, row in result.iteritems()) - defer.returnValue([s for s in sensors if s]) + return [s for s in sensors if s] def _temp_row_to_sensor(self, index, row): online = row.get('sensorProbeTempOnline', 'offline') diff --git a/python/nav/bin/naventity.py b/python/nav/bin/naventity.py index a5cb2c08e9..52782777df 100755 --- a/python/nav/bin/naventity.py +++ b/python/nav/bin/naventity.py @@ -71,11 +71,11 @@ def collect_entities(netbox, portnumber): """Collects the entPhysicalTable""" agent = _create_agentproxy(netbox, portnumber) if not agent: - defer.returnValue(None) + return None mib = EntityMib(agent) result = yield mib.get_entity_physical_table() - defer.returnValue(result) + return result def make_graph(entities, netbox): diff --git a/python/nav/bin/navoidverify.py b/python/nav/bin/navoidverify.py index 3268c11a11..0d71db776e 100755 --- a/python/nav/bin/navoidverify.py +++ b/python/nav/bin/navoidverify.py @@ -73,7 +73,7 @@ def verify(netbox, oid): """Verifies a GETNEXT response from below the oid subtree""" agent = _create_agentproxy(netbox) if not agent: - defer.returnValue(False) + return False result = yield agent.walk(str(oid)) agent.close() @@ -83,8 +83,8 @@ def verify(netbox, oid): for key, _value in result: if oid.is_a_prefix_of(key): print(netbox.sysname) - defer.returnValue(True) - defer.returnValue(False) + return True + return False def endit(_result): diff --git a/python/nav/ipdevpoll/jobs.py b/python/nav/ipdevpoll/jobs.py index be73be8be5..73a96e2928 100644 --- a/python/nav/ipdevpoll/jobs.py +++ b/python/nav/ipdevpoll/jobs.py @@ -153,9 +153,9 @@ def _find_plugins(self): ] if not plugins: - defer.returnValue(None) + return None - defer.returnValue(plugins) + return plugins def _get_valid_plugins(self): valid_plugins, invalid_plugins = splitby( @@ -201,7 +201,7 @@ def _get_willing_plugins(self, plugin_classes): else: self._logger.debug("no %s plugins", willingness) - defer.returnValue(willing_plugins) + return willing_plugins def _iterate_plugins(self, plugins): """Iterates plugins.""" @@ -278,7 +278,7 @@ def run(self): self._reset_timers() if not plugins: self._destroy_agentproxy() - defer.returnValue(False) + return False self._logger.debug("Starting job %r for %s", self.name, self.netbox.sysname) @@ -353,7 +353,7 @@ def log_externally_failure(result): df.addBoth(cleanup) df.addCallbacks(log_externally_success, log_externally_failure) yield df - defer.returnValue(True) + return True def cancel(self): """Cancels a running job. diff --git a/python/nav/ipdevpoll/plugins/arp.py b/python/nav/ipdevpoll/plugins/arp.py index 37baab8249..a50da4db24 100644 --- a/python/nav/ipdevpoll/plugins/arp.py +++ b/python/nav/ipdevpoll/plugins/arp.py @@ -102,10 +102,10 @@ def handle(self): @defer.inlineCallbacks def _get_ip_mib(self): if not self.is_arista(): - defer.returnValue(IpMib(self.agent)) # regular IpMib for regular folks + return IpMib(self.agent) # regular IpMib for regular folks else: instances = yield get_arista_vrf_instances(self.agent) - defer.returnValue(MultiIpMib(self.agent, instances=instances)) + return MultiIpMib(self.agent, instances=instances) def is_arista(self): """Returns True if this is an Arista device""" @@ -171,7 +171,7 @@ def _load_existing_mappings(self): open_mappings = dict( ((IP(arp['ip']), arp['mac']), arp['id']) for arp in open_arp_records ) - defer.returnValue(open_mappings) + return open_mappings @classmethod def _update_prefix_cache(cls): diff --git a/python/nav/ipdevpoll/plugins/bgp.py b/python/nav/ipdevpoll/plugins/bgp.py index a1cfeef758..3f84374ce6 100644 --- a/python/nav/ipdevpoll/plugins/bgp.py +++ b/python/nav/ipdevpoll/plugins/bgp.py @@ -14,7 +14,7 @@ # along with NAV. If not, see . # """BGP peer state monitor plugin for ipdevpoll""" -from twisted.internet.defer import inlineCallbacks, returnValue +from twisted.internet.defer import inlineCallbacks from nav.ipdevpoll import Plugin from nav.ipdevpoll.shadows import GatewayPeerSession, Netbox @@ -40,7 +40,7 @@ def handle(self): if not mib: self._logger.debug("No BGP MIBs are supported") - returnValue(None) + return None self._logger.debug("Collect BGP peers from %s", mib.mib['moduleName']) data = yield mib.get_bgp_peer_states() @@ -73,4 +73,4 @@ def _get_supported_mib(self): mib = mibclass(self.agent) support = yield mib.is_supported() if support: - returnValue(mib) + return mib diff --git a/python/nav/ipdevpoll/plugins/bridge.py b/python/nav/ipdevpoll/plugins/bridge.py index 7335d40750..7288763163 100644 --- a/python/nav/ipdevpoll/plugins/bridge.py +++ b/python/nav/ipdevpoll/plugins/bridge.py @@ -41,7 +41,7 @@ def handle(self): if bridge_address: self._save_bridge_address(bridge_address) baseports = yield bridge.get_baseport_ifindex_map() - defer.returnValue(self._set_port_numbers(baseports)) + return self._set_port_numbers(baseports) def _save_bridge_address(self, bridge_address): info = self.containers.factory( diff --git a/python/nav/ipdevpoll/plugins/cam.py b/python/nav/ipdevpoll/plugins/cam.py index b04ce1866b..f46c42b2cb 100644 --- a/python/nav/ipdevpoll/plugins/cam.py +++ b/python/nav/ipdevpoll/plugins/cam.py @@ -57,7 +57,7 @@ class Cam(Plugin): def can_handle(cls, netbox): daddy_says_ok = super(Cam, cls).can_handle(netbox) has_ifcs = yield db.run_in_thread(cls._has_interfaces, netbox) - defer.returnValue(has_ifcs and daddy_says_ok) + return has_ifcs and daddy_says_ok @classmethod def _has_interfaces(cls, netbox): @@ -102,7 +102,7 @@ def _get_dot1d_mac_port_mapping(self): ifindex = baseports[port] mapping[ifindex].add(mac) - defer.returnValue(dict(mapping)) + return dict(mapping) @defer.inlineCallbacks def _get_dot1q_mac_port_mapping(self): @@ -116,27 +116,27 @@ def _get_dot1q_mac_port_mapping(self): ifindex = baseports[port] mapping[ifindex].add(mac) - defer.returnValue(dict(mapping)) + return dict(mapping) @defer.inlineCallbacks def _get_baseports(self): if not self.baseports: bridge = yield self._get_bridge() self.baseports = yield bridge.get_baseport_ifindex_map() - defer.returnValue(self.baseports) + return self.baseports @defer.inlineCallbacks def _get_bridge(self): if not self.bridge: instances = yield self._get_dot1d_instances() self.bridge = MultiBridgeMib(self.agent, instances) - defer.returnValue(self.bridge) + return self.bridge @defer.inlineCallbacks def _get_dot1d_instances(self): if not self.dot1d_instances: self.dot1d_instances = yield utils.get_dot1d_instances(self.agent) - defer.returnValue(self.dot1d_instances) + return self.dot1d_instances def _log_fdb_stats(self, prefix, fdb): mac_count = sum(len(v) for v in fdb.values()) @@ -230,7 +230,7 @@ def _get_dot1d_stp_blocking(self): if translated: self._log_blocking_ports(translated) self._store_blocking_ports(translated) - defer.returnValue(translated) + return translated def _log_blocking_ports(self, blocking): ifc_count = len(set(ifc for ifc, vlan in blocking)) diff --git a/python/nav/ipdevpoll/plugins/cdp.py b/python/nav/ipdevpoll/plugins/cdp.py index 5093018d83..dc4a0861c3 100644 --- a/python/nav/ipdevpoll/plugins/cdp.py +++ b/python/nav/ipdevpoll/plugins/cdp.py @@ -50,7 +50,7 @@ class CDP(Plugin): def can_handle(cls, netbox): daddy_says_ok = super(CDP, cls).can_handle(netbox) has_ifcs = yield run_in_thread(cls._has_interfaces, netbox) - defer.returnValue(has_ifcs and daddy_says_ok) + return has_ifcs and daddy_says_ok @classmethod def _has_interfaces(cls, netbox): @@ -97,7 +97,7 @@ def _get_stampcheck(self, mib): yield stampcheck.load() yield stampcheck.collect([mib.get_neighbors_last_change()]) - defer.returnValue(stampcheck) + return stampcheck @defer.inlineCallbacks def _get_cached_neighbors(self): @@ -108,7 +108,7 @@ def _get_cached_neighbors(self): INFO_KEY_NAME, INFO_VAR_NEIGHBORS_CACHE, ) - defer.returnValue(value) + return value @defer.inlineCallbacks def _save_cached_neighbors(self, neighbors): diff --git a/python/nav/ipdevpoll/plugins/ciscovlan.py b/python/nav/ipdevpoll/plugins/ciscovlan.py index a5a3517c48..456a1fd41f 100644 --- a/python/nav/ipdevpoll/plugins/ciscovlan.py +++ b/python/nav/ipdevpoll/plugins/ciscovlan.py @@ -72,7 +72,7 @@ def handle(self): def _get_ifindexes(self): ifmib = IfMib(self.agent) indexes = yield ifmib.get_ifindexes() - defer.returnValue(set(indexes)) + return set(indexes) def _store_access_ports(self, vlan_membership): """Store vlan memberships for all ports.""" diff --git a/python/nav/ipdevpoll/plugins/dot1q.py b/python/nav/ipdevpoll/plugins/dot1q.py index fe07d2e703..fa5262eb3d 100644 --- a/python/nav/ipdevpoll/plugins/dot1q.py +++ b/python/nav/ipdevpoll/plugins/dot1q.py @@ -27,7 +27,7 @@ from collections import defaultdict -from twisted.internet.defer import inlineCallbacks, returnValue +from twisted.internet.defer import inlineCallbacks from nav.util import mergedicts from nav.mibs.bridge_mib import BridgeMib @@ -122,7 +122,7 @@ def _retrieve_vlan_ports(self): egress = yield query.get_vlan_static_egress_ports() untagged = yield query.get_vlan_static_untagged_ports() - returnValue((egress, untagged)) + return (egress, untagged) def _find_trunkports(self, egress, untagged): trunkports = defaultdict(list) diff --git a/python/nav/ipdevpoll/plugins/entity.py b/python/nav/ipdevpoll/plugins/entity.py index 46ba3c7592..a3e16d6f3e 100644 --- a/python/nav/ipdevpoll/plugins/entity.py +++ b/python/nav/ipdevpoll/plugins/entity.py @@ -65,7 +65,7 @@ def _need_to_collect(self): yield self.stampcheck.collect([self.entitymib.get_last_change_time()]) result = yield self.stampcheck.is_changed() - defer.returnValue(result) + return result def _process_entities(self, result): """Process the list of collected entities.""" diff --git a/python/nav/ipdevpoll/plugins/extremevlan.py b/python/nav/ipdevpoll/plugins/extremevlan.py index f3e18bc547..9e482df296 100644 --- a/python/nav/ipdevpoll/plugins/extremevlan.py +++ b/python/nav/ipdevpoll/plugins/extremevlan.py @@ -19,7 +19,7 @@ """ -from twisted.internet.defer import inlineCallbacks, returnValue +from twisted.internet.defer import inlineCallbacks from nav.enterprise.ids import VENDOR_ID_EXTREME_NETWORKS from nav.mibs.extreme_vlan_mib import ExtremeVlanMib @@ -60,7 +60,7 @@ def _get_vlan_data(self): vlan_ports = yield self.extremevlan.get_vlan_ports() if not vlan_ports: # Doesn't appear to have VLAN data in EXTREME MIBs, get out now. - returnValue(None) + return None ifindex_vlan = yield self.extremevlan.get_ifindex_vlan_map() self.baseport_ifindex = yield self.bridge.get_baseport_ifindex_map() diff --git a/python/nav/ipdevpoll/plugins/interfaces.py b/python/nav/ipdevpoll/plugins/interfaces.py index 3be4bb53fc..6e232bf45b 100644 --- a/python/nav/ipdevpoll/plugins/interfaces.py +++ b/python/nav/ipdevpoll/plugins/interfaces.py @@ -165,7 +165,7 @@ def _stackify(stackstatus): stack = yield self.ifmib.get_stack_status().addCallback(_stackify) self._get_ifalias_from_lower_layers(stack) self._create_stack_containers(stack) - defer.returnValue(interfaces) + return interfaces def _get_ifalias_from_lower_layers(self, stack): """For each interface without an ifAlias value, attempts to find diff --git a/python/nav/ipdevpoll/plugins/juniperdot1q.py b/python/nav/ipdevpoll/plugins/juniperdot1q.py index 741652c8a3..9a75a9e7dc 100644 --- a/python/nav/ipdevpoll/plugins/juniperdot1q.py +++ b/python/nav/ipdevpoll/plugins/juniperdot1q.py @@ -37,7 +37,7 @@ """ -from twisted.internet.defer import inlineCallbacks, returnValue +from twisted.internet.defer import inlineCallbacks from nav.enterprise.ids import VENDOR_ID_JUNIPER_NETWORKS_INC from nav.oids import OID from . import dot1q @@ -84,12 +84,12 @@ def _retrieve_vlan_ports(self): """ (egress, untagged) = yield super(JuniperDot1q, self)._retrieve_vlan_ports() if not self.jnx_vlan_map: - returnValue((egress, untagged)) + return (egress, untagged) new_egress = {self._remap_vlan(key): value for key, value in egress.items()} new_untagged = {self._remap_vlan(key): value for key, value in untagged.items()} - returnValue((new_egress, new_untagged)) + return (new_egress, new_untagged) def __is_a_moronic_juniper_device(self): if self.netbox.type: @@ -103,4 +103,4 @@ def __get_jnx_ex_vlan_tag(self): mappings = result.get(_jnxExVlanTag, {}) mappings = {OID(key)[-1]: value for key, value in mappings.items()} self._logger.debug("got jnxExVlanTag map: %r", mappings) - returnValue(mappings) + return mappings diff --git a/python/nav/ipdevpoll/plugins/linkaggregate.py b/python/nav/ipdevpoll/plugins/linkaggregate.py index 7c94daaa8a..963cbbdba4 100644 --- a/python/nav/ipdevpoll/plugins/linkaggregate.py +++ b/python/nav/ipdevpoll/plugins/linkaggregate.py @@ -15,7 +15,7 @@ # import logging from collections import defaultdict -from twisted.internet.defer import inlineCallbacks, returnValue +from twisted.internet.defer import inlineCallbacks from nav.ipdevpoll import Plugin from nav.ipdevpoll import shadows @@ -47,7 +47,7 @@ def _convert_to_interfaces(self, aggregatedict): for if_idx in aggregates: interface = yield self._get_interface(if_idx) result.append((interface, aggregator)) - returnValue(result) + return result @inlineCallbacks def _get_interface(self, ifindex): @@ -56,7 +56,7 @@ def _get_interface(self, ifindex): # In case no other plugins ran before us to collect this: self._logger.debug("retrieving ifName.%s", ifindex) ifc.ifname = yield self.ifmib.retrieve_column_by_index('ifName', (ifindex,)) - returnValue(ifc) + return ifc def _log_aggregates(self, aggregates): if not self._logger.isEnabledFor(logging.DEBUG): diff --git a/python/nav/ipdevpoll/plugins/linkstate.py b/python/nav/ipdevpoll/plugins/linkstate.py index f5a6b33667..738461b7ba 100644 --- a/python/nav/ipdevpoll/plugins/linkstate.py +++ b/python/nav/ipdevpoll/plugins/linkstate.py @@ -14,7 +14,7 @@ # License along with NAV. If not, see . # """Collects interface link states and dispatches NAV events on changes""" -from twisted.internet.defer import inlineCallbacks, returnValue +from twisted.internet.defer import inlineCallbacks from nav.mibs import reduce_index from nav.mibs.if_mib import IfMib @@ -32,7 +32,7 @@ def handle(self): self._logger.debug( "this is a virtual instance of %s, not polling", self.netbox.master ) - returnValue(None) + return None ifmib = IfMib(self.agent) result = yield ifmib.retrieve_columns( diff --git a/python/nav/ipdevpoll/plugins/lldp.py b/python/nav/ipdevpoll/plugins/lldp.py index dd8bc06e37..ccbd084441 100644 --- a/python/nav/ipdevpoll/plugins/lldp.py +++ b/python/nav/ipdevpoll/plugins/lldp.py @@ -53,7 +53,7 @@ class LLDP(Plugin): def can_handle(cls, netbox): daddy_says_ok = super(LLDP, cls).can_handle(netbox) has_ifcs = yield run_in_thread(cls._has_interfaces, netbox) - defer.returnValue(has_ifcs and daddy_says_ok) + return has_ifcs and daddy_says_ok @classmethod def _has_interfaces(cls, netbox): @@ -102,7 +102,7 @@ def _get_cached_remote_table(self): INFO_KEY_LLDP_INFO, INFO_VAR_REMOTES_CACHE, ) - defer.returnValue(value) + return value @defer.inlineCallbacks def _save_cached_remote_table(self, remote_table): @@ -149,7 +149,7 @@ def _get_stampcheck(self, mib): yield stampcheck.load() yield stampcheck.collect([mib.get_remote_last_change()]) - defer.returnValue(stampcheck) + return stampcheck def _process_remote(self): """Tries to synchronously identify LLDP entries in NAV's database""" diff --git a/python/nav/ipdevpoll/plugins/modules.py b/python/nav/ipdevpoll/plugins/modules.py index 0b2a8fdf72..14b980a0ce 100644 --- a/python/nav/ipdevpoll/plugins/modules.py +++ b/python/nav/ipdevpoll/plugins/modules.py @@ -70,7 +70,7 @@ def _need_to_collect(self): yield self.stampcheck.collect([self.entitymib.get_last_change_time()]) result = yield self.stampcheck.is_changed() - defer.returnValue(result) + return result def _device_from_entity(self, ent): serial_column = 'entPhysicalSerialNum' diff --git a/python/nav/ipdevpoll/plugins/paloaltoarp.py b/python/nav/ipdevpoll/plugins/paloaltoarp.py index fc5ee484df..792353aae0 100644 --- a/python/nav/ipdevpoll/plugins/paloaltoarp.py +++ b/python/nav/ipdevpoll/plugins/paloaltoarp.py @@ -30,7 +30,6 @@ from IPy import IP from twisted.internet import defer, reactor, ssl -from twisted.internet.defer import returnValue from twisted.web import client from twisted.web.client import Agent from twisted.web.http_headers import Headers @@ -77,11 +76,11 @@ def handle(self): mappings = yield self._get_paloalto_arp_mappings(self.netbox.ip, api_key) if mappings is None: self._logger.info("No mappings found for Paloalto device") - returnValue(None) + return None yield self._process_data(mappings) - returnValue(None) + return None @defer.inlineCallbacks def _get_paloalto_arp_mappings(self, address: str, key: str): @@ -89,11 +88,11 @@ def _get_paloalto_arp_mappings(self, address: str, key: str): arptable = yield self._do_request(address, key) if arptable is None: - returnValue(None) + return None # process arpdata into an array of mappings mappings = parse_arp(arptable.decode('utf-8')) - returnValue(mappings) + return mappings @defer.inlineCallbacks def _do_request(self, address: str, key: str): @@ -122,10 +121,10 @@ def creatorForNetloc(self, hostname, port): "Error when talking to PaloAlto API. " "Make sure the device is reachable and the API key is correct." ) - returnValue(None) + return None response = yield client.readBody(response) - returnValue(response) + return response def parse_arp(arp): diff --git a/python/nav/ipdevpoll/plugins/poe.py b/python/nav/ipdevpoll/plugins/poe.py index a509651d02..468864c053 100644 --- a/python/nav/ipdevpoll/plugins/poe.py +++ b/python/nav/ipdevpoll/plugins/poe.py @@ -15,7 +15,7 @@ # """Collects power over ethernet information""" from collections import defaultdict -from twisted.internet.defer import inlineCallbacks, returnValue +from twisted.internet.defer import inlineCallbacks from nav.mibs.power_ethernet_mib import PowerEthernetMib from nav.mibs.cisco_power_ethernet_ext_mib import CiscoPowerEthernetExtMib @@ -41,7 +41,7 @@ def handle(self): self._logger.debug( "this is a virtual instance of %s, not polling", self.netbox.master ) - returnValue(None) + return None poemib = PowerEthernetMib(self.agent) if self._is_cisco(): @@ -90,7 +90,7 @@ def _map_cisco_power_ports_to_ifindex(self): entity_mib = EntityMib(self.agent) alias_mapping = yield entity_mib.get_alias_mapping() port_ifindices = self._resolve_ifindex(port_phy_index, alias_mapping) - returnValue((group_phy_index, port_ifindices)) + return (group_phy_index, port_ifindices) def _process_groups(self, groups, phy_indices): netbox = self.containers.factory(None, shadows.Netbox) diff --git a/python/nav/ipdevpoll/plugins/prefix.py b/python/nav/ipdevpoll/plugins/prefix.py index 2f8d88a629..0ea232ac43 100644 --- a/python/nav/ipdevpoll/plugins/prefix.py +++ b/python/nav/ipdevpoll/plugins/prefix.py @@ -134,7 +134,7 @@ def _get_adminup_ifcs(self): ifmib = IfMib(self.agent) statuses = yield ifmib.get_admin_status() result = set(ifindex for ifindex, status in statuses.items() if status == 'up') - defer.returnValue(result) + return result def create_containers( self, netbox, ifindex, net_prefix, ip, vlan_interfaces, ifc_aliases=None @@ -193,7 +193,7 @@ def get_vlan_interfaces(self): vlan = int(match.group('vlan')) vlan_ifs[ifindex] = vlan - defer.returnValue(vlan_ifs) + return vlan_ifs def _ignore_timeout(self, failure, result=None): """Ignores a TimeoutError in an errback chain. diff --git a/python/nav/ipdevpoll/plugins/psuwatch.py b/python/nav/ipdevpoll/plugins/psuwatch.py index e68d90db8e..d2fe7b767e 100644 --- a/python/nav/ipdevpoll/plugins/psuwatch.py +++ b/python/nav/ipdevpoll/plugins/psuwatch.py @@ -64,7 +64,7 @@ def handle(self): if old_state != new_state: yield self._handle_state_change(unit, new_state) - defer.returnValue(True) + return True @defer.inlineCallbacks def _retrieve_current_unit_state(self, unit): @@ -79,11 +79,11 @@ def _retrieve_current_unit_state(self, unit): method = getattr(mib, method_name, None) if method: state = yield method(unit.internal_id) - defer.returnValue(state or STATE_UNKNOWN) + return state or STATE_UNKNOWN else: self._logger.debug("unit has no internal id: %r", unit) - defer.returnValue(STATE_UNKNOWN) + return STATE_UNKNOWN @defer.inlineCallbacks def _handle_state_change(self, unit, new_state): diff --git a/python/nav/ipdevpoll/plugins/sensors.py b/python/nav/ipdevpoll/plugins/sensors.py index 7defdb939e..8a679ef341 100644 --- a/python/nav/ipdevpoll/plugins/sensors.py +++ b/python/nav/ipdevpoll/plugins/sensors.py @@ -96,7 +96,7 @@ def mibfactory(self): classes = self.mib_map.get(vendor_id, ()) or self.mib_map.get('*', ()) mibs = [cls(self.agent) for cls in classes] - defer.returnValue(mibs) + return mibs def _store_sensors(self, result): """Stores sensor records in the current job's container dictionary, so diff --git a/python/nav/ipdevpoll/plugins/snmpcheck.py b/python/nav/ipdevpoll/plugins/snmpcheck.py index a7bc9d31ae..dec55b5f4c 100644 --- a/python/nav/ipdevpoll/plugins/snmpcheck.py +++ b/python/nav/ipdevpoll/plugins/snmpcheck.py @@ -16,7 +16,6 @@ """snmp check plugin""" from pynetsnmp.netsnmp import SnmpTimeoutError from twisted.internet import error, defer -from twisted.internet.defer import returnValue from django.db import transaction @@ -71,10 +70,10 @@ def _do_check(self): result = yield self.agent.walk(SYSTEM_OID) except (defer.TimeoutError, error.TimeoutError, SnmpTimeoutError): self._logger.debug("SNMP v%s timed out", self.agent.snmpVersion) - returnValue(False) + return False self._logger.debug("SNMP response: %r", result) - returnValue(bool(result)) + return bool(result) @defer.inlineCallbacks def _mark_as_down(self): diff --git a/python/nav/ipdevpoll/plugins/statports.py b/python/nav/ipdevpoll/plugins/statports.py index 4cb6490fed..e3c7dabcfd 100644 --- a/python/nav/ipdevpoll/plugins/statports.py +++ b/python/nav/ipdevpoll/plugins/statports.py @@ -78,7 +78,7 @@ def can_handle(cls, netbox): def handle(self): if self.netbox.master: yield self._log_instance_details() - defer.returnValue(None) + return None timestamp = time.time() stats = yield self._get_stats() @@ -105,7 +105,7 @@ def _get_stats(self): stats[ifindex][IF_IN_OCTETS_IPV6] = in_octets stats[ifindex][IF_OUT_OCTETS_IPV6] = out_octets - defer.returnValue(stats) + return stats def _make_metrics(self, stats, netboxes, timestamp=None): timestamp = timestamp or time.time() diff --git a/python/nav/ipdevpoll/plugins/statsensors.py b/python/nav/ipdevpoll/plugins/statsensors.py index 37289be74e..75ebe132c3 100644 --- a/python/nav/ipdevpoll/plugins/statsensors.py +++ b/python/nav/ipdevpoll/plugins/statsensors.py @@ -46,8 +46,8 @@ def can_handle(cls, netbox): ) if base_can_handle: i_can_handle = yield run_in_thread(cls._has_sensors, netbox) - defer.returnValue(i_can_handle) - defer.returnValue(base_can_handle) + return i_can_handle + return base_can_handle @classmethod def _has_sensors(cls, netbox): @@ -56,7 +56,7 @@ def _has_sensors(cls, netbox): @defer.inlineCallbacks def handle(self): if self.netbox.master: - defer.returnValue(None) + return None netboxes = yield db.run_in_thread(self._get_netbox_list) sensors = yield run_in_thread(self._get_sensors) self._logger.debug("retrieving data from %d sensors", len(sensors)) diff --git a/python/nav/ipdevpoll/plugins/statsystem.py b/python/nav/ipdevpoll/plugins/statsystem.py index 21eb980b4c..f96fbe689a 100644 --- a/python/nav/ipdevpoll/plugins/statsystem.py +++ b/python/nav/ipdevpoll/plugins/statsystem.py @@ -75,7 +75,7 @@ class StatSystem(Plugin): @defer.inlineCallbacks def handle(self): if self.netbox.master: - defer.returnValue(None) + return None netboxes = yield db.run_in_thread(self._get_netbox_list) bandwidth = yield self._collect_bandwidth(netboxes) cpu = yield self._collect_cpu(netboxes) @@ -98,8 +98,8 @@ def _collect_bandwidth(self, netboxes): ) else: if metrics: - defer.returnValue(metrics) - defer.returnValue([]) + return metrics + return [] @defer.inlineCallbacks def _collect_bandwidth_from_mib(self, mib, netboxes): @@ -129,7 +129,7 @@ def _collect_bandwidth_from_mib(self, mib, netboxes): (timestamp, bandwidth_peak), ), ] - defer.returnValue(metrics) + return metrics @defer.inlineCallbacks def _collect_cpu(self, netboxes): @@ -142,8 +142,8 @@ def _collect_cpu(self, netboxes): "collect_cpu: ignoring timeout in %s", mib.mib['moduleName'] ) else: - defer.returnValue(load + utilization) - defer.returnValue([]) + return load + utilization + return [] @defer.inlineCallbacks def _get_cpu_loadavg(self, mib, netboxes): @@ -160,7 +160,7 @@ def _get_cpu_loadavg(self, mib, netboxes): for netbox in netboxes: path = metric_path_for_cpu_load(netbox, cpuname, interval) metrics.append((path, (timestamp, value))) - defer.returnValue(metrics) + return metrics @defer.inlineCallbacks def _get_cpu_utilization(self, mib, netboxes): @@ -176,7 +176,7 @@ def _get_cpu_utilization(self, mib, netboxes): for netbox in netboxes: path = metric_path_for_cpu_utilization(netbox, cpuname) metrics.append((path, (timestamp, value))) - defer.returnValue(metrics) + return metrics def _mibs_for_me(self, mib_class_dict): vendor = self.netbox.type.get_enterprise_id() if self.netbox.type else None @@ -196,9 +196,9 @@ def _collect_sysuptime(self, netboxes): for netbox in netboxes: path = metric_path_for_sysuptime(netbox) metrics.append((path, (timestamp, uptime))) - defer.returnValue(metrics) + return metrics else: - defer.returnValue([]) + return [] @defer.inlineCallbacks def _collect_power(self, netboxes): @@ -218,9 +218,9 @@ def _collect_power(self, netboxes): for index, value in power.items(): path = metric_path_for_power(netbox, index) metrics.append((path, (timestamp, value))) - defer.returnValue(metrics) + return metrics else: - defer.returnValue([]) + return [] @defer.inlineCallbacks def _collect_memory(self, netboxes): @@ -250,4 +250,4 @@ def _collect_memory(self, netboxes): (prefix + '.free', (timestamp, free)), ] ) - defer.returnValue(result) + return result diff --git a/python/nav/ipdevpoll/plugins/typeoid.py b/python/nav/ipdevpoll/plugins/typeoid.py index 47a94eed99..9231b9f975 100644 --- a/python/nav/ipdevpoll/plugins/typeoid.py +++ b/python/nav/ipdevpoll/plugins/typeoid.py @@ -67,7 +67,7 @@ def _fetch_sysobjectid(self): ) oid = OID(result) self._logger.debug("sysObjectID is %s", oid) - defer.returnValue(oid) + return oid def _is_sysobjectid_changed(self, oid): current_oid = OID(self.netbox.type.sysobjectid) if self.netbox.type else None @@ -129,7 +129,7 @@ def _create(): return type_ new_type = yield db.run_in_thread(_create) - defer.returnValue(new_type) + return new_type @classmethod def _get_vendor(cls, sysobjectid): diff --git a/python/nav/ipdevpoll/plugins/uptime.py b/python/nav/ipdevpoll/plugins/uptime.py index e3529db46a..c7c179865c 100644 --- a/python/nav/ipdevpoll/plugins/uptime.py +++ b/python/nav/ipdevpoll/plugins/uptime.py @@ -18,7 +18,7 @@ """Collects uptime ticks and interprets discontinuities as cold boots""" from datetime import timedelta, datetime -from twisted.internet.defer import inlineCallbacks, returnValue +from twisted.internet.defer import inlineCallbacks from nav.ipdevpoll import Plugin, shadows from nav.ipdevpoll.timestamps import TimestampChecker @@ -54,7 +54,7 @@ def _get_timestamps(self): "last sysuptime reset/rollover reported by device: %s", upsince ) stampcheck.save() - returnValue((changed, upsince)) + return (changed, upsince) def get_upsince(timestamp, ticks): diff --git a/python/nav/ipdevpoll/pool.py b/python/nav/ipdevpoll/pool.py index edf72f6efd..797f00e7c9 100755 --- a/python/nav/ipdevpoll/pool.py +++ b/python/nav/ipdevpoll/pool.py @@ -25,7 +25,7 @@ from twisted.protocols import amp from twisted.internet import reactor, protocol -from twisted.internet.defer import inlineCallbacks, returnValue +from twisted.internet.defer import inlineCallbacks from twisted.internet.endpoints import ProcessEndpoint, StandardIOEndpoint import twisted.internet.endpoints @@ -274,7 +274,7 @@ def start(self): now=False, ) - returnValue(self) + return self @property def pid(self): @@ -367,7 +367,7 @@ def responds_to_ping(self, timeout=10): deferred = self.process.callRemote(Ping) response = yield deferred.addTimeout(timeout, clock=reactor) self._logger.debug("PING: Response from %r: %r", self, response) - returnValue(response.get("result") == "pong") + return response.get("result") == "pong" def cancel(self, serial): """Cancels a job running on this worker""" diff --git a/python/nav/ipdevpoll/timestamps.py b/python/nav/ipdevpoll/timestamps.py index 9b356c72b9..959e88b7b5 100644 --- a/python/nav/ipdevpoll/timestamps.py +++ b/python/nav/ipdevpoll/timestamps.py @@ -84,7 +84,7 @@ def collect(self, collectors): else: value.raiseException() self.collected_times = tuple(tup) - defer.returnValue(self.collected_times) + return self.collected_times # We must ignore deserialization failures by catching the Exception base class # pylint: disable=W0703 @@ -107,7 +107,7 @@ def _deserialize(): return None self.loaded_times = yield db.run_in_thread(_deserialize) - defer.returnValue(self.loaded_times) + return self.loaded_times def save(self): """Saves timestamps to a ContainerRepository""" diff --git a/python/nav/ipdevpoll/utils.py b/python/nav/ipdevpoll/utils.py index 8e95c0cccc..af1a1a543f 100644 --- a/python/nav/ipdevpoll/utils.py +++ b/python/nav/ipdevpoll/utils.py @@ -139,7 +139,7 @@ def get_multibridgemib(agentproxy): from nav.mibs.bridge_mib import MultiBridgeMib instances = yield get_dot1d_instances(agentproxy) - defer.returnValue(MultiBridgeMib(agentproxy, instances)) + return MultiBridgeMib(agentproxy, instances) @defer.inlineCallbacks @@ -182,9 +182,9 @@ def get_dot1d_instances(agentproxy): modified_by, result, ) - defer.returnValue(result) + return result - defer.returnValue([]) + return [] @defer.inlineCallbacks @@ -202,7 +202,7 @@ def get_arista_vrf_instances(agentproxy) -> Deferred: states = yield vrf_mib.get_vrf_states(only='active') vrfs = [('', agentproxy.community)] vrfs.extend((vrf, f"{agentproxy.community}@{vrf}") for vrf in states) - defer.returnValue(vrfs) + return vrfs _VLAN_RE = re.compile('^vlan([0-9]+)', re.IGNORECASE) diff --git a/python/nav/mibs/alcatel_ind1_port_mib.py b/python/nav/mibs/alcatel_ind1_port_mib.py index 876a3165f4..34000fb5e7 100644 --- a/python/nav/mibs/alcatel_ind1_port_mib.py +++ b/python/nav/mibs/alcatel_ind1_port_mib.py @@ -19,7 +19,6 @@ """ from twisted.internet import defer -from twisted.internet.defer import returnValue from nav.smidumps import get_mib from nav.mibs.mibretriever import MibRetriever from nav.models.manage import Sensor @@ -69,7 +68,7 @@ def get_all_sensors(self): sensors = [] for column, config in COLUMNS.items(): sensors += yield self.handle_column(column, config) - returnValue(sensors) + return sensors @defer.inlineCallbacks def handle_column(self, column, config): @@ -89,4 +88,4 @@ def handle_column(self, column, config): print(sensor) sensor.update(config) result.append(sensor) - returnValue(result) + return result diff --git a/python/nav/mibs/arista_vrf_mib.py b/python/nav/mibs/arista_vrf_mib.py index f03e65ad83..eb418a9dbf 100644 --- a/python/nav/mibs/arista_vrf_mib.py +++ b/python/nav/mibs/arista_vrf_mib.py @@ -13,7 +13,7 @@ # more details. You should have received a copy of the GNU General Public # License along with NAV. If not, see . # -from twisted.internet.defer import inlineCallbacks, returnValue, Deferred +from twisted.internet.defer import inlineCallbacks, Deferred from nav.mibs import mibretriever from nav.oids import OID @@ -40,7 +40,7 @@ def get_vrf_states(self, only: str = None) -> Deferred: for k, v in states.items() if only is None or v['aristaVrfState'] == only } - returnValue(states) + return states def _vrf_index_to_string(index: OID) -> str: diff --git a/python/nav/mibs/bgp4_mib.py b/python/nav/mibs/bgp4_mib.py index d97fa49d9c..3f29d7b81c 100644 --- a/python/nav/mibs/bgp4_mib.py +++ b/python/nav/mibs/bgp4_mib.py @@ -22,7 +22,6 @@ import logging from twisted.internet import defer -from twisted.internet.defer import returnValue from nav.oidparsers import oid_to_ipv4 from nav.smidumps import get_mib @@ -50,7 +49,7 @@ def is_supported(self): """ reply = yield self.get_next(self.SUPPORTED_ROOT) - returnValue(bool(reply)) + return bool(reply) @defer.inlineCallbacks def get_bgp_peer_states(self): @@ -91,7 +90,7 @@ def get_bgp_peer_states(self): if self._logger.isEnabledFor(logging.DEBUG): self._logger.debug("Found BGP peers:\n%s", pformat(result)) - returnValue(result) + return result @staticmethod def _bgp_row_to_remote_ip(row_index): diff --git a/python/nav/mibs/bridge_mib.py b/python/nav/mibs/bridge_mib.py index 0d244d091b..13a44d58f0 100644 --- a/python/nav/mibs/bridge_mib.py +++ b/python/nav/mibs/bridge_mib.py @@ -38,7 +38,7 @@ def get_baseport_ifindex_map(self): @defer.inlineCallbacks def get_base_bridge_address(self): addr = yield self.get_next('dot1dBaseBridgeAddress') - defer.returnValue(addr) + return addr @defer.inlineCallbacks def get_forwarding_database(self): @@ -56,14 +56,14 @@ def get_forwarding_database(self): mac = ':'.join("%02x" % o for o in mac[-6:]) port = row['dot1dTpFdbPort'] result.append((mac, port)) - defer.returnValue(result) + return result @defer.inlineCallbacks def get_stp_blocking_ports(self): """Retrieves a list of numbers of STP blocking ports""" states = yield self.__get_stp_port_states() blocked = [port for port, state in states if state == 'blocking'] - defer.returnValue(blocked) + return blocked @defer.inlineCallbacks def get_stp_port_states(self): @@ -71,7 +71,7 @@ def get_stp_port_states(self): states = yield self.retrieve_columns(['dot1dStpPortState']) states = reduce_index(self.translate_result(states)) result = [(k, v['dot1dStpPortState']) for k, v in states.items()] - defer.returnValue(result) + return result __get_stp_port_states = get_stp_port_states diff --git a/python/nav/mibs/cd6c_mib.py b/python/nav/mibs/cd6c_mib.py index c234114684..9546178cd1 100644 --- a/python/nav/mibs/cd6c_mib.py +++ b/python/nav/mibs/cd6c_mib.py @@ -34,7 +34,7 @@ def get_all_sensors(self): supported = yield self.get_next('main') if not supported: self._logger.debug('CD6C mib not supported - returned %s', supported) - defer.returnValue([]) + return [] self._logger.debug('CD6C mib supported because main returned %s', supported) @@ -52,7 +52,7 @@ def get_all_sensors(self): all_sensors = temp_sensors + pressure_sensors + flow_sensors - defer.returnValue(all_sensors) + return all_sensors def create_sensor(self, sensor, precision=0, uom=''): """Creates sensor object based on name""" diff --git a/python/nav/mibs/cisco_cdp_mib.py b/python/nav/mibs/cisco_cdp_mib.py index b213e1eb84..f7a6820886 100644 --- a/python/nav/mibs/cisco_cdp_mib.py +++ b/python/nav/mibs/cisco_cdp_mib.py @@ -49,7 +49,7 @@ def get_cdp_neighbors(self): neighbor = self._make_cache_tuple(index, row) if neighbor: neighbors.append(neighbor) - defer.returnValue(neighbors) + return neighbors @defer.inlineCallbacks def _get_cdp_cache_table(self): @@ -61,7 +61,7 @@ def _get_cdp_cache_table(self): 'cdpCacheDevicePort', ] ) - defer.returnValue(reduce_index(cache)) + return reduce_index(cache) @staticmethod def _make_cache_tuple(index, row): diff --git a/python/nav/mibs/cisco_enhanced_memory_pool_mib.py b/python/nav/mibs/cisco_enhanced_memory_pool_mib.py index e5334d523c..0c7f0b0543 100644 --- a/python/nav/mibs/cisco_enhanced_memory_pool_mib.py +++ b/python/nav/mibs/cisco_enhanced_memory_pool_mib.py @@ -36,4 +36,4 @@ def get_memory_usage(self): result = dict( (row[NAME], (row[USED], row[FREE])) for row in pools.values() if row[VALID] ) - defer.returnValue(result) + return result diff --git a/python/nav/mibs/cisco_entity_fru_control_mib.py b/python/nav/mibs/cisco_entity_fru_control_mib.py index e513092bc1..5998285768 100644 --- a/python/nav/mibs/cisco_entity_fru_control_mib.py +++ b/python/nav/mibs/cisco_entity_fru_control_mib.py @@ -101,7 +101,7 @@ def get_fan_status(self, internal_id): "cefcFanTrayOperStatus", (int(internal_id),) ) self._logger.debug("cefcFanTrayOperStatus.%s = %r", internal_id, oper_status) - defer.returnValue(self._translate_fan_status(oper_status)) + return self._translate_fan_status(oper_status) @defer.inlineCallbacks def get_power_supply_status(self, internal_id): @@ -110,21 +110,21 @@ def get_power_supply_status(self, internal_id): "cefcFRUPowerOperStatus", (int(internal_id),) ) self._logger.debug("cefcFRUPowerOperStatus.%s = %r", internal_id, oper_status) - defer.returnValue(self._translate_power_supply_status_value(oper_status)) + return self._translate_power_supply_status_value(oper_status) @defer.inlineCallbacks def get_fan_status_table(self): """Retrieve the whole table of fan-sensors and cache the result.""" if not self.fan_status_table: self.fan_status_table = yield self._get_fantray_status_table() - defer.returnValue(self.fan_status_table) + return self.fan_status_table @defer.inlineCallbacks def get_psu_status_table(self): """Retrieve the whole table of PSU-sensors and cache the result.""" if not self.psu_status_table: self.psu_status_table = yield self._get_power_status_table() - defer.returnValue(self.psu_status_table) + return self.psu_status_table def get_power_supplies(self): """Retrieves a list of power supply objects""" @@ -144,4 +144,4 @@ def get_fans(self): "found %d/%d field-replaceable fan entities", len(status), len(fans) ) fans = [fan for fan in fans if fan.internal_id in status] - defer.returnValue(fans) + return fans diff --git a/python/nav/mibs/cisco_envmon_mib.py b/python/nav/mibs/cisco_envmon_mib.py index 99e76f4b77..1ebb822dcb 100644 --- a/python/nav/mibs/cisco_envmon_mib.py +++ b/python/nav/mibs/cisco_envmon_mib.py @@ -209,4 +209,4 @@ def get_all_sensors(self): result.extend(self._get_powersupply_sensor_params(powersupply_sensors)) self._logger.debug('get_all_sensors: result=%s', result) - defer.returnValue(result) + return result diff --git a/python/nav/mibs/cisco_hsrp_mib.py b/python/nav/mibs/cisco_hsrp_mib.py index ecfcc80cfc..cb28ff51e8 100644 --- a/python/nav/mibs/cisco_hsrp_mib.py +++ b/python/nav/mibs/cisco_hsrp_mib.py @@ -34,4 +34,4 @@ def get_virtual_addresses(self): addr_map = dict( (IP(ip), ifindex) for (ifindex, group), ip in index_addrs.items() ) - defer.returnValue(addr_map) + return addr_map diff --git a/python/nav/mibs/cisco_ietf_ip_mib.py b/python/nav/mibs/cisco_ietf_ip_mib.py index 1d8a095b5d..99dba865d0 100644 --- a/python/nav/mibs/cisco_ietf_ip_mib.py +++ b/python/nav/mibs/cisco_ietf_ip_mib.py @@ -72,7 +72,7 @@ def get_ifindex_ip_mac_mappings(self): column='cInetNetToMediaPhysAddress' ) - defer.returnValue(mappings) + return mappings @defer.inlineCallbacks def get_interface_addresses(self): @@ -90,7 +90,7 @@ def get_interface_addresses(self): prefix_entry='cIpAddressPfxOrigin', ) - defer.returnValue(addresses) + return addresses @staticmethod def _binary_mac_to_hex(mac): diff --git a/python/nav/mibs/cisco_memory_pool_mib.py b/python/nav/mibs/cisco_memory_pool_mib.py index 7738d51316..c2e4803a70 100644 --- a/python/nav/mibs/cisco_memory_pool_mib.py +++ b/python/nav/mibs/cisco_memory_pool_mib.py @@ -38,4 +38,4 @@ def get_memory_usage(self): result = dict( (row[NAME], (row[USED], row[FREE])) for row in pools.values() if row[VALID] ) - defer.returnValue(result) + return result diff --git a/python/nav/mibs/cisco_process_mib.py b/python/nav/mibs/cisco_process_mib.py index d2748ce561..a793873896 100644 --- a/python/nav/mibs/cisco_process_mib.py +++ b/python/nav/mibs/cisco_process_mib.py @@ -50,12 +50,12 @@ def get_cpu_loadavg(self): for index, row in load.items(): name = names.get(row[PHYSICAL_INDEX], str(index[-1])) result[name] = [(5, row[TOTAL_5_MIN_REV]), (1, row[TOTAL_1_MIN_REV])] - defer.returnValue(result) + return result @defer.inlineCallbacks def _get_cpu_names(self, indexes): if not indexes: - defer.returnValue({}) + return {} self._logger.debug("getting cpu names from ENTITY-MIB") base_oid = EntityMib.nodes['entPhysicalName'].oid oids = [str(base_oid + (index,)) for index in indexes] @@ -64,7 +64,7 @@ def _get_cpu_names(self, indexes): names = { OID(oid)[-1]: smart_str(value) for oid, value in names.items() if value } - defer.returnValue(names) + return names def get_cpu_utilization(self): return defer.succeed(None) diff --git a/python/nav/mibs/cisco_vlan_iftable_relationship_mib.py b/python/nav/mibs/cisco_vlan_iftable_relationship_mib.py index f32979315a..ad8bede3e0 100644 --- a/python/nav/mibs/cisco_vlan_iftable_relationship_mib.py +++ b/python/nav/mibs/cisco_vlan_iftable_relationship_mib.py @@ -42,7 +42,7 @@ def get_routed_vlan_ifindexes(self): RoutedVlan(vlan, physical, virtual) for (vlan, physical), virtual in routed_vlans.items() ] - defer.returnValue(result) + return result # pylint: disable=C0103 diff --git a/python/nav/mibs/cisco_vlan_membership_mib.py b/python/nav/mibs/cisco_vlan_membership_mib.py index 18c5bba140..7222d461f1 100644 --- a/python/nav/mibs/cisco_vlan_membership_mib.py +++ b/python/nav/mibs/cisco_vlan_membership_mib.py @@ -31,4 +31,4 @@ def get_vlan_membership(self): vlans = yield self.retrieve_column('vmVlan') result = {index[0]: vlan for index, vlan in vlans.items()} - defer.returnValue(result) + return result diff --git a/python/nav/mibs/cisco_vtp_mib.py b/python/nav/mibs/cisco_vtp_mib.py index 7fe6c65310..a16090e1dc 100644 --- a/python/nav/mibs/cisco_vtp_mib.py +++ b/python/nav/mibs/cisco_vtp_mib.py @@ -15,7 +15,6 @@ # from __future__ import absolute_import from twisted.internet import defer -from twisted.internet.defer import returnValue from nav.bitvector import BitVector from nav.smidumps import get_mib @@ -39,7 +38,7 @@ def get_trunk_native_vlans(self): for index, row in trunkports.items() if row['vlanTrunkPortDynamicState'] in ('on', 'onNoNegotiate') } - returnValue(result) + return result @defer.inlineCallbacks def get_trunk_enabled_vlans(self, as_bitvector=False): @@ -78,7 +77,7 @@ def get_vlan_list(row): for index, row in trunkports.items() if row['vlanTrunkPortDynamicState'] in ('on', 'onNoNegotiate') } - returnValue(result) + return result @defer.inlineCallbacks def get_ethernet_vlan_states(self): @@ -92,15 +91,13 @@ def get_ethernet_vlan_states(self): for (_domain, vlan), row in states.items() if row['vtpVlanType'] == 'ethernet' } - defer.returnValue(result) + return result @defer.inlineCallbacks def get_operational_vlans(self): """Retrieves a set of operational ethernet VLANs on this device""" states = yield self.get_ethernet_vlan_states() - defer.returnValue( - set(vlan for vlan, state in states.items() if state == 'operational') - ) + return set(vlan for vlan, state in states.items() if state == 'operational') @defer.inlineCallbacks def retrieve_alternate_bridge_mibs(self): @@ -112,6 +109,4 @@ def retrieve_alternate_bridge_mibs(self): """ vlans = yield self.get_operational_vlans() community = self.agent_proxy.community - defer.returnValue( - [("vlan%s" % vlan, "%s@%s" % (community, vlan)) for vlan in vlans] - ) + return [("vlan%s" % vlan, "%s@%s" % (community, vlan)) for vlan in vlans] diff --git a/python/nav/mibs/comet.py b/python/nav/mibs/comet.py index 97b87821b6..332525325c 100644 --- a/python/nav/mibs/comet.py +++ b/python/nav/mibs/comet.py @@ -22,7 +22,6 @@ """ from twisted.internet import defer -from twisted.internet.defer import returnValue from nav.Snmp import safestring from nav.smidumps import get_mib @@ -49,7 +48,7 @@ def get_all_sensors(self): """ channels = yield self.get_channels() bin_inputs = yield self.get_binary_inputs() - returnValue(channels + bin_inputs) + return channels + bin_inputs @defer.inlineCallbacks def get_channels(self): @@ -81,7 +80,7 @@ def get_channels(self): mib=self.get_module_name(), ) ) - returnValue(result) + return result @defer.inlineCallbacks def get_binary_inputs(self): @@ -131,7 +130,7 @@ def get_binary_inputs(self): on_state=1, ) ) - returnValue(result) + return result class CometMS(MibRetriever): @@ -145,7 +144,7 @@ def get_all_sensors(self): device. """ channels = yield self.get_channels() - returnValue(channels) + return channels @defer.inlineCallbacks def get_channels(self): @@ -172,4 +171,4 @@ def get_channels(self): mib=self.get_module_name(), ) ) - returnValue(result) + return result diff --git a/python/nav/mibs/coriant_groove_mib.py b/python/nav/mibs/coriant_groove_mib.py index 130dde9ff6..e55ebcaa87 100644 --- a/python/nav/mibs/coriant_groove_mib.py +++ b/python/nav/mibs/coriant_groove_mib.py @@ -16,7 +16,6 @@ """A class for getting DOM values from Coriant Groove equipment""" from twisted.internet import defer -from twisted.internet.defer import returnValue from nav.smidumps import get_mib from nav.mibs.mibretriever import MibRetriever from nav.models.manage import Sensor @@ -153,7 +152,7 @@ def get_all_sensors(self): filter_columns=group.get("filter_columns"), ) sensors.extend(response) - returnValue(sensors) + return sensors @defer.inlineCallbacks def _discover_sensors( @@ -226,7 +225,7 @@ def _discover_sensors( ] ) self._logger.debug("Returning sensor list: %r", sensors) - returnValue(sensors) + return sensors def _make_sensor(self, index, name, alias, column, config): value_oid = self.nodes[column].oid diff --git a/python/nav/mibs/cpqpower_mib.py b/python/nav/mibs/cpqpower_mib.py index f06f50fcea..580bb0d486 100644 --- a/python/nav/mibs/cpqpower_mib.py +++ b/python/nav/mibs/cpqpower_mib.py @@ -183,7 +183,7 @@ def get_all_sensors(self): for config in SENSORS: r = yield self._get_sensors(names, **config) result.extend(r) - defer.returnValue(result) + return result def _get_oid(self, column, index): return self.mib['nodes'][column]['oid'] + index @@ -200,7 +200,7 @@ def _get_names(self): name = name.strip() name = name.replace('\0', '') result[index] = name - defer.returnValue(result) + return result @defer.inlineCallbacks def _get_sensors(self, names, sensors, extra_columns=None, filter=lambda x: True): @@ -214,7 +214,7 @@ def _get_sensors(self, names, sensors, extra_columns=None, filter=lambda x: True if not filter(row): continue result.extend(self._mksensors(index, row, sensors, names)) - defer.returnValue(result) + return result def _mksensors(self, index, row, table, names): result = [] diff --git a/python/nav/mibs/eltek_distributed_mib.py b/python/nav/mibs/eltek_distributed_mib.py index 7f1f066298..aa1d926e2e 100644 --- a/python/nav/mibs/eltek_distributed_mib.py +++ b/python/nav/mibs/eltek_distributed_mib.py @@ -14,7 +14,7 @@ # along with NAV. If not, see . # """MibRetriever implementation for Eltek 48V rectifier devices""" -from twisted.internet.defer import inlineCallbacks, returnValue +from twisted.internet.defer import inlineCallbacks from nav.smidumps import get_mib from nav.mibs.mibretriever import MibRetriever from nav.models.manage import Sensor @@ -54,7 +54,7 @@ def get_all_sensors(self): if sensor: sensors.append(sensor) - returnValue(sensors) + return sensors @inlineCallbacks def _verify_sensor(self, object_name): @@ -81,4 +81,4 @@ def _verify_sensor(self, object_name): sensor['on_state'] = 1 sensor['on_message'] = "{} alarm".format(description) sensor['off_message'] = "{} normal".format(description) - returnValue(sensor) + return sensor diff --git a/python/nav/mibs/entity_mib.py b/python/nav/mibs/entity_mib.py index 55f98a7953..4eecde2f48 100644 --- a/python/nav/mibs/entity_mib.py +++ b/python/nav/mibs/entity_mib.py @@ -90,13 +90,13 @@ def _get_named_table(self, table_name): df.addCallback(self.translate_result) ret_table = yield df named_table = EntityTable(ret_table) - defer.returnValue(named_table) + return named_table @defer.inlineCallbacks def get_entity_physical_table(self): """Retrieves the full entPhysicalTable contents""" phy_sensor_table = yield self._get_named_table('entPhysicalTable') - defer.returnValue(phy_sensor_table) + return phy_sensor_table @defer.inlineCallbacks def get_useful_physical_table_columns(self): @@ -116,12 +116,12 @@ def get_useful_physical_table_columns(self): 'entPhysicalIsFRU', ] ) - defer.returnValue(self.translate_result(columns)) + return self.translate_result(columns) @defer.inlineCallbacks def get_alias_mapping(self): alias_mapping = yield self.retrieve_column('entAliasMappingIdentifier') - defer.returnValue(self._process_alias_mapping(alias_mapping)) + return self._process_alias_mapping(alias_mapping) def _process_alias_mapping(self, alias_mapping): mapping = defaultdict(list) @@ -155,7 +155,7 @@ def __filter_psu_or_fan(self, filter_function): for e in table.values() if filter_function(e) ] - defer.returnValue(objects) + return objects class EntityTable(dict): diff --git a/python/nav/mibs/entity_sensor_mib.py b/python/nav/mibs/entity_sensor_mib.py index e96f63f441..a4fb532dca 100644 --- a/python/nav/mibs/entity_sensor_mib.py +++ b/python/nav/mibs/entity_sensor_mib.py @@ -137,4 +137,4 @@ def get_all_sensors(self): } ) self._logger.debug('get_all_sensors: result=%s', result) - defer.returnValue(result) + return result diff --git a/python/nav/mibs/esswitch_mib.py b/python/nav/mibs/esswitch_mib.py index df2335cdf5..fa38757279 100644 --- a/python/nav/mibs/esswitch_mib.py +++ b/python/nav/mibs/esswitch_mib.py @@ -46,4 +46,4 @@ def get_bandwidth_peak(self): self.nodes[self.BANDWIDTH_USAGE_CURRENT_PEAK].oid + (peak_index,) ) rsp = yield self.agent_proxy.get([peak_oid]) - defer.returnValue(rsp.get(peak_oid, None)) + return rsp.get(peak_oid, None) diff --git a/python/nav/mibs/etherlike_mib.py b/python/nav/mibs/etherlike_mib.py index c127747063..b3a815b935 100644 --- a/python/nav/mibs/etherlike_mib.py +++ b/python/nav/mibs/etherlike_mib.py @@ -35,4 +35,4 @@ def get_duplex(self): result = { index[0]: row['dot3StatsDuplexStatus'] for index, row in duplex.items() } - defer.returnValue(result) + return result diff --git a/python/nav/mibs/hp_httpmanageable_mib.py b/python/nav/mibs/hp_httpmanageable_mib.py index b8ef34a663..db20c07782 100644 --- a/python/nav/mibs/hp_httpmanageable_mib.py +++ b/python/nav/mibs/hp_httpmanageable_mib.py @@ -30,4 +30,4 @@ def get_serial_number(self): if serial: if isinstance(serial, bytes): serial = serial.decode("utf-8") - defer.returnValue(serial) + return serial diff --git a/python/nav/mibs/hpicf_fan_mib.py b/python/nav/mibs/hpicf_fan_mib.py index 3036ad021c..0f1eb75ece 100644 --- a/python/nav/mibs/hpicf_fan_mib.py +++ b/python/nav/mibs/hpicf_fan_mib.py @@ -57,7 +57,7 @@ def _get_fan_status_table(self): df.addCallback(reduce_index) fan_table = yield df self._logger.debug("fan_table: %r", fan_table) - defer.returnValue(fan_table) + return fan_table @staticmethod def _translate_fan_status(psu_status): @@ -79,7 +79,7 @@ def get_fan_status(self, internal_id): fan_status = fan_status_row.get("hpicfFanState") self._logger.debug("hpicfFanState.%s = %r", index, fan_status) - defer.returnValue(self._translate_fan_status(fan_status)) + return self._translate_fan_status(fan_status) @defer.inlineCallbacks def get_fans(self): @@ -102,4 +102,4 @@ def get_fans(self): ): ent.internal_id = "{}:{}".format(ent.internal_id, index) - defer.returnValue(entities) + return entities diff --git a/python/nav/mibs/hpicf_powersupply_mib.py b/python/nav/mibs/hpicf_powersupply_mib.py index e18d56c33b..c665774b11 100644 --- a/python/nav/mibs/hpicf_powersupply_mib.py +++ b/python/nav/mibs/hpicf_powersupply_mib.py @@ -54,7 +54,7 @@ def _get_psu_status_table(self): df.addCallback(reduce_index) psu_table = yield df self._logger.debug("psu_table: %r", psu_table) - defer.returnValue(psu_table) + return psu_table @staticmethod def _translate_psu_status(psu_status): @@ -76,7 +76,7 @@ def get_power_supply_status(self, internal_id): psu_status = psu_status_row.get("hpicfPsState") self._logger.debug("hpicfPsState.%s = %r", index, psu_status) - defer.returnValue(self._translate_psu_status(psu_status)) + return self._translate_psu_status(psu_status) @defer.inlineCallbacks def get_power_supplies(self): @@ -100,7 +100,7 @@ def get_power_supplies(self): ): ent.internal_id = "{}:{}".format(ent.internal_id, index) - defer.returnValue(entities) + return entities def _psu_index_from_internal_id(internal_id): diff --git a/python/nav/mibs/ibm_pdu_mib.py b/python/nav/mibs/ibm_pdu_mib.py index b3864c07c0..548cbd0312 100644 --- a/python/nav/mibs/ibm_pdu_mib.py +++ b/python/nav/mibs/ibm_pdu_mib.py @@ -15,7 +15,7 @@ # """MibRetriever implementation for IBM-PDU-MIB""" -from twisted.internet.defer import inlineCallbacks, returnValue +from twisted.internet.defer import inlineCallbacks from nav.mibs import reduce_index from nav.smidumps import get_mib @@ -46,7 +46,7 @@ def get_all_sensors(self): """ phases = yield self._get_phase_sensors() outlets = yield self._get_outlet_sensors() - returnValue(phases + outlets) + return phases + outlets @inlineCallbacks def _get_phase_sensors(self): @@ -78,7 +78,7 @@ def _get_phase_sensors(self): ) ) - returnValue(result) + return result @inlineCallbacks def _get_outlet_sensors(self): @@ -99,7 +99,7 @@ def _get_outlet_sensors(self): for index, row in outlets.items(): result.extend(self._outlet_row_to_sensors(index, row)) - returnValue(result) + return result def _outlet_row_to_sensors(self, index, row): name = row.get(OUTLET_NAME) diff --git a/python/nav/mibs/ieee8023_lag_mib.py b/python/nav/mibs/ieee8023_lag_mib.py index 7f8b453716..08ccda52a3 100644 --- a/python/nav/mibs/ieee8023_lag_mib.py +++ b/python/nav/mibs/ieee8023_lag_mib.py @@ -15,7 +15,7 @@ # """"A MibRetriever to retrieve IEEE 802.3ad info from the IEEE8023-LAG-MIB""" from collections import defaultdict -from twisted.internet.defer import inlineCallbacks, returnValue +from twisted.internet.defer import inlineCallbacks from nav.smidumps import get_mib from nav.mibs import mibretriever, reduce_index @@ -36,9 +36,9 @@ def retrieve_selected_aggregators(self): result = yield self.retrieve_column('dot3adAggPortSelectedAggID').addCallback( reduce_index ) - returnValue( - {port: aggregator for port, aggregator in result.items() if aggregator != 0} - ) + return { + port: aggregator for port, aggregator in result.items() if aggregator != 0 + } @inlineCallbacks def retrieve_attached_aggregators(self): @@ -51,9 +51,9 @@ def retrieve_attached_aggregators(self): result = yield self.retrieve_column('dot3adAggPortAttachedAggID').addCallback( reduce_index ) - returnValue( - {port: aggregator for port, aggregator in result.items() if aggregator != 0} - ) + return { + port: aggregator for port, aggregator in result.items() if aggregator != 0 + } @inlineCallbacks def retrieve_aggregations_by_operational_key(self): @@ -81,4 +81,4 @@ def retrieve_aggregations_by_operational_key(self): if opervalue in by_opervalue } - returnValue(result) + return result diff --git a/python/nav/mibs/if_mib.py b/python/nav/mibs/if_mib.py index 71d4cc0ac2..193f2266a9 100644 --- a/python/nav/mibs/if_mib.py +++ b/python/nav/mibs/if_mib.py @@ -35,7 +35,7 @@ def get_if_table(self): df.addCallback(self.translate_result) df.addCallback(reduce_index) if_table = yield df - defer.returnValue(if_table) + return if_table @defer.inlineCallbacks def get_ifnames(self): @@ -50,7 +50,7 @@ def get_ifnames(self): result = dict( (index, (row['ifName'], row['ifDescr'])) for index, row in table.items() ) - defer.returnValue(result) + return result @defer.inlineCallbacks def get_ifaliases(self): @@ -60,13 +60,13 @@ def get_ifaliases(self): """ aliases = yield self.retrieve_column('ifAlias').addCallback(reduce_index) - defer.returnValue(aliases) + return aliases @defer.inlineCallbacks def get_ifindexes(self): "Retrieves a list of current ifIndexes" indexes = yield self.retrieve_column('ifIndex') - defer.returnValue(indexes.values()) + return indexes.values() @defer.inlineCallbacks def get_admin_status(self): @@ -81,7 +81,7 @@ def get_admin_status(self): status = yield df result = dict((index, row['ifAdminStatus']) for index, row in status.items()) - defer.returnValue(result) + return result @defer.inlineCallbacks def get_stack_status(self): @@ -94,4 +94,4 @@ def get_stack_status(self): """ status = yield self.retrieve_columns(['ifStackStatus']) result = [(h, l) for h, l in status.keys() if h > 0 and l > 0] - defer.returnValue(result) + return result diff --git a/python/nav/mibs/ip_forward_mib.py b/python/nav/mibs/ip_forward_mib.py index 482d9a4d16..2c1186c2b4 100644 --- a/python/nav/mibs/ip_forward_mib.py +++ b/python/nav/mibs/ip_forward_mib.py @@ -20,7 +20,7 @@ from itertools import chain from collections import namedtuple -from twisted.internet.defer import inlineCallbacks, returnValue +from twisted.internet.defer import inlineCallbacks from nav.smidumps import get_mib from nav.oidparsers import consume @@ -78,9 +78,9 @@ def get_routes(self, protocols=None): if protocols: result = chain(*[by_proto.get(proto, []) for proto in protocols]) - returnValue(list(result)) + return list(result) else: - returnValue(dict(by_proto)) + return dict(by_proto) @inlineCallbacks def get_decoded_routes(self, protocols=None): @@ -115,7 +115,7 @@ def decode(index): for entry in (decode_route_entry(r) for r in result[proto]) if entry ] - returnValue(result) + return result def get_cidr_route_column(self, column, index): """Retrieves the value of a specific column for a given route index""" diff --git a/python/nav/mibs/ip_mib.py b/python/nav/mibs/ip_mib.py index 04dee0639a..beb985b668 100644 --- a/python/nav/mibs/ip_mib.py +++ b/python/nav/mibs/ip_mib.py @@ -18,7 +18,7 @@ """MibRetriever implementation for IP-MIB""" from __future__ import absolute_import -from twisted.internet.defer import inlineCallbacks, returnValue +from twisted.internet.defer import inlineCallbacks from nav.oids import OID from nav.oidparsers import IPV4_ID, IPV6_ID, oid_to_ipv6, oid_to_ipv4 @@ -161,7 +161,7 @@ def _get_ifindex_ip_mac_mappings(self, column='ipNetToPhysicalPhysAddress'): self._logger.debug( "ip/mac pairs: Got %d rows from %s", len(all_phys_addrs), column ) - returnValue(mappings) + return mappings @inlineCallbacks def _get_ifindex_ipv4_mac_mappings(self, column='ipNetToMediaPhysAddress'): @@ -194,7 +194,7 @@ def _get_ifindex_ipv4_mac_mappings(self, column='ipNetToMediaPhysAddress'): self._logger.debug( "ip/mac pairs: Got %d rows from %s", len(ipv4_phys_addrs), column ) - returnValue(mappings) + return mappings @staticmethod def _binary_mac_to_hex(mac): @@ -219,7 +219,7 @@ def get_ifindex_ip_mac_mappings(self): mappings_new = yield self._get_ifindex_ip_mac_mappings() mappings_deprecated = yield self._get_ifindex_ipv4_mac_mappings() - returnValue(mappings_new | mappings_deprecated) + return mappings_new | mappings_deprecated @inlineCallbacks def _get_interface_ipv4_addresses( @@ -267,7 +267,7 @@ def _get_interface_ipv4_addresses( len(address_rows), ifindex_column, ) - returnValue(addresses) + return addresses @inlineCallbacks def _get_interface_addresses( @@ -311,7 +311,7 @@ def _get_interface_addresses( len(address_rows), ifindex_column, ) - returnValue(addresses) + return addresses @inlineCallbacks def get_interface_addresses(self): @@ -329,7 +329,7 @@ def get_interface_addresses(self): addrs_from_new_table = yield self._get_interface_addresses() addrs_from_deprecated_table = yield self._get_interface_ipv4_addresses() - returnValue(addrs_from_new_table | addrs_from_deprecated_table) + return addrs_from_new_table | addrs_from_deprecated_table @inlineCallbacks def get_ipv6_octet_counters(self): @@ -344,7 +344,7 @@ def get_ipv6_octet_counters(self): for index, row in octets.items() if index[-2] == IPV6_ID ) - returnValue(result) + return result class MultiIpMib(IpMib, mibretriever.MultiMibMixIn): diff --git a/python/nav/mibs/ipv6_mib.py b/python/nav/mibs/ipv6_mib.py index e510dd3f9f..097dd7d5cc 100644 --- a/python/nav/mibs/ipv6_mib.py +++ b/python/nav/mibs/ipv6_mib.py @@ -89,7 +89,7 @@ def get_ifindex_ip_mac_mappings(self): self._logger.debug( "ip/mac pairs: Got %d rows from %s", len(ipv6_phys_addrs), column ) - defer.returnValue(mappings) + return mappings @defer.inlineCallbacks def get_interface_addresses(self): @@ -121,4 +121,4 @@ def get_interface_addresses(self): prefixlen_column, ) - defer.returnValue(addresses) + return addresses diff --git a/python/nav/mibs/itw_mib.py b/python/nav/mibs/itw_mib.py index 13cb51b715..33ad510c6b 100644 --- a/python/nav/mibs/itw_mib.py +++ b/python/nav/mibs/itw_mib.py @@ -397,7 +397,7 @@ def get_all_sensors(self): for sensor_group in sensor_groups: result.extend(self._handle_sensor_group(sensor_group, sensors)) - defer.returnValue(result) + return result UNITS = { diff --git a/python/nav/mibs/itw_mibv3.py b/python/nav/mibs/itw_mibv3.py index 261a320168..4c1ed2bbba 100644 --- a/python/nav/mibs/itw_mibv3.py +++ b/python/nav/mibs/itw_mibv3.py @@ -516,4 +516,4 @@ def get_all_sensors(self): self._logger.debug('get_all_sensors: %s = %s', table, sensors) result.extend(handler(sensors)) - defer.returnValue(result) + return result diff --git a/python/nav/mibs/juniper_alarm_mib.py b/python/nav/mibs/juniper_alarm_mib.py index 4ac26692b2..a1a6f5e29b 100644 --- a/python/nav/mibs/juniper_alarm_mib.py +++ b/python/nav/mibs/juniper_alarm_mib.py @@ -41,4 +41,4 @@ def _get_alarm_count(self, oid): count = int(count) or 0 except (ValueError, TypeError): count = 0 - defer.returnValue(count) + return count diff --git a/python/nav/mibs/juniper_dom_mib.py b/python/nav/mibs/juniper_dom_mib.py index b8c71550de..24a394a571 100644 --- a/python/nav/mibs/juniper_dom_mib.py +++ b/python/nav/mibs/juniper_dom_mib.py @@ -18,7 +18,6 @@ """ from twisted.internet import defer -from twisted.internet.defer import returnValue from nav.smidumps import get_mib from nav.mibs.mibretriever import MibRetriever from nav.models.manage import Sensor @@ -65,7 +64,7 @@ def get_all_sensors(self): sensors = [] for column, config in COLUMNS.items(): sensors += yield self.handle_column(column, config) - returnValue(sensors) + return sensors @defer.inlineCallbacks def handle_column(self, column, config): @@ -83,4 +82,4 @@ def handle_column(self, column, config): ) sensor.update(config) result.append(sensor) - returnValue(result) + return result diff --git a/python/nav/mibs/juniper_mib.py b/python/nav/mibs/juniper_mib.py index 700159d96a..a3b96d956f 100644 --- a/python/nav/mibs/juniper_mib.py +++ b/python/nav/mibs/juniper_mib.py @@ -70,7 +70,7 @@ def get_serial_number(self): if serial: if isinstance(serial, bytes): serial = serial.decode("utf-8") - defer.returnValue(serial) + return serial @defer.inlineCallbacks def get_cpu_loadavg(self): @@ -98,7 +98,7 @@ def get_cpu_loadavg(self): (1, row[LOAD_AVG_1MIN]), ] result[name] = values - defer.returnValue(result) + return result @defer.inlineCallbacks def get_cpu_utilization(self): @@ -119,7 +119,7 @@ def get_cpu_utilization(self): if row[OPERATING_CPU]: name = row[OPERATING_DESCR] result[name] = row[OPERATING_CPU] - defer.returnValue(result) + return result def get_power_supplies(self): """Retrieves a list of field-replaceable power supply units""" @@ -147,7 +147,7 @@ def _get_fru_by_type(self, fru_type): for row in response.values() if row.get("jnxFruState") != "empty" and row.get("jnxFruType") == fru_type ] - defer.returnValue(units) + return units @defer.inlineCallbacks def get_fru_status(self, internal_id): @@ -156,7 +156,7 @@ def get_fru_status(self, internal_id): "jnxFruState", OID(internal_id) ) self._logger.debug("jnxFruState.%s = %r", internal_id, oper_status) - defer.returnValue(self._translate_fru_status_value(oper_status)) + return self._translate_fru_status_value(oper_status) get_fan_status = get_fru_status get_power_supply_status = get_fru_status @@ -168,7 +168,7 @@ def get_all_sensors(self): for table, config in SENSOR_TABLES.items(): sensors = yield self._get_sensors(config) result.extend(sensors) - defer.returnValue(result) + return result @defer.inlineCallbacks def _get_sensors(self, config): @@ -189,7 +189,7 @@ def _get_sensors(self, config): self._row_to_sensor(config, index, row) for index, row in result.items() ) - defer.returnValue([s for s in sensors if s]) + return [s for s in sensors if s] def _row_to_sensor(self, config, index, row): """ @@ -246,7 +246,7 @@ def get_memory_usage(self): used = (row[OPERATING_BUF] / 100) * total free = total - used result[row[OPERATING_DESCR]] = (used, free) - defer.returnValue(result) + return result def _fru_row_to_powersupply_or_fan(fru_row): diff --git a/python/nav/mibs/lldp_mib.py b/python/nav/mibs/lldp_mib.py index c17c58b57b..58f7eb22f0 100644 --- a/python/nav/mibs/lldp_mib.py +++ b/python/nav/mibs/lldp_mib.py @@ -18,7 +18,7 @@ import socket from collections import namedtuple -from twisted.internet.defer import inlineCallbacks, returnValue +from twisted.internet.defer import inlineCallbacks from nav.ip import IP from nav.mibs.if_mib import IfMib @@ -49,7 +49,7 @@ def get_remote_table(self): else: result = [] - returnValue(result) + return result def _retrieve_rem_table(self): return self.retrieve_columns( @@ -92,7 +92,7 @@ def _translate_port_numbers(self, remote_table): """ if self._is_remote_table_index_broken(remote_table): self._logger.warning("lldpRemTable has broken row indexes on this device") - returnValue([]) + return [] remotes = remote_table.values() local_ports = yield self._retrieve_local_ports() @@ -141,7 +141,7 @@ def _translate_port_numbers(self, remote_table): _timemark, local_portnum, _index = remote[0] remote[0] = lookup.get(local_portnum, local_portnum) - returnValue(remotes) + return remotes @staticmethod def _is_remote_table_index_broken(remote_table): @@ -164,7 +164,7 @@ def _retrieve_local_ports(self): index: IdSubtypes.get(row['lldpLocPortIdSubtype'], row['lldpLocPortId']) for index, row in ports.items() } - returnValue(result) + return result @inlineCallbacks def _make_interface_lookup_dict(self): @@ -174,7 +174,7 @@ def _make_interface_lookup_dict(self): for ifindex, (ifname, ifdescr) in ifnames.items(): lookup[ifdescr] = ifindex lookup[ifname] = ifindex - returnValue(lookup) + return lookup # pylint: disable=C0103 diff --git a/python/nav/mibs/mibretriever.py b/python/nav/mibs/mibretriever.py index be0312f45c..7ea6d8743f 100644 --- a/python/nav/mibs/mibretriever.py +++ b/python/nav/mibs/mibretriever.py @@ -35,7 +35,6 @@ from pynetsnmp.netsnmp import SnmpTimeoutError from twisted.internet import defer, reactor -from twisted.internet.defer import returnValue from twisted.internet.error import TimeoutError from twisted.python.failure import Failure @@ -390,7 +389,7 @@ def get_next(self, object_name, translate_result=False): if oid.is_a_prefix_of(key): if translate_result: value = self.nodes[object_name].to_python(value) - defer.returnValue(value) + return value def retrieve_column(self, column_name): """Retrieve the contents of a single MIB table column. @@ -574,7 +573,7 @@ def retrieve_column_by_index(self, column, index): result = yield self.agent_proxy._get([oid]) for obj, value in result: assert obj == oid - returnValue(node.to_python(value)) + return node.to_python(value) class MultiMibMixIn(MibRetriever): @@ -654,7 +653,7 @@ class constructor; result is the actual result self.agent_proxy = self._base_agent results.append((descr, one_result)) yield lambda thing: fire_eventually(thing) - defer.returnValue(integrator(results)) + return integrator(results) def __timeout_handler(self, failure, descr): """Handles timeouts while processing alternate MIB instances. diff --git a/python/nav/mibs/netswitch_mib.py b/python/nav/mibs/netswitch_mib.py index d1ef2ad245..f50551d38b 100644 --- a/python/nav/mibs/netswitch_mib.py +++ b/python/nav/mibs/netswitch_mib.py @@ -47,4 +47,4 @@ def get_memory_usage(self): slots = yield self.retrieve_columns([slot_oid, free_oid, used_oid]) for row in slots.values(): result[kind + str(row[slot_oid])] = (row[used_oid], row[free_oid]) - defer.returnValue(result) + return result diff --git a/python/nav/mibs/old_cisco_cpu_mib.py b/python/nav/mibs/old_cisco_cpu_mib.py index 9940c1d1c4..a873ed71e4 100644 --- a/python/nav/mibs/old_cisco_cpu_mib.py +++ b/python/nav/mibs/old_cisco_cpu_mib.py @@ -27,7 +27,7 @@ def get_cpu_loadavg(self): avgbusy1 = yield self.get_next('avgBusy1') if avgbusy5 or avgbusy1: result = dict(cpu=[(5, avgbusy5), (1, avgbusy1)]) - defer.returnValue(result) + return result def get_cpu_utilization(self): return defer.succeed(None) diff --git a/python/nav/mibs/pdu2_mib.py b/python/nav/mibs/pdu2_mib.py index f7d55779a1..7c2a2bb583 100644 --- a/python/nav/mibs/pdu2_mib.py +++ b/python/nav/mibs/pdu2_mib.py @@ -17,7 +17,6 @@ """ from twisted.internet import defer -from twisted.internet.defer import returnValue from nav.smidumps import get_mib from nav.mibs.mibretriever import MibRetriever from nav.models.manage import Sensor @@ -75,7 +74,7 @@ def get_all_sensors(self): result += sensors result += yield self.get_inlet_pole_sensors(inlets) result += yield self.get_over_current_protection_sensors() - returnValue(result) + return result def retrieve_sensor_columns(self, table): columns = [fmt.format(table=table) for fmt in SENSOR_COLUMNS] @@ -128,7 +127,7 @@ def get_inlet_sensors(self): ) sensor = self.get_sensor(table, index, row, name, name, internal_name) result.append(sensor) - returnValue((result, inlets)) + return (result, inlets) @defer.inlineCallbacks def get_inlet_pole_sensors(self, inlets): @@ -155,7 +154,7 @@ def get_inlet_pole_sensors(self, inlets): ) sensor = self.get_sensor(table, index, row, name, name, internal_name) result.append(sensor) - returnValue(result) + return result @defer.inlineCallbacks def get_over_current_protection_sensors(self): @@ -183,4 +182,4 @@ def get_over_current_protection_sensors(self): if sensor_type == 'trip': sensor['unit_of_measurement'] = Sensor.UNIT_TRUTHVALUE result.append(sensor) - returnValue(result) + return result diff --git a/python/nav/mibs/power_ethernet_mib.py b/python/nav/mibs/power_ethernet_mib.py index 8e41d6abca..084798ed45 100644 --- a/python/nav/mibs/power_ethernet_mib.py +++ b/python/nav/mibs/power_ethernet_mib.py @@ -27,10 +27,10 @@ def get_groups_table(self): cols = yield self.retrieve_columns( ["pethMainPsePower", "pethMainPseOperStatus", "pethMainPseConsumptionPower"] ) - defer.returnValue(cols) + return cols @defer.inlineCallbacks def get_ports_table(self): """Retrieves PoE port information""" cols = yield self.retrieve_table("pethPsePortTable") - defer.returnValue(cols) + return cols diff --git a/python/nav/mibs/powernet_mib.py b/python/nav/mibs/powernet_mib.py index ca81c0e71f..0c369a5090 100644 --- a/python/nav/mibs/powernet_mib.py +++ b/python/nav/mibs/powernet_mib.py @@ -84,7 +84,7 @@ def get_all_sensors(self): ups_sensors = yield super(PowerNetMib, self).get_all_sensors() pdu_sensors = yield self._get_pdu_bank_load_sensors() result = ups_sensors + pdu_sensors - defer.returnValue(result) + return result @defer.inlineCallbacks def _get_pdu_bank_load_sensors(self): @@ -123,7 +123,7 @@ def _get_pdu_bank_load_sensors(self): mib=self.get_module_name(), ) ) - defer.returnValue(result) + return result @defer.inlineCallbacks def get_serial_number(self): @@ -134,4 +134,4 @@ def get_serial_number(self): if serial: if isinstance(serial, bytes): serial = serial.decode("utf-8") - defer.returnValue(serial) + return serial diff --git a/python/nav/mibs/pwt_3phase_mibv1.py b/python/nav/mibs/pwt_3phase_mibv1.py index 62829bddcb..7b5862857a 100644 --- a/python/nav/mibs/pwt_3phase_mibv1.py +++ b/python/nav/mibs/pwt_3phase_mibv1.py @@ -237,4 +237,4 @@ def get_all_sensors(self): method = getattr(self, handler) result.extend(method(sensors)) - defer.returnValue(result) + return result diff --git a/python/nav/mibs/qbridge_mib.py b/python/nav/mibs/qbridge_mib.py index 68abd71fad..266fda3c12 100644 --- a/python/nav/mibs/qbridge_mib.py +++ b/python/nav/mibs/qbridge_mib.py @@ -104,7 +104,7 @@ def get_forwarding_database(self): mac = ':'.join("%02x" % o for o in mac[-6:]) port = row['dot1qTpFdbPort'] result.append((mac, port)) - defer.returnValue(result) + return result @defer.inlineCallbacks def get_vlan_static_names(self): @@ -115,7 +115,7 @@ def get_vlan_static_names(self): for key, value in names.items(): if isinstance(value, str) and "\x00" in value: names[key] = value.replace("\x00", "") - defer.returnValue(names) + return names def filter_newest_current_entries(dot1qvlancurrenttable): diff --git a/python/nav/mibs/rittal_cmc_iii.py b/python/nav/mibs/rittal_cmc_iii.py index 9425f63702..001050cc52 100644 --- a/python/nav/mibs/rittal_cmc_iii.py +++ b/python/nav/mibs/rittal_cmc_iii.py @@ -19,7 +19,6 @@ import math from twisted.internet import defer -from twisted.internet.defer import returnValue from nav.smidumps import get_mib from nav.mibs.mibretriever import MibRetriever from nav.models.manage import Sensor @@ -79,7 +78,7 @@ def get_all_sensors(self): """Discovers and returns all eligible sensors from the device.""" devices = yield self.get_devices() sensors = yield self.get_sensors(devices) - returnValue(sensors) + return sensors @defer.inlineCallbacks def get_devices(self): @@ -87,7 +86,7 @@ def get_devices(self): ['cmcIIIDevName', 'cmcIIIDevAlias', 'cmcIIIDevNumberOfVars'] ) devices = self.translate_result(devices) - returnValue(devices) + return devices @defer.inlineCallbacks def get_sensors(self, devices): @@ -147,4 +146,4 @@ def get_sensors(self, devices): mib=self.get_module_name(), ) result.append(sensor) - returnValue(result) + return result diff --git a/python/nav/mibs/snmpv2_mib.py b/python/nav/mibs/snmpv2_mib.py index 9cd4f08003..8dbd4eaa6d 100644 --- a/python/nav/mibs/snmpv2_mib.py +++ b/python/nav/mibs/snmpv2_mib.py @@ -43,13 +43,13 @@ def _get_sysvariable(self, var): oid = self.nodes[var].oid result = yield self.get_next(var) if result: - defer.returnValue(result) + return result else: oid = oid + OID('0') result = yield self.agent_proxy.get([str(oid)]) for key, value in result.items(): if oid == OID(key): - defer.returnValue(value) + return value # pylint: disable=C0103 @@ -77,7 +77,7 @@ def get_timestamp_and_uptime(self): """ sysuptime = yield self._get_sysvariable('sysUpTime') timestamp = time.mktime(time.localtime()) - defer.returnValue((timestamp, sysuptime)) + return (timestamp, sysuptime) @staticmethod def get_uptime_deviation(first_uptime, second_uptime): diff --git a/python/nav/mibs/spagent_mib.py b/python/nav/mibs/spagent_mib.py index ab07f51df9..540801cc4d 100644 --- a/python/nav/mibs/spagent_mib.py +++ b/python/nav/mibs/spagent_mib.py @@ -111,7 +111,7 @@ def get_all_sensors(self): for table, config in TABLES[model_id].items(): sensors = yield self._get_sensors(config) result.extend(sensors) - defer.returnValue(result) + return result @defer.inlineCallbacks def _get_sensors(self, config): @@ -135,7 +135,7 @@ def _get_sensors(self, config): self._row_to_sensor(config, index, row) for index, row in result.items() ) - defer.returnValue([s for s in sensors if s]) + return [s for s in sensors if s] def _row_to_sensor(self, config, index, row): """ diff --git a/python/nav/mibs/statistics_mib.py b/python/nav/mibs/statistics_mib.py index b89d06c8af..3b05997095 100644 --- a/python/nav/mibs/statistics_mib.py +++ b/python/nav/mibs/statistics_mib.py @@ -35,7 +35,7 @@ def get_cpu_utilization(self): """Returns the current switch CPU utilization in percent""" util = yield self.get_next('hpSwitchCpuStat') if util is not None: - defer.returnValue(dict(cpu=util)) + return dict(cpu=util) def get_cpu_loadavg(self): return defer.succeed(None) @@ -64,4 +64,4 @@ def _split(item): IP('.'.join(str(i) for i in group)), ifindex, vlan, access ) - defer.returnValue([_split(i) for i in ports.items()]) + return [_split(i) for i in ports.items()] diff --git a/python/nav/mibs/ups_mib.py b/python/nav/mibs/ups_mib.py index fb524cdf0e..3610c75164 100644 --- a/python/nav/mibs/ups_mib.py +++ b/python/nav/mibs/ups_mib.py @@ -115,7 +115,7 @@ def get_all_sensors(self): sensor_params = yield self._get_named_column(sensor) result.extend(self._get_sensors(sensor, sensor_params)) - defer.returnValue(result) + return result def _get_sensors(self, object_name, sensor_params): result = [] diff --git a/python/nav/mibs/vrrp_mib.py b/python/nav/mibs/vrrp_mib.py index 2e34673ee9..7406ff5858 100644 --- a/python/nav/mibs/vrrp_mib.py +++ b/python/nav/mibs/vrrp_mib.py @@ -36,4 +36,4 @@ def get_virtual_addresses(self): ifindex, vrrp_id = index[:2] ipaddr = IP(".".join(str(o) for o in index[2:])) addr_map[ipaddr] = ifindex - defer.returnValue(addr_map) + return addr_map diff --git a/python/nav/mibs/wlsx_systemext_mib.py b/python/nav/mibs/wlsx_systemext_mib.py index 40a1558d71..07e094e13b 100644 --- a/python/nav/mibs/wlsx_systemext_mib.py +++ b/python/nav/mibs/wlsx_systemext_mib.py @@ -30,4 +30,4 @@ def get_serial_number(self): if serial: if isinstance(serial, bytes): serial = serial.decode("utf-8") - defer.returnValue(serial) + return serial