2 * Copyright (c) 2015 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.util.regex.Matcher;
11 import java.util.regex.Pattern;
12 import java.math.BigInteger;
14 import org.apache.karaf.shell.commands.Argument;
15 import org.apache.karaf.shell.commands.Command;
16 import org.apache.karaf.shell.console.OsgiCommandSupport;
17 import org.opendaylight.genius.itm.api.IITMProvider;
18 import org.opendaylight.genius.itm.globals.ITMConstants;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeGre;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeMplsOverGre;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
27 * Created by echiapt on 7/5/2016.
29 @Command(scope = "tep", name = "rem-external-endpoint", description = "removing an external endpoint")
30 public class RemoveExternalEndpoint extends OsgiCommandSupport {
31 @Argument(index = 0, name = "destination-ip", description = "Destination-IP", required = true, multiValued = false)
32 private String destinationIp;
33 @Argument(index = 1, name = "TunnelType", description = "Tunnel-Type", required = true, multiValued = false)
34 private String tunnelType;
36 private static final Logger LOG = LoggerFactory.getLogger(RemoveExternalEndpoint.class);
37 private IITMProvider itmProvider;
39 public void setItmProvider(IITMProvider itmProvider) {
40 this.itmProvider = itmProvider;
44 protected Object doExecute() {
46 LOG.debug("RemoveExternalEndpoint: destinationIP {} with tunnelType {}", destinationIp, tunnelType);
47 Class<? extends TunnelTypeBase> tunType = TunnelTypeVxlan.class;
48 if( tunnelType.toUpperCase().equals(ITMConstants.TUNNEL_TYPE_VXLAN))
49 tunType = TunnelTypeVxlan.class ;
50 else if( tunnelType.toUpperCase().equals(ITMConstants.TUNNEL_TYPE_GRE) )
51 tunType = TunnelTypeGre.class ;
52 else if (tunnelType.toUpperCase().equals(ITMConstants.TUNNEL_TYPE_MPLSoGRE)) {
53 tunType = TunnelTypeMplsOverGre.class;
55 System.out.println("Invalid tunnel-type " + tunnelType);
59 if (!itmProvider.validateIP(destinationIp)) {
60 System.out.println("Invalid IpAddress " + destinationIp);
64 IpAddress dcgwIPAddr = new IpAddress(destinationIp.toCharArray());
65 itmProvider.remExternalEndpoint(tunType, dcgwIPAddr);
66 } catch (IllegalArgumentException e) {
67 System.out.println(e.getMessage());
68 } catch (Exception e) {
69 System.out.println(e.getMessage());
70 LOG.error("Exception occurred during execution of command \"tep:configure-tunnelType\": ", e);