Vxlan/Gre co-existence,Alarms,tunnelstate,TR fixes
[vpnservice.git] / itm / itm-impl / src / main / java / org / opendaylight / vpnservice / itm / cli / TepAdd.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 java.math.BigInteger;
11
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.opendaylight.vpnservice.itm.api.IITMProvider;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18
19 @Command(scope = "tep", name = "add", description = "adding a tunnel end point")
20 public class TepAdd extends OsgiCommandSupport {
21
22     @Argument(index = 0, name = "dpnId", description = "DPN-ID", required = false, multiValued = false)
23     private BigInteger dpnId;
24     @Argument(index = 1, name = "portNo", description = "port-name", required = false, multiValued = false)
25     private String portName;
26     @Argument(index = 2, name = "vlanId", description = "vlan-id", required = false, multiValued = false)
27     private Integer vlanId;
28     @Argument(index = 3, name = "ipAddress", description = "ip-address", required = false, multiValued = false)
29     private String ipAddress;
30     @Argument(index = 4, name = "subnetMask", description = "subnet-Mask", required = false, multiValued = false)
31     private String subnetMask;
32     @Argument(index = 5, name = "gatewayIp", description = "gateway-ip", required = false, multiValued = false)
33     private String gatewayIp;
34     @Argument(index = 6, name = "transportZone", description = "transport_zone", required = false, multiValued = false)
35     private String transportZone;
36     private static final Logger LOG = LoggerFactory.getLogger(TepAdd.class);
37     private IITMProvider itmProvider;
38
39     public void setItmProvider(IITMProvider itmProvider) {
40         this.itmProvider = itmProvider;
41     }
42
43     @Override
44     protected Object doExecute() {
45         try {
46             if (dpnId == null || portName == null || vlanId == null || ipAddress == null || subnetMask == null
47                             || transportZone == null) {
48                 System.out.println("Insufficient Arguments");
49                 System.out.println("Correct Usage : exec tep-add dpnId portName vlanId ipAddress subnetMask gatewayIp transportZone");
50                 return null;
51             }
52             LOG.debug("Executing create TEP command" + "\t" + dpnId + "\t" + portName + "\t" + vlanId + "\t"
53                             + ipAddress + "\t" + subnetMask + "\t" + gatewayIp + "\t" + transportZone);
54             itmProvider.createLocalCache(dpnId, portName, vlanId, ipAddress, subnetMask, gatewayIp, transportZone);
55         } catch (IllegalArgumentException e) {
56             System.out.println(e.getMessage());
57         } catch (Exception e) {
58             System.out.println(e.getMessage());
59             LOG.error("Exception occurred during execution of command \"tep-add\": ", e);
60         }
61         return null;
62     }
63 }