Skip to content

Commit a69d192

Browse files
lolarsonGitHub Enterprise
authored andcommitted
master branch has more up to date SNMPAgent (#10)
pulled in from master to update develop
1 parent 5315a42 commit a69d192

File tree

1 file changed

+12
-42
lines changed

1 file changed

+12
-42
lines changed

smc/elements/profiles.py

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -225,41 +225,15 @@ def dns_answer_translation(self):
225225

226226
class SNMPAgent(Element):
227227
"""
228-
SNMPAgent configuration for monitoring specifics on NGFW.
228+
Minimal implementation of SNMPAgent
229229
"""
230230
typeof = 'snmp_agent'
231-
231+
232232
@classmethod
233-
def create(cls, name, snmp_monitoring_contact=None,
234-
snmp_monitoring_user_name=None, snmp_user_name=None,
235-
snmp_monitoring_listening_port=161,
236-
snmp_version='v3', comment=None):
237-
"""
238-
Create a new SNMPAgent. If specifying v2c or v3, you can optionally
239-
specify snmp_user_name as a list along with snmp_authentication_protocol
240-
and snmp_privacy_protocol, otherwise defaults will be selected.
241-
The simplest way to create an SNMP Agent is as follows::
242-
243-
SNMPAgent.update_or_create(name='MyAgent')
244-
245-
To customize v3 settings around authentication and privacy protocols
246-
you can do::
247-
248-
SNMPAgent.create(name='MyAgent123', snmp_monitoring_user_name=['myuser'],
249-
snmp_user_name=[{'name': 'myuser', 'snmp_authentication_password': 'abcd1234',
250-
'snmp_authentication_protocol': 'md5', 'snmp_privacy_protocol': 'aes',
251-
'snmp_private_password': 'abcd1234'}])
252-
253-
..note:: Check the SMC documentation for additional valid fields.
254-
255-
:param str name: name of agent
256-
:param str snmp_monitoring_contact: name of monitoring contact
257-
:param list snmp_monitoring_user_name: monitoring communities
258-
:param list snmp_user_name: SNMP username required when specifying v2c or v3
259-
:param int snmp_monitoring_listening_port: default port 161
260-
:param str snmp_version: version of snmp, v1, v2c, or v3, default v3
261-
:param str comment: optional comment
262-
"""
233+
def create(cls, name, snmp_users=[], trap_destinations=[], snmp_monitoring_contact=None,
234+
snmp_monitoring_listening_port=161, snmp_version='v3',
235+
monitoring_user_names=[], trap_user_names=[], comment=None):
236+
263237
json = {'boot': False,
264238
'go_offline': False,
265239
'go_online': False,
@@ -269,18 +243,14 @@ def create(cls, name, snmp_monitoring_contact=None,
269243
'shutdown': False,
270244
'snmp_monitoring_contact': snmp_monitoring_contact,
271245
'snmp_monitoring_listening_port': snmp_monitoring_listening_port,
272-
'snmp_monitoring_user_name': snmp_monitoring_user_name or ['public'],
273-
'snmp_trap_destination': [],
274-
'snmp_user_name': snmp_user_name or [],
246+
'snmp_monitoring_user_name': monitoring_user_names,
247+
'snmp_trap_destination': trap_destinations,
248+
'snmp_user_name': snmp_users,
275249
'snmp_version': snmp_version,
276-
'user_login': False,
277-
'comment': comment}
278-
279-
if not snmp_user_name: # Username not set, use defaults
280-
json.update(snmp_user_name=[{'name': 'public', 'snmp_authentication_protocol': 'none',
281-
'snmp_privacy_protocol': 'none'}])
250+
'user_login': False}
251+
282252
return ElementCreator(cls, json)
283-
253+
284254

285255
class SandboxService(Element):
286256
typeof = 'sandbox_service'

0 commit comments

Comments
 (0)