aboutsummaryrefslogtreecommitdiffstats
path: root/profiles/snmp/src
diff options
context:
space:
mode:
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2018-02-21 10:27:26 +0530
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2018-02-21 10:27:26 +0530
commit3903891dfe8f9e2488fc9d1bd0858fa4670cff0e (patch)
treed5e27c63d4e4a640841df49f0d8ce58ed2f35fb4 /profiles/snmp/src
parentb24c44159cdfc5fb3417890d84f6074a6cd02f78 (diff)
Throw error when SNMP command failed
Issue-ID: CLI-92 Change-Id: Ib6da4a647ea9cd25dd5e156cd58f4c21299efb9e Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'profiles/snmp/src')
-rw-r--r--profiles/snmp/src/main/java/org/onap/cli/fw/snmp/cmd/OnapSnmpCommand.java27
1 files changed, 16 insertions, 11 deletions
diff --git a/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/cmd/OnapSnmpCommand.java b/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/cmd/OnapSnmpCommand.java
index 6bdc9a03..1ee1b200 100644
--- a/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/cmd/OnapSnmpCommand.java
+++ b/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/cmd/OnapSnmpCommand.java
@@ -120,18 +120,23 @@ public class OnapSnmpCommand extends OnapCommand {
case OnapCommandSnmpConstants.SNMP_CMD_GET:
ResponseEvent responseEvent = snmp.send(getPDU(PDU.GET, oidStrArr), getTarget(), null);
- if ( responseEvent != null && responseEvent.getResponse().getErrorStatus() == PDU.noError) {
- Vector<? extends VariableBinding> variableBindings = responseEvent.getResponse().getVariableBindings();
- variableBindings.stream().forEach(varBinding -> { //NOSONAR
- String key = getKeyForValue(varBinding.getOid().toString());
- if (key != null) {
- this.getResult().getRecordsMap().get(key).getValues().add(
- varBinding.getVariable().toString());
- }
- });
- } else {
- throw new OnapSnmpErrorResponse("Error response from SNMP agent",
+ if ( responseEvent != null) {
+ if (responseEvent.getResponse().getErrorStatus() == PDU.noError) {
+ Vector<? extends VariableBinding> variableBindings = responseEvent.
+ getResponse().getVariableBindings();
+ variableBindings.stream().forEach(varBinding -> { //NOSONAR
+ String key = getKeyForValue(varBinding.getOid().toString());
+ if (key != null) {
+ this.getResult().getRecordsMap().get(key).getValues().add(
+ varBinding.getVariable().toString());
+ }
+ });
+ } else {
+ throw new OnapSnmpErrorResponse("Error response from SNMP agent",
responseEvent.getResponse().getErrorStatus());
+ }
+ } else {
+ throw new OnapSnmpErrorResponse("Failed to send SNMP GET command");
}
break;