dceed36b2d0587530f01eefa60167ae857eff1a7
[netvirt.git] / qosservice / impl / src / main / java / org / opendaylight / netvirt / qosservice / QosAlertThresholdCLI.java
1 /*
2  * Copyright (c) 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.netvirt.qosservice;
10
11 import javax.annotation.Nullable;
12 import org.apache.karaf.shell.commands.Argument;
13 import org.apache.karaf.shell.commands.Command;
14 import org.apache.karaf.shell.console.OsgiCommandSupport;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
17
18 @Command(scope = "qos", name = "drop-packet-threshold", description = "configure drop packet threshold in %")
19 public class QosAlertThresholdCLI extends OsgiCommandSupport {
20
21     @Argument(index = 0, name = "<threshold>", description = "threshold value in % 1..100",
22             required = true, multiValued = false)
23     private String threshold;
24
25     private static final Logger LOG = LoggerFactory.getLogger(QosAlertThresholdCLI.class);
26
27     private QosAlertManager qosAlertManager;
28
29     public void setQosAlertManager(QosAlertManager qosAlertManager) {
30         this.qosAlertManager = qosAlertManager;
31         LOG.trace("Qos manager:{} set", qosAlertManager);
32     }
33
34     @Override
35     @Nullable
36     protected Object doExecute() {
37         LOG.debug("setting threshold in qos alert manager:{}", threshold);
38         qosAlertManager.setThreshold(Short.parseShort(threshold));
39         return null;
40     }
41
42 }