Search in sources :

Example 11 with VtepConfigSchema

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;
}
Also used : VtepConfigSchema(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema)

Example 12 with VtepConfigSchema

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;
}
Also used : VtepConfigSchema(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema)

Example 13 with VtepConfigSchema

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);
    }
}
Also used : VtepConfigSchema(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema)

Example 14 with VtepConfigSchema

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);
}
Also used : VtepConfigSchema(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema)

Example 15 with VtepConfigSchema

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();
}
Also used : SubnetUtils(org.apache.commons.net.util.SubnetUtils) VtepConfigSchemaBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchemaBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Aggregations

VtepConfigSchema (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema)13 BigInteger (java.math.BigInteger)7 ArrayList (java.util.ArrayList)7 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)5 VtepConfigSchemaBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchemaBuilder)4 VtepIpPool (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.ip.pools.VtepIpPool)3 SubnetUtils (org.apache.commons.net.util.SubnetUtils)2 TepCommandHelper (org.opendaylight.genius.itm.cli.TepCommandHelper)2 TepException (org.opendaylight.genius.itm.cli.TepException)2 List (java.util.List)1 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)1 TunnelTypeGre (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeGre)1 DpnIds (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.vtep.config.schema.DpnIds)1 VtepIpPoolBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.ip.pools.VtepIpPoolBuilder)1 ExternalTunnelList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList)1 TunnelList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelList)1 StateTunnelList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList)1 DcGatewayIpList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.DcGatewayIpList)1 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)1 TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)1