chore(release): 0.18.0 #85
No files matched your search
@@ -13,6 +13,7 @@ from typing import TYPE_CHECKING, Literal
|
||||
|
||||
from napalm_device_types import (
|
||||
OPENED_PORTS_RECORD,
|
||||
SNMP_PURPOSE,
|
||||
FixStepOutcomeDict,
|
||||
OpenedRuleDict,
|
||||
opened_rule_line,
|
||||
@@ -24,6 +25,7 @@ from napalm_device_types import (
|
||||
ufw_allow_recorded_command,
|
||||
ufw_delete_command,
|
||||
)
|
||||
from napalm_device_types.models import SnmpAgentSettingsDict
|
||||
|
||||
from napalm_linux._snmp_agent import (
|
||||
_source,
|
||||
@@ -83,7 +85,7 @@ def _count_command(firewall: Firewall, port: int, proto: str) -> str:
|
||||
|
||||
|
||||
class OpenPortMixin:
|
||||
"""``_allow_sources`` and ``_revoke_sources``: the shared firewall steps."""
|
||||
"""``_allow_sources`` and ``_revoke_sources``: the shared firewall steps, and SNMP's."""
|
||||
|
||||
def _firewall(self) -> Firewall:
|
||||
"""The firewall this host runs. firewalld first: its hosts have iptables too, and
|
||||
@@ -120,6 +122,10 @@ class OpenPortMixin:
|
||||
done = f"{proto}/{port} open for {', '.join(sources)}"
|
||||
return self._root_outcome(" && ".join(rules), 30, done)
|
||||
|
||||
def _allow_snmp_sources(self, settings: SnmpAgentSettingsDict) -> FixStepOutcomeDict:
|
||||
"""SNMP's firewall step (napalm-device-types ``SnmpAgentMixin``): udp/161."""
|
||||
return self._allow_sources(settings.get("allowed_sources", []), 161, "udp", SNMP_PURPOSE)
|
||||
|
||||
def _revoke_sources(self, purpose: str, port: int, proto: str) -> FixStepOutcomeDict:
|
||||
"""Remove the rules recorded under *purpose*, whatever port they opened, and
|
||||
nothing else; report what is left for *proto*/*port*.
|
||||
|
||||
@@ -30,7 +30,6 @@ from napalm_device_types import (
|
||||
DNF_INSTALLED_CVES_COMMAND,
|
||||
DNF_SECURITY_COMMAND,
|
||||
LLDPCTL_KEYVALUE_COMMAND,
|
||||
SNMP_PURPOSE,
|
||||
AptProxyMixin,
|
||||
ByteStream,
|
||||
CommandResult,
|
||||
@@ -1798,9 +1797,6 @@ class LinuxDriver(
|
||||
return {"ok": False, "output": (written.stdout or written.stderr).strip()[-300:]}
|
||||
return {"ok": True, "output": f"wrote {_SNMPD_CONF}"}
|
||||
|
||||
def _allow_snmp_sources(self, settings: SnmpAgentSettingsDict) -> FixStepOutcomeDict:
|
||||
return self._allow_sources(settings.get("allowed_sources", []), 161, "udp", SNMP_PURPOSE)
|
||||
|
||||
def _start_snmp_agent(self) -> FixStepOutcomeDict:
|
||||
return self._root_outcome(
|
||||
"systemctl enable snmpd && systemctl restart snmpd && systemctl is-active snmpd",
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"napalm_linux.linux"
|
||||
],
|
||||
"python_file_lines": {
|
||||
"napalm_linux/linux.py": 1993
|
||||
"napalm_linux/linux.py": 1990
|
||||
},
|
||||
"untyped_public": []
|
||||
}
|
||||
Reference in new issue
Block a user