2 * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
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
8 package org.opendaylight.genius.itm.cli;
10 import java.math.BigInteger;
11 import org.apache.karaf.shell.commands.Argument;
12 import org.apache.karaf.shell.commands.Command;
13 import org.apache.karaf.shell.console.OsgiCommandSupport;
14 import org.opendaylight.genius.itm.api.IITMProvider;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
18 @Command(scope = "tep", name = "add", description = "adding a tunnel end point")
19 public class TepAdd extends OsgiCommandSupport {
21 @Argument(index = 0, name = "dpnId", description = "DPN-ID", required = false, multiValued = false)
22 private BigInteger dpnId;
23 @Argument(index = 1, name = "portNo", description = "port-name", required = false, multiValued = false)
24 private String portName;
25 @Argument(index = 2, name = "vlanId", description = "vlan-id", required = false, multiValued = false)
26 private Integer vlanId;
27 @Argument(index = 3, name = "ipAddress", description = "ip-address", required = false, multiValued = false)
28 private String ipAddress;
29 @Argument(index = 4, name = "subnetMask", description = "subnet-Mask", required = false, multiValued = false)
30 private String subnetMask;
31 @Argument(index = 5, name = "gatewayIp", description = "gateway-ip", required = false, multiValued = false)
32 private String gatewayIp;
33 @Argument(index = 6, name = "transportZone", description = "transport_zone", required = false, multiValued = false)
34 private String transportZone;
35 private static final Logger LOG = LoggerFactory.getLogger(TepAdd.class);
36 private IITMProvider itmProvider;
38 public void setItmProvider(IITMProvider itmProvider) {
39 this.itmProvider = itmProvider;
42 @SuppressWarnings("checkstyle:IllegalCatch")
44 protected Object doExecute() {
46 if (dpnId == null || portName == null || vlanId == null || ipAddress == null || subnetMask == null
47 || transportZone == null) {
48 session.getConsole().println("Insufficient Arguments");
49 session.getConsole().println("Correct Usage : exec tep-add dpnId portName vlanId ipAddress subnetMask "
50 + "gatewayIp transportZone");
53 LOG.debug("Executing create TEP command dpnId={}, portName={}, vlanId={}, ipAddress={},"
54 + " subnetMask={}, gatewayIp={}, transportZone={}", dpnId, portName, vlanId, ipAddress,
55 subnetMask, gatewayIp, transportZone);
56 itmProvider.createLocalCache(dpnId, portName, vlanId, ipAddress, subnetMask, gatewayIp,
58 } catch (Exception e) {
59 LOG.error("Exception occurred during execution of command \"tep-add\"", e);