Search in sources :

Example 1 with VtepConfigSchemaBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchemaBuilder in project genius by opendaylight.

the class VtepConfigSchemaListener method handleNewlyAddedDpnsToSchema.

/**
 * Handle newly added dpns to schema.
 *
 * @param original
 *            the original
 * @param originalDpnIds
 *            the original dpn ids
 * @param updatedDpnIds
 *            the updated dpn ids
 */
private void handleNewlyAddedDpnsToSchema(VtepConfigSchema original, List<DpnIds> originalDpnIds, List<DpnIds> updatedDpnIds) {
    LOG.trace("Handle Addition of DPNs from VTEP Original Dpn: {}. Updated Dpn: {}", originalDpnIds, updatedDpnIds);
    ArrayList<DpnIds> newlyAddedDpns = new ArrayList<>(updatedDpnIds);
    newlyAddedDpns.removeAll(originalDpnIds);
    LOG.debug("Newly added DPNs {} to VTEP config schema [{}].", newlyAddedDpns, original.getSchemaName());
    if (!newlyAddedDpns.isEmpty()) {
        VtepConfigSchema diffSchema = new VtepConfigSchemaBuilder(original).setDpnIds(newlyAddedDpns).build();
        String subnetCidr = ItmUtils.getSubnetCidrAsString(original.getSubnet());
        VtepIpPool vtepIpPool = getVtepIpPool(subnetCidr);
        LOG.debug("Adding of DPNs in Diff Schema: {}", diffSchema);
        addVteps(diffSchema, vtepIpPool);
    }
}
Also used : DpnIds(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.vtep.config.schema.DpnIds) VtepConfigSchema(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema) VtepConfigSchemaBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchemaBuilder) ArrayList(java.util.ArrayList) VtepIpPool(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.ip.pools.VtepIpPool)

Example 2 with VtepConfigSchemaBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchemaBuilder in project genius by opendaylight.

the class ItmProvider method updateVtepSchema.

@Override
public void updateVtepSchema(String schemaName, List<BigInteger> lstDpnsForAdd, List<BigInteger> lstDpnsForDelete) {
    LOG.trace("Updating VTEP schema {} by adding DPN's {} and deleting DPN's {}.", schemaName, lstDpnsForAdd, lstDpnsForDelete);
    VtepConfigSchema schema = ItmUtils.validateForUpdateVtepSchema(schemaName, lstDpnsForAdd, lstDpnsForDelete, this);
    VtepConfigSchemaBuilder builder = new VtepConfigSchemaBuilder(schema);
    /* if (ItmUtils.getDpnIdList(schema.getDpnIds()).isEmpty()) {
            builder.setDpnIds(schema.getDpnIds());
        } else {*/
    if (lstDpnsForAdd != null && !lstDpnsForAdd.isEmpty()) {
        List<BigInteger> originalDpnList = ItmUtils.getDpnIdList(schema.getDpnIds());
        originalDpnList.addAll(lstDpnsForAdd);
        builder.setDpnIds(ItmUtils.getDpnIdsListFromBigInt(originalDpnList));
    }
    if (lstDpnsForDelete != null && !lstDpnsForDelete.isEmpty()) {
        List<BigInteger> originalDpnList = ItmUtils.getDpnIdList(schema.getDpnIds());
        originalDpnList.removeAll(lstDpnsForDelete);
        builder.setDpnIds(ItmUtils.getDpnIdsListFromBigInt(originalDpnList));
    // schema.setDpnIds(ItmUtils.getDpnIdsListFromBigInt(ItmUtils.getDpnIdList(schema.getDpnIds())
    // .removeAll(lstDpnsForAdd)));
    }
    // }
    schema = builder.build();
    MDSALUtil.syncWrite(this.dataBroker, LogicalDatastoreType.CONFIGURATION, ItmUtils.getVtepConfigSchemaIdentifier(schemaName), schema);
    LOG.debug("Vtep config schema {} updated to config DS with DPN's {}", schemaName, ItmUtils.getDpnIdList(schema.getDpnIds()));
}
Also used : VtepConfigSchema(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema) VtepConfigSchemaBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchemaBuilder) BigInteger(java.math.BigInteger)

Example 3 with VtepConfigSchemaBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchemaBuilder in project genius by opendaylight.

the class ItmUtils method constructVtepConfigSchema.

public static VtepConfigSchema constructVtepConfigSchema(String schemaName, String portName, Integer vlanId, String subnetMask, String gatewayIp, String transportZone, String tunnelType, List<BigInteger> dpnIds, String excludeIpFilter) {
    IpAddress gatewayIpObj = StringUtils.isBlank(gatewayIp) ? null : IpAddressBuilder.getDefaultInstance(gatewayIp);
    IpPrefix subnet = StringUtils.isBlank(subnetMask) ? null : IpPrefixBuilder.getDefaultInstance(subnetMask);
    Class<? extends TunnelTypeBase> tunType;
    if (tunnelType.equals(ITMConstants.TUNNEL_TYPE_VXLAN)) {
        tunType = TunnelTypeVxlan.class;
    } else {
        tunType = TunnelTypeGre.class;
    }
    VtepConfigSchemaBuilder schemaBuilder = new VtepConfigSchemaBuilder().setSchemaName(schemaName).setPortName(portName).setVlanId(vlanId).setSubnet(subnet).setGatewayIp(gatewayIpObj).setTransportZoneName(transportZone).setTunnelType(tunType).setDpnIds(getDpnIdsListFromBigInt(dpnIds)).setExcludeIpFilter(excludeIpFilter);
    return schemaBuilder.build();
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) 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)

Example 4 with VtepConfigSchemaBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchemaBuilder 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

VtepConfigSchemaBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchemaBuilder)4 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 VtepConfigSchema (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema)2 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 SubnetUtils (org.apache.commons.net.util.SubnetUtils)1 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)1 DpnIds (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.vtep.config.schema.DpnIds)1 VtepIpPool (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.ip.pools.VtepIpPool)1