...
 
Commits (2)
......@@ -94,7 +94,9 @@ class Command(BaseCommand):
create_test_case_parser.add_argument("--test-storage", help="External storage name")
create_test_case_parser.add_argument("--test-path", type=smart_text, help="Path name")
create_test_case_parser.add_argument("--config-storage", help="External storage name")
create_test_case_parser.add_argument("--config-path", default="/", help="Path name")
create_test_case_parser.add_argument(
"--config-path", type=smart_text, default="/", help="Path name"
)
create_test_case_parser.add_argument(
"--build", action="store_true", default=False, help="Build test case after create"
)
......
......@@ -16,6 +16,7 @@ import codecs
from noc.core.script.base import BaseScript
from noc.sa.interfaces.igetbeef import IGetBeef
from noc.core.comp import smart_bytes
from noc.core.snmp.error import SNMPError
class Script(BaseScript):
......@@ -103,12 +104,20 @@ class Script(BaseScript):
def collect_snmp(self, spec):
# Collect
for ans in spec["answers"]:
if ans["type"] == "snmp-get":
value = self.snmp.get(ans["value"], raw_varbinds=True)
yield {"oid": str(ans["value"]), "value": self.encode_mib(value).strip()}
elif ans["type"] == "snmp-getnext":
for oid, value in self.snmp.getnext(ans["value"], raw_varbinds=True, max_retries=2):
yield {"oid": str(oid), "value": self.encode_mib(value).strip()}
try:
if ans["type"] == "snmp-get":
value = self.snmp.get(ans["value"], raw_varbinds=True)
yield {
"oid": str(ans["value"]),
"value": self.encode_mib(value).strip(),
}
elif ans["type"] == "snmp-getnext":
for oid, value in self.snmp.getnext(
ans["value"], raw_varbinds=True, max_retries=2
):
yield {"oid": str(oid), "value": self.encode_mib(value).strip()}
except SNMPError:
continue
def get_snmp_results(self, spec):
r = []
......