/*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
package org.opendaylight.genius.itm.cli;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.math.BigInteger;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
/**
* The Class which implements karaf command "vtep:schema-show".
*/
private String schemaName;
private static String VTEP_CONFIG_SCHEMA_CLI_FORMAT = "%-14s %-12s %-8s %-16s %-13s %-14s %-11s %-20s %-32s";
- public static final String HEADER_UNDERLINE = "---------------------------------------------------------------------------------------------------------------------------------------";
+ public static final String HEADER_UNDERLINE = "------------------------------------------------------------------"
+ + "---------------------------------------------------------------------";
/** The Constant logger. */
private static final Logger LOG = LoggerFactory.getLogger(VtepSchemaShow.class);
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.karaf.shell.console.AbstractAction#doExecute()
*/
+ @SuppressWarnings("checkstyle:IllegalCatch")
@Override
protected Object doExecute() {
LOG.debug("Executing command: schema-show {} ", this.schemaName);
* the schema
*/
private void printSchema(VtepConfigSchema schema) {
- List<BigInteger> lstDpnIds = (schema.getDpnIds() == null) ? Collections.<BigInteger> emptyList()
+ List<BigInteger> lstDpnIds = (schema.getDpnIds() == null) ? Collections.emptyList()
: ItmUtils.getDpnIdList(schema.getDpnIds());
List<String> lstIpFilter = getExcludeIpFilterAsList(schema.getExcludeIpFilter());
String portName = StringUtils.defaultString(schema.getPortName());
String vlanId = String.valueOf(schema.getVlanId());
String subnetCIDR = (schema.getSubnet() == null) ? StringUtils.EMPTY
- : String.valueOf(schema.getSubnet().getValue());
+ : schema.getSubnet().stringValue();
String gatewayIp = (schema.getGatewayIp() == null) ? StringUtils.EMPTY
- : String.valueOf(schema.getGatewayIp().getValue());
+ : schema.getGatewayIp().stringValue();
String transportZone = StringUtils.defaultString(schema.getTransportZoneName());
String strTunnelType ;
Class<? extends TunnelTypeBase> tunType = schema.getTunnelType();
- if( tunType.equals(TunnelTypeGre.class) )
- strTunnelType = ITMConstants.TUNNEL_TYPE_GRE ;
- else
- strTunnelType = ITMConstants.TUNNEL_TYPE_VXLAN ;
+ if (TunnelTypeGre.class.equals(tunType)) {
+ strTunnelType = ITMConstants.TUNNEL_TYPE_GRE;
+ } else {
+ strTunnelType = ITMConstants.TUNNEL_TYPE_VXLAN;
+ }
String dpnId = (dpnIterator.hasNext() ? String.valueOf(dpnIterator.next()) : StringUtils.EMPTY);
String excludeIpFilter = (ipFilterIterator.hasNext() ? String.valueOf(ipFilterIterator.next())
: StringUtils.EMPTY);
// Print first row
- session.getConsole().println(String.format(VTEP_CONFIG_SCHEMA_CLI_FORMAT, schema.getSchemaName(), portName, vlanId,
- subnetCIDR, gatewayIp, transportZone, strTunnelType, dpnId, excludeIpFilter));
+ session.getConsole().println(String.format(VTEP_CONFIG_SCHEMA_CLI_FORMAT, schema.getSchemaName(),
+ portName, vlanId, subnetCIDR, gatewayIp, transportZone, strTunnelType, dpnId, excludeIpFilter));
while (dpnIterator.hasNext() || ipFilterIterator.hasNext()) {
dpnId = (dpnIterator.hasNext() ? String.valueOf(dpnIterator.next()) : StringUtils.EMPTY);
excludeIpFilter = (ipFilterIterator.hasNext() ? String.valueOf(ipFilterIterator.next())
: StringUtils.EMPTY);
- session.getConsole().println(String.format(VTEP_CONFIG_SCHEMA_CLI_FORMAT, StringUtils.EMPTY, StringUtils.EMPTY,
+ session.getConsole().println(String.format(VTEP_CONFIG_SCHEMA_CLI_FORMAT, StringUtils.EMPTY,
StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY,
- dpnId, excludeIpFilter));
+ StringUtils.EMPTY, dpnId, excludeIpFilter));
}
session.getConsole().println(System.lineSeparator());
}
* @return the vtep config schema header output
*/
private String getHeaderOutput() {
- StringBuilder headerBuilder = new StringBuilder();
- headerBuilder.append(String.format(VTEP_CONFIG_SCHEMA_CLI_FORMAT, "SchemaName", "PortName", "VlanID", "Subnet",
- "GatewayIP", "TransportZone", "TunnelType", "DPN-IDS", "ExcludeIpFilter"));
- headerBuilder.append('\n');
- headerBuilder.append(HEADER_UNDERLINE);
- return headerBuilder.toString();
+ String headerBuilder =
+ String.format(VTEP_CONFIG_SCHEMA_CLI_FORMAT, "SchemaName", "PortName", "VlanID", "Subnet", "GatewayIP",
+ "TransportZone", "TunnelType", "DPN-IDS", "ExcludeIpFilter") + '\n' + HEADER_UNDERLINE;
+ return headerBuilder;
}
}