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
9 package org.opendaylight.vpnservice.itm.cli;
11 import org.apache.commons.lang3.StringUtils;
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;
20 * The Class which implements karaf command "vtep:schema-delete".
22 @Command(scope = "vtep", name = "schema-delete", description = "Delete VTEP schema.")
23 public class VtepSchemaDelete extends OsgiCommandSupport {
25 private static final String ALL = "all";
27 @Argument(index = 0, name = ALL, description = "Delete all VTEP schemas", required = true, multiValued = false)
28 String deleteAll = null;
30 /** The Constant logger. */
31 private static final Logger LOG = LoggerFactory.getLogger(VtepSchemaDelete.class);
33 /** The itm provider. */
34 private IITMProvider itmProvider;
37 * Sets the itm provider.
40 * the new itm provider
42 public void setItmProvider(IITMProvider itmProvider) {
43 this.itmProvider = itmProvider;
46 private void usage() {
47 System.out.println("usage: vtep:schema-delete all");
53 * @see org.apache.karaf.shell.console.AbstractAction#doExecute()
56 protected Object doExecute() {
58 if (this.deleteAll == null || !StringUtils.equalsIgnoreCase(ALL, this.deleteAll)) {
62 LOG.debug("Executing vtep:schema-delete command\t {} ", this.deleteAll);
63 this.itmProvider.deleteAllVtepSchemas();
65 } catch (IllegalArgumentException e) {
66 System.out.println(e.getMessage());
67 } catch (Exception e) {
68 LOG.error("Exception occurred during execution of command \"vtep:schema-delete all\": ", e);