use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema in project genius by opendaylight.
the class VtepSchemaAdd method doExecute.
/*
* (non-Javadoc)
*
* @see org.apache.karaf.shell.console.AbstractAction#doExecute()
*/
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
protected Object doExecute() {
try {
if (this.schemaName == null || this.portName == null || this.vlanId == null || this.subnetCIDR == null || this.transportZone == null) {
usage();
return null;
}
LOG.debug("Executing vtep:schema-add command\t {} \t {} \t {} \t {} \t {} \t {} \t {} \t {} \t {}", schemaName, portName, vlanId, subnetCIDR, gatewayIp, transportZone, tunnelType, dpnIds, excludeIpFilter);
if (null == tunnelType) {
tunnelType = ITMConstants.TUNNEL_TYPE_VXLAN;
}
VtepConfigSchema schema = ItmUtils.constructVtepConfigSchema(schemaName, portName, vlanId, subnetCIDR, gatewayIp, transportZone, tunnelType, ItmCliUtils.constructDpnIdList(dpnIds), excludeIpFilter);
this.itmProvider.addVtepConfigSchema(schema);
} catch (Exception e) {
LOG.error("Exception occurred during execution of command \"vtep:schema-add\": ", e);
throw e;
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema in project genius by opendaylight.
the class VtepSchemaShow method doExecute.
/*
* (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);
try {
if (this.schemaName != null) {
VtepConfigSchema schema = this.itmProvider.getVtepConfigSchema(this.schemaName);
if (schema == null) {
session.getConsole().println("No VTEP schema present with name: " + this.schemaName);
} else {
session.getConsole().println(getHeaderOutput());
printSchema(schema);
}
} else {
printAllVtepSchemas();
}
} catch (Exception e) {
LOG.error("Exception occurred during execution of command \"vtep:schema-show\": ", e);
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema in project genius by opendaylight.
the class VtepSchemaShow method printAllVtepSchemas.
/**
* Prints all vtep schemas.
*/
private void printAllVtepSchemas() {
List<VtepConfigSchema> schemas = this.itmProvider.getAllVtepConfigSchemas();
if (schemas == null || schemas.isEmpty()) {
session.getConsole().println("No VTEP schemas present.");
return;
}
session.getConsole().println(getHeaderOutput());
for (VtepConfigSchema schema : schemas) {
printSchema(schema);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema in project genius by opendaylight.
the class ItmProvider method addVtepConfigSchema.
@Override
public void addVtepConfigSchema(VtepConfigSchema vtepConfigSchema) {
VtepConfigSchema validatedSchema = ItmUtils.validateForAddVtepConfigSchema(vtepConfigSchema, getAllVtepConfigSchemas());
String schemaName = validatedSchema.getSchemaName();
VtepConfigSchema existingSchema = getVtepConfigSchema(schemaName);
if (existingSchema != null) {
Preconditions.checkArgument(false, String.format("VtepConfigSchema [%s] already exists!", schemaName));
}
MDSALUtil.syncWrite(this.dataBroker, LogicalDatastoreType.CONFIGURATION, ItmUtils.getVtepConfigSchemaIdentifier(schemaName), validatedSchema);
LOG.debug("Vtep config schema {} added to config DS", schemaName);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema in project genius by opendaylight.
the class ItmUtils method validateVtepConfigSchema.
public static VtepConfigSchema validateVtepConfigSchema(VtepConfigSchema schema) {
Preconditions.checkNotNull(schema);
Preconditions.checkArgument(StringUtils.isNotBlank(schema.getSchemaName()));
Preconditions.checkArgument(StringUtils.isNotBlank(schema.getPortName()));
Preconditions.checkArgument(schema.getVlanId() >= 0 && schema.getVlanId() < 4095, "Invalid VLAN ID, range (0-4094)");
Preconditions.checkArgument(StringUtils.isNotBlank(schema.getTransportZoneName()));
Preconditions.checkNotNull(schema.getSubnet());
String subnetCidr = getSubnetCidrAsString(schema.getSubnet());
SubnetUtils subnetUtils = new SubnetUtils(subnetCidr);
IpAddress gatewayIp = schema.getGatewayIp();
if (gatewayIp != null) {
String strGatewayIp = String.valueOf(gatewayIp.getValue());
if (!strGatewayIp.equals(ITMConstants.DUMMY_IP_ADDRESS) && !subnetUtils.getInfo().isInRange(strGatewayIp)) {
Preconditions.checkArgument(false, "Gateway IP address " + strGatewayIp + " is not in subnet range " + subnetCidr);
}
}
ItmUtils.getExcludeIpAddresses(schema.getExcludeIpFilter(), subnetUtils.getInfo());
return new VtepConfigSchemaBuilder(schema).setTunnelType(schema.getTunnelType()).build();
}
Aggregations