Vxlan/Gre co-existence,Alarms,tunnelstate,TR fixes
[vpnservice.git] / itm / itm-impl / src / main / java / org / opendaylight / vpnservice / itm / cli / TepMonitor.java
1 /*
2  * Copyright (c) 2016 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 package org.opendaylight.vpnservice.itm.cli;
9
10 import org.apache.karaf.shell.commands.Argument;
11 import org.apache.karaf.shell.commands.Command;
12 import org.apache.karaf.shell.console.OsgiCommandSupport;
13 import org.opendaylight.vpnservice.itm.api.IITMProvider;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
16
17 @Command(scope = "tep", name = "monitor-interval", description = "configuring tunnel monitoring time interval")
18 public class TepMonitor extends OsgiCommandSupport {
19
20   @Argument(index = 0, name = "interval", description = "monitoring interval", required = true,
21       multiValued = false)
22   private Integer interval;
23
24   private static final Logger logger = LoggerFactory.getLogger(TepMonitor.class);
25   private IITMProvider itmProvider;
26
27   public void setItmProvider(IITMProvider itmProvider) {
28     this.itmProvider = itmProvider;
29   }
30
31   @Override
32   protected Object doExecute() {
33     try {
34       logger.debug("Executing TEP monitor command with interval: " + "\t" + interval);
35       if(!(interval >= 5 && interval <=30)){
36           System.out.println("Monitoring Interval must be in the range 5 - 30");
37       }
38       else {
39           itmProvider.configureTunnelMonitorInterval(interval);
40       }
41     } catch (Exception e) {
42       e.printStackTrace();
43     }
44     return null;
45   }
46 }