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