Skip to content

Commit f3b6fa8

Browse files
committed
changed the way we retrieve snmp-server community details
1 parent a701182 commit f3b6fa8

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

cloudshell/networking/cisco/flows/cisco_disable_snmp_flow.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ def execute_flow(self, snmp_parameters=None):
5252
raise Exception(self.__class__.__name__, "Failed to remove SNMP v3 Configuration." +
5353
" Please check Logs for details")
5454
else:
55-
updated_snmp_communities = updated_snmp_actions.get_current_snmp_communities()
56-
if snmp_parameters.snmp_community in updated_snmp_communities:
55+
updated_snmp_communities = updated_snmp_actions.get_current_snmp_config()
56+
if re.search("snmp-server community {}".format(snmp_parameters.snmp_community),
57+
updated_snmp_communities):
5758
raise Exception(self.__class__.__name__, "Failed to remove SNMP community." +
5859
" Please check Logs for details")

cloudshell/networking/cisco/flows/cisco_enable_snmp_flow.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/python
22
# -*- coding: utf-8 -*-
3+
import re
34

45
from cloudshell.devices.flows.cli_action_flows import EnableSnmpFlow
56
from cloudshell.networking.cisco.command_actions.enable_disable_snmp_actions import EnableDisableSnmpActions
@@ -69,9 +70,10 @@ def execute_flow(self, snmp_parameters):
6970
snmp_group=None)
7071

7172
else:
72-
current_snmp_communities = snmp_actions.get_current_snmp_communities()
73+
current_snmp_communities = snmp_actions.get_current_snmp_config()
7374
snmp_community = snmp_parameters.snmp_community
74-
if snmp_community not in current_snmp_communities:
75+
if not re.search("snmp-server community {}".format(snmp_parameters.snmp_community),
76+
current_snmp_communities):
7577
snmp_actions.enable_snmp(snmp_community, read_only_community)
7678
else:
7779
self._logger.debug("SNMP Community '{}' already configured".format(snmp_community))
@@ -85,8 +87,9 @@ def execute_flow(self, snmp_parameters):
8587
raise Exception(self.__class__.__name__, "Failed to create SNMP v3 Configuration." +
8688
" Please check Logs for details")
8789
else:
88-
updated_snmp_communities = updated_snmp_actions.get_current_snmp_communities()
89-
if snmp_parameters.snmp_community not in updated_snmp_communities:
90+
updated_snmp_communities = updated_snmp_actions.get_current_snmp_config()
91+
if not re.search("snmp-server community {}".format(snmp_parameters.snmp_community),
92+
updated_snmp_communities):
9093
raise Exception(self.__class__.__name__, "Failed to create SNMP community." +
9194
" Please check Logs for details")
9295

0 commit comments

Comments
 (0)