Lehel44 commented on a change in pull request #5088:
URL: https://github.com/apache/nifi/pull/5088#discussion_r637163865



##########
File path: 
nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/main/java/org/apache/nifi/snmp/processors/SendTrapSNMP.java
##########
@@ -0,0 +1,269 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.snmp.processors;
+
+import org.apache.nifi.annotation.behavior.InputRequirement;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnScheduled;
+import org.apache.nifi.components.AllowableValue;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.Relationship;
+import org.apache.nifi.processor.util.StandardValidators;
+import org.apache.nifi.reporting.InitializationException;
+import org.apache.nifi.snmp.configuration.TrapConfiguration;
+import org.apache.nifi.snmp.configuration.TrapV1Configuration;
+import org.apache.nifi.snmp.configuration.TrapV2cV3Configuration;
+import org.apache.nifi.snmp.utils.SNMPUtils;
+import org.snmp4j.mp.SnmpConstants;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Receiving data from configured SNMP agent which, upon each invocation of
+ * {@link #onTrigger(ProcessContext, ProcessSession)} method, will construct a
+ * {@link FlowFile} containing in its properties the information retrieved.
+ * The output {@link FlowFile} won't have any content.
+ */
+@Tags({"snmp", "send", "trap"})
+@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN)
+@CapabilityDescription("Sends information to SNMP Manager.")
+public class SendTrapSNMP extends AbstractSNMPProcessor {
+
+    public static final AllowableValue GENERIC_TRAP_TYPE_0 = new 
AllowableValue("0", "Cold Start",
+            "A coldStart trap signifies that the sending protocol entity is 
reinitializing itself such that" +
+                    " the agent's configuration or the protocol entity 
implementation may be altered.");
+
+    public static final AllowableValue GENERIC_TRAP_TYPE_1 = new 
AllowableValue("1", "Warm Start",
+            "A warmStart trap signifies that the sending protocol entity is 
reinitializing itself such that" +
+                    " neither the agent configuration nor the protocol entity 
implementation is altered.");
+
+    public static final AllowableValue GENERIC_TRAP_TYPE_2 = new 
AllowableValue("2", "Link Down",
+            "A linkDown trap signifies that the sending protocol entity 
recognizes a failure in one of " +
+                    "the communication links represented in the agent's 
configuration.");
+
+    public static final AllowableValue GENERIC_TRAP_TYPE_3 = new 
AllowableValue("3", "Link Up",
+            "A linkUp trap signifies that the sending protocol entity 
recognizes that one of the communication " +
+                    "links represented in the agent's configuration has come 
up.");
+
+    public static final AllowableValue GENERIC_TRAP_TYPE_4 = new 
AllowableValue("4", "Authentication Failure",
+            "An authenticationFailure trap signifies that the sending protocol 
entity is the addressee of a " +
+                    "protocol message that is not properly authenticated.  
While implementations of the SNMP must be " +
+                    "capable of generating this trap, they must also be 
capable of suppressing the emission of such traps " +
+                    "via an implementation- specific mechanism.");
+
+    public static final AllowableValue GENERIC_TRAP_TYPE_5 = new 
AllowableValue("5", "EGP Neighbor Loss",
+            "An egpNeighborLoss trap signifies that an EGP neighbor for whom 
the sending protocol entity was " +
+                    "an EGP peer has been marked down and the peer 
relationship no longer obtains.");
+
+    public static final AllowableValue GENERIC_TRAP_TYPE_6 = new 
AllowableValue("6", "Enterprise Specific",
+            "An enterpriseSpecific trap signifies that a particular 
enterprise-specific trap has occurred which " +
+                    "can be defined in the Specific Trap Type field.");
+
+    public static final PropertyDescriptor SNMP_MANAGER_HOST = new 
PropertyDescriptor.Builder()
+            .name("snmp-trap-manager-host")
+            .displayName("SNMP Manager Host")
+            .description("The host where the SNMP Manager sends the trap.")
+            .required(true)
+            .defaultValue("localhost")
+            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+            .build();
+
+    public static final PropertyDescriptor SNMP_MANAGER_PORT = new 
PropertyDescriptor.Builder()
+            .name("snmp-trap-manager-port")
+            .displayName("SNMP Manager Port")
+            .description("The port where the SNMP Manager listens to the 
incoming traps.")
+            .required(true)
+            .defaultValue("0")
+            .addValidator(StandardValidators.PORT_VALIDATOR)

Review comment:
       Yes it is, but unless it's changed, it seems that defaults are not 
validated.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to