Search in sources :

Example 1 with VtepsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsBuilder in project netvirt by opendaylight.

the class TransportZoneNotificationUtil method addVtep.

/**
 * Tries to add a vtep for a transport zone.
 *
 * @return Whether a vtep was added or not.
 */
private boolean addVtep(TransportZone zone, String subnetIp, BigInteger dpnId, @Nullable String localIp) {
    List<Subnets> zoneSubnets = zone.getSubnets();
    if (zoneSubnets == null) {
        return false;
    }
    Subnets subnets = getOrAddSubnet(zoneSubnets, subnetIp);
    for (Vteps existingVtep : subnets.getVteps()) {
        if (existingVtep.getDpnId().equals(dpnId)) {
            return false;
        }
    }
    if (localIp != null) {
        IpAddress nodeIp = new IpAddress(localIp.toCharArray());
        VtepsBuilder vtepsBuilder = new VtepsBuilder().setDpnId(dpnId).setIpAddress(nodeIp).setPortname(TUNNEL_PORT).setOptionOfTunnel(elanConfig.isUseOfTunnels());
        subnets.getVteps().add(vtepsBuilder.build());
        return true;
    }
    return false;
}
Also used : Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) VtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder)

Example 2 with VtepsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsBuilder in project genius by opendaylight.

the class TepCommandHelper method createLocalCache.

@SuppressWarnings("checkstyle:IllegalCatch")
public void createLocalCache(Uint64 dpnId, String ipAddress, String transportZone) throws TepException {
    CHECK.incrementAndGet();
    IpAddress ipAddressObj;
    final VtepsKey vtepkey = new VtepsKey(dpnId);
    ipAddressObj = IpAddressBuilder.getDefaultInstance(ipAddress);
    if (checkTepPerTzPerDpn(transportZone, dpnId)) {
        handleError("Only one end point per transport Zone per Dpn is allowed");
        return;
    }
    Vteps vtepCli = new VtepsBuilder().setDpnId(dpnId).setIpAddress(ipAddressObj).withKey(vtepkey).build();
    if (transportZonesHashMap.containsKey(transportZone)) {
        List<Vteps> vtepListTemp = transportZonesHashMap.get(transportZone);
        if (!vtepListTemp.contains(vtepCli)) {
            vtepListTemp.add(vtepCli);
        }
    } else {
        List<Vteps> vtepListTemp = new ArrayList<>();
        vtepListTemp.add(vtepCli);
        transportZonesHashMap.put(transportZone, vtepListTemp);
    }
}
Also used : VtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps) ArrayList(java.util.ArrayList) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) VtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsBuilder)

Example 3 with VtepsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsBuilder in project genius by opendaylight.

the class TepCommandHelper method isInCache.

// deletes from ADD-cache if it exists.
public boolean isInCache(Uint64 dpnId, String ipAddress, String transportZone) throws TepException {
    boolean exists = false;
    final VtepsKey vtepkey = new VtepsKey(dpnId);
    IpAddress ipAddressObj = IpAddressBuilder.getDefaultInstance(ipAddress);
    Vteps vtepCli = new VtepsBuilder().setDpnId(dpnId).setIpAddress(ipAddressObj).withKey(vtepkey).build();
    if (transportZonesHashMap.containsKey(transportZone)) {
        List<Vteps> vtepListTemp = transportZonesHashMap.get(transportZone);
        if (vtepListTemp.contains(vtepCli)) {
            // return true if tzones has vtep
            exists = true;
            vtepListTemp.remove(vtepCli);
            if (vtepListTemp.size() == 0) {
                transportZonesHashMap.remove(transportZone);
            }
        } else {
            handleError("Vtep has not been configured");
        }
    }
    return exists;
}
Also used : VtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) VtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsBuilder)

Example 4 with VtepsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsBuilder in project genius by opendaylight.

the class OvsdbTepAddConfigHelper method addVtepInITMConfigDS.

/**
 * Adds the TEP into Vtep list in the subnet list in the transport zone list
 * from ITM configuration Datastore by merge operation with write transaction.
 *
 * @param updatedVtepList updated Vteps list object which will have new TEP for addition
 * @param tepIpAddress TEP IP address in IpAddress object
 * @param tzName transport zone name in string
 * @param dpid bridge datapath ID
 * @param ofTunnel boolean flag for TEP to enable/disable of-tunnel feature on it
 * @param tx TypedWriteTransaction object
 */
public static void addVtepInITMConfigDS(List<Vteps> updatedVtepList, IpAddress tepIpAddress, String tzName, Uint64 dpid, boolean ofTunnel, TypedWriteTransaction<Datastore.Configuration> tx) {
    // Create TZ node path
    InstanceIdentifier<TransportZone> tranzportZonePath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(tzName)).build();
    // when VTEP is moved from TepsNotHosted list to TZ configured from Northbound.
    if (dpid.compareTo(Uint64.ZERO) > 0) {
        // create vtep
        VtepsKey vtepkey = new VtepsKey(dpid);
        Vteps vtepObj = new VtepsBuilder().setDpnId(dpid).setIpAddress(tepIpAddress).withKey(vtepkey).setOptionOfTunnel(ofTunnel).build();
        // Add vtep obtained from bridge into list
        updatedVtepList.add(vtepObj);
        LOG.trace("Adding TEP (TZ: {} TEP IP: {} DPID: {}, of-tunnel: {}) in ITM Config DS.", tzName, tepIpAddress, dpid, ofTunnel);
    } else {
        // corresponding TZ is configured from northbound.
        for (Vteps vtep : updatedVtepList) {
            LOG.trace("Moving TEP (TEP IP: {} DPID: {}, of-tunnel: {})" + "from not-hosted-transport-zone {} into  ITM Config DS.", vtep.getIpAddress(), vtep.getDpnId(), ofTunnel, tzName);
        }
    }
    // create TZ node with updated subnet having new vtep
    TransportZone updatedTzone = new TransportZoneBuilder().withKey(new TransportZoneKey(tzName)).setVteps(updatedVtepList).setZoneName(tzName).build();
    // Update TZ in Config DS to add vtep in TZ
    tx.mergeParentStructureMerge(tranzportZonePath, updatedTzone);
}
Also used : VtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey) UnknownVtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVtepsKey) UnknownVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps) TransportZoneBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder) TepsInNotHostedTransportZoneBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZoneBuilder) VtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsBuilder) UnknownVtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVtepsBuilder) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone) TepsInNotHostedTransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone) TepsInNotHostedTransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZoneKey) TransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)

Example 5 with VtepsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsBuilder in project genius by opendaylight.

the class ItmExternalTunnelDeleteTest method setupMocks.

private void setupMocks() {
    ipAddress1 = IpAddressBuilder.getDefaultInstance(tepIp1);
    ipAddress2 = IpAddressBuilder.getDefaultInstance(tepIp2);
    ipAddress3 = IpAddressBuilder.getDefaultInstance(tepIp3);
    ipPrefixTest = IpPrefixBuilder.getDefaultInstance(subnetIp + "/24");
    gtwyIp1 = IpAddressBuilder.getDefaultInstance(gwyIp1);
    gtwyIp2 = IpAddressBuilder.getDefaultInstance(gwyIp2);
    deviceVteps1 = new DeviceVtepsBuilder().setIpAddress(ipAddress1).withKey(new DeviceVtepsKey(ipAddress1, "hwvtep:1")).setNodeId("hwvtep://192.168.101.30:6640/physicalswitch/s3").setTopologyId("hwvtep:1").build();
    deviceVteps2 = new DeviceVtepsBuilder().setIpAddress(ipAddress2).withKey(new DeviceVtepsKey(ipAddress2, "hwvtep:1")).setNodeId("hwvtep://192.168.101.30:6640/physicalswitch/s3").setTopologyId("hwvtep:1").build();
    deviceVtepsList.add(deviceVteps1);
    deviceVtepsList.add(deviceVteps2);
    hwVtep1 = new HwVtep();
    hwVtep1.setTransportZone(transportZone1);
    hwVtep1.setGatewayIP(gtwyIp1);
    hwVtep1.setHwIp(ipAddress2);
    hwVtep1.setTunnelType(tunnelType1);
    hwVtep1.setVlanID(vlanId);
    hwVtep1.setTopoId("hwvtep:1");
    hwVtep1.setNodeId("hwvtep://192.168.101.30:6640/physicalswitch/s3");
    hwVtep1.setIpPrefix(ipPrefixTest);
    vteps = new VtepsBuilder().setDpnId(dpId2).setIpAddress(ipAddress1).withKey(new VtepsKey(dpId2)).build();
    vtepsList.add(vteps);
    idOutputOptional1 = RpcResultBuilder.success(expectedId1).buildFuture();
    getIdInput1 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("1:phy0:100:192.168.56.101:192.168.56.30:VXLAN").build();
    lenient().doReturn(idOutputOptional1).when(idManagerService).allocateId(getIdInput1);
    idOutputOptional2 = RpcResultBuilder.success(expectedId2).buildFuture();
    getIdInput2 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("hwvtep:1:hwvtep:1:192.168.56.30:192.168.56.101:VXLAN").build();
    lenient().doReturn(idOutputOptional2).when(idManagerService).allocateId(getIdInput2);
    idOutputOptional3 = RpcResultBuilder.success(expectedId3).buildFuture();
    getIdInput3 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("1:phy0:100:192.168.56.101:192.168.56.40:VXLAN").build();
    lenient().doReturn(idOutputOptional3).when(idManagerService).allocateId(getIdInput3);
    idOutputOptional4 = RpcResultBuilder.success(expectedId4).buildFuture();
    getIdInput4 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("hwvtep:1:hwvtep:1:192.168.56.40:192.168.56.101:VXLAN").build();
    lenient().doReturn(idOutputOptional4).when(idManagerService).allocateId(getIdInput4);
    idOutputOptional5 = RpcResultBuilder.success(expectedId5).buildFuture();
    getIdInput5 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("hwvtep:1:hwvtep://192.168.101.30:6640/physicalswitch/" + "s3:192.168.56.40:192.168.56.101:VXLAN").build();
    lenient().doReturn(idOutputOptional5).when(idManagerService).allocateId(getIdInput5);
    idOutputOptional6 = RpcResultBuilder.success(expectedId6).buildFuture();
    getIdInput6 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("hwvtep:1:hwvtep://192.168.101.30:6640/physicalswitch/" + "s3:192.168.56.40:192.168.56.30:VXLAN").build();
    lenient().doReturn(idOutputOptional6).when(idManagerService).allocateId(getIdInput6);
    idOutputOptional7 = RpcResultBuilder.success(expectedId7).buildFuture();
    getIdInput7 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("hwvtep:1:hwvtep:1:192.168.56.30:192.168.56.40:VXLAN").build();
    lenient().doReturn(idOutputOptional7).when(idManagerService).allocateId(getIdInput7);
    idOutputOptional8 = RpcResultBuilder.success(expectedId8).buildFuture();
    getIdInput8 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("1:phy0:100:192.168.56.30:192.168.56.40:VXLAN").build();
    lenient().doReturn(idOutputOptional8).when(idManagerService).allocateId(getIdInput8);
    tunnelEndPointsVxlan = new TunnelEndPointsBuilder().setIpAddress(ipAddress3).setInterfaceName(parentInterfaceName).setTzMembership(ItmUtils.createTransportZoneMembership(transportZone1)).setTunnelType(tunnelType1).build();
    tunnelEndPointsListVxlan.add(tunnelEndPointsVxlan);
    dpntePsInfoVxlan = new DPNTEPsInfoBuilder().setDPNID(dpId2).setUp(true).withKey(new DPNTEPsInfoKey(dpId2)).setTunnelEndPoints(tunnelEndPointsListVxlan).build();
    dpnTepsList.add(dpntePsInfoVxlan);
    cfgdHwVtepsList.add(hwVtep1);
    transportZone = new TransportZoneBuilder().setTunnelType(tunnelType1).setZoneName(transportZone1).withKey(new TransportZoneKey(transportZone1)).setDeviceVteps(deviceVtepsList).setVteps(vtepsList).build();
    externalTunnel = new ExternalTunnelBuilder().setTunnelInterfaceName(parentInterfaceName).setTransportType(tunnelType1).setDestinationDevice("hwvtep:1").setSourceDevice(dpId2.toString()).withKey(new ExternalTunnelKey(dpId2.toString(), hwVtep1.getNodeId(), tunnelType1)).build();
    trunkInterfaceName = ItmUtils.getTrunkInterfaceName(parentInterfaceName, tunnelEndPointsVxlan.getIpAddress().stringValue(), ipAddress1.stringValue(), tunnelType1.getName());
    trunkIdentifier = ItmUtils.buildId(trunkInterfaceName);
    path = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, ItmUtils.getExternalTunnelKey(ipAddress1.stringValue(), dpId2.toString(), tunnelType1));
    lenient().doReturn(mockReadTx).when(dataBroker).newReadOnlyTransaction();
    lenient().doReturn(mockWriteTx).when(dataBroker).newWriteOnlyTransaction();
    lenient().doReturn(FluentFutures.immediateNullFluentFuture()).when(mockWriteTx).commit();
    doReturn("phy0").when(itmConfig).getPortname();
    doReturn(Uint16.valueOf(100)).when(itmConfig).getVlanId();
}
Also used : DPNTEPsInfoBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoBuilder) VtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey) DeviceVtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVtepsKey) ExternalTunnelKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnelKey) ExternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel) DeviceVtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVtepsKey) HwVtep(org.opendaylight.genius.itm.confighelpers.HwVtep) DeviceVtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVtepsBuilder) VtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsBuilder) TunnelEndPointsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPointsBuilder) AllocateIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder) DPNTEPsInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoKey) DeviceVtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVtepsBuilder) ExternalTunnelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnelBuilder) TransportZoneBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder) TransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)

Aggregations

VtepsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsBuilder)9 VtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey)9 TransportZoneBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder)7 TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)7 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)6 UnknownVteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps)6 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps)6 ArrayList (java.util.ArrayList)5 UnknownVtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVtepsKey)5 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)5 VtepsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder)5 List (java.util.List)4 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)4 TepsInNotHostedTransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone)4 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)4 DeviceVtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVtepsKey)4 VtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey)4 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)3 StateTunnelList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList)3 SubnetsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey)3