2 * Copyright (c) 2016 Hewlett Packard Enterprise, Co. 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.netvirt.elan.cli.etree;
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.eclipse.jdt.annotation.Nullable;
14 import org.opendaylight.netvirt.elanmanager.api.IElanService;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInterface;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
20 @Command(scope = "etreeInterface", name = "delete", description = "deleting Etree Interface")
21 public class EtreeInterfaceDelete extends OsgiCommandSupport {
23 @Argument(index = 0, name = "etreeName", description = "ETREE-NAME", required = true, multiValued = false)
24 private String etreeName;
25 @Argument(index = 1, name = "interfaceName", description = "InterfaceName", required = true, multiValued = false)
26 private String interfaceName;
27 private static final Logger LOG = LoggerFactory.getLogger(EtreeInterfaceDelete.class);
28 private IElanService elanProvider;
30 public void setElanProvider(IElanService elanServiceProvider) {
31 this.elanProvider = elanServiceProvider;
36 protected Object doExecute() {
37 LOG.debug("Deleting EtreeInterface command etreeName:{}, interfaceName:{}", etreeName, interfaceName);
38 ElanInterface existingInterface =
39 elanProvider.getElanInterfaceByElanInterfaceName(interfaceName);
40 if (existingInterface == null || existingInterface.augmentation(EtreeInterface.class) == null) {
42 .println("Etree interface doesn't exist or isn't configured as etree: " + interfaceName);
44 elanProvider.deleteEtreeInterface(interfaceName);
45 session.getConsole().println("Deleted the Etree interface succesfully");