Search in sources :

Example 81 with Uuid

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid in project netvirt by opendaylight.

the class AbstractAclServiceImpl method handleRemoteAclUpdate.

protected void handleRemoteAclUpdate(Acl aclBefore, Acl aclAfter, Collection<AclInterface> portsBefore) {
    String aclName = aclAfter.getAclName();
    Collection<AclInterface> interfaceList = aclDataUtil.getInterfaceList(new Uuid(aclName));
    if (interfaceList == null || interfaceList.isEmpty()) {
        LOG.trace("handleRemoteAclUpdate: No interfaces found with ACL={}", aclName);
        return;
    }
    Set<Uuid> remoteAclsBefore = AclServiceUtils.getRemoteAclIdsByDirection(aclBefore, this.direction);
    Set<Uuid> remoteAclsAfter = AclServiceUtils.getRemoteAclIdsByDirection(aclAfter, this.direction);
    Set<Uuid> remoteAclsAdded = new HashSet<>(remoteAclsAfter);
    remoteAclsAdded.removeAll(remoteAclsBefore);
    Set<Uuid> remoteAclsDeleted = new HashSet<>(remoteAclsBefore);
    remoteAclsDeleted.removeAll(remoteAclsAfter);
    if (!remoteAclsAdded.isEmpty() || !remoteAclsDeleted.isEmpty()) {
        // ports
        for (AclInterface portBefore : portsBefore) {
            programAclDispatcherTable(portBefore, NwConstants.DEL_FLOW);
        }
        for (AclInterface port : interfaceList) {
            programAclDispatcherTable(port, NwConstants.ADD_FLOW);
        }
    }
    Set<BigInteger> dpns = interfaceList.stream().map(port -> port.getDpId()).collect(Collectors.toSet());
    programRemoteAclTable(aclName, remoteAclsDeleted, dpns, NwConstants.DEL_FLOW);
    programRemoteAclTable(aclName, remoteAclsAdded, dpns, NwConstants.ADD_FLOW);
}
Also used : AclInterface(org.opendaylight.netvirt.aclservice.api.utils.AclInterface) AceIpv4(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4) NxMatchCtState(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchCtState) Acl(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl) SortedSet(java.util.SortedSet) LoggerFactory(org.slf4j.LoggerFactory) AclServiceListener(org.opendaylight.netvirt.aclservice.api.AclServiceListener) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) AllowedAddressPairs(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs) Map(java.util.Map) BigInteger(java.math.BigInteger) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) DirectionIngress(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.DirectionIngress) MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) AclConstants(org.opendaylight.netvirt.aclservice.utils.AclConstants) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) AclDataUtil(org.opendaylight.netvirt.aclservice.utils.AclDataUtil) Collection(java.util.Collection) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) Set(java.util.Set) AclConntrackClassifierType(org.opendaylight.netvirt.aclservice.utils.AclConntrackClassifierType) Matches(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches) Collectors(java.util.stream.Collectors) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) List(java.util.List) NxCtAction(org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack.NxCtAction) Entry(java.util.Map.Entry) AceIp(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIp) DirectionEgress(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.DirectionEgress) HashMap(java.util.HashMap) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) ServiceModeBase(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceModeBase) AclServiceUtils(org.opendaylight.netvirt.aclservice.utils.AclServiceUtils) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Lists(com.google.common.collect.Lists) AclInterfaceCache(org.opendaylight.netvirt.aclservice.api.AclInterfaceCache) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) MatchEthernetType(org.opendaylight.genius.mdsalutil.matches.MatchEthernetType) SecurityRuleAttr(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.SecurityRuleAttr) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) AccessListEntries(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.AccessListEntries) AclServiceOFFlowBuilder(org.opendaylight.netvirt.aclservice.utils.AclServiceOFFlowBuilder) ServiceModeEgress(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceModeEgress) DirectionBase(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.DirectionBase) AclInterface(org.opendaylight.netvirt.aclservice.api.utils.AclInterface) Logger(org.slf4j.Logger) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) Ace(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.Ace) ActionNxConntrack(org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) IMdsalApiManager(org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager) Action(org.opendaylight.netvirt.aclservice.api.AclServiceManager.Action) Collections(java.util.Collections) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) BigInteger(java.math.BigInteger) HashSet(java.util.HashSet)

Example 82 with Uuid

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid in project netvirt by opendaylight.

the class RouterInterfaceVrfEntryHandler method installRouterFibEntries.

private Boolean installRouterFibEntries(VrfEntry vrfEntry, String rd, int addOrRemove, RouterInterface routerInterface) {
    final VpnInstanceOpDataEntry vpnInstance = getFibUtil().getVpnInstance(rd);
    Preconditions.checkNotNull(vpnInstance, "Vpn Instance not available " + rd);
    Preconditions.checkNotNull(vpnInstance.getVpnId(), "Vpn Instance with rd " + vpnInstance.getVrfId() + " has null vpnId!");
    synchronized (vpnInstance.getVpnInstanceName().intern()) {
        final Collection<VpnToDpnList> vpnToDpnList;
        if (vrfEntry.getParentVpnRd() != null && FibHelper.isControllerManagedNonSelfImportedRoute(RouteOrigin.value(vrfEntry.getOrigin()))) {
            VpnInstanceOpDataEntry parentVpnInstance = getFibUtil().getVpnInstance(vrfEntry.getParentVpnRd());
            vpnToDpnList = parentVpnInstance != null ? parentVpnInstance.getVpnToDpnList() : vpnInstance.getVpnToDpnList();
        } else {
            vpnToDpnList = vpnInstance.getVpnToDpnList();
        }
        final Long vpnId = vpnInstance.getVpnId();
        if (vpnToDpnList != null) {
            String routerId = routerInterface.getUuid();
            String macAddress = routerInterface.getMacAddress();
            String ipValue = routerInterface.getIpAddress();
            LOG.trace("createFibEntries - Router augmented vrfentry found for for router uuid:{}, ip:{}, mac:{}", routerId, ipValue, macAddress);
            for (VpnToDpnList vpnDpn : vpnToDpnList) {
                if (vpnDpn.getDpnState() == VpnToDpnList.DpnState.Active) {
                    installRouterFibEntry(vrfEntry, vpnDpn.getDpnId(), vpnId, ipValue, new MacAddress(macAddress), addOrRemove);
                }
            }
        }
    }
    return true;
}
Also used : VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)

Example 83 with Uuid

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid in project netvirt by opendaylight.

the class L2GatewayConnectionUtils method getAssociatedL2GwConnections.

/**
 * Gets the associated l2 gw connections.
 *
 * @param broker
 *            the broker
 * @param l2GatewayIds
 *            the l2 gateway ids
 * @return the associated l2 gw connections
 */
@Nonnull
public static List<L2gatewayConnection> getAssociatedL2GwConnections(DataBroker broker, Set<Uuid> l2GatewayIds) {
    List<L2gatewayConnection> allL2GwConns = getAllL2gatewayConnections(broker);
    List<L2gatewayConnection> l2GwConnections = new ArrayList<>();
    for (Uuid l2GatewayId : l2GatewayIds) {
        for (L2gatewayConnection l2GwConn : allL2GwConns) {
            if (l2GwConn.getL2gatewayId().equals(l2GatewayId)) {
                l2GwConnections.add(l2GwConn);
            }
        }
    }
    return l2GwConnections;
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) L2gatewayConnection(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection) Nonnull(javax.annotation.Nonnull)

Example 84 with Uuid

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid in project netvirt by opendaylight.

the class L2GatewayConnectionUtils method associateHwvtepsToElan.

private void associateHwvtepsToElan(ElanInstance elanInstance, L2gateway l2Gateway, L2gatewayConnection input, String l2GwDeviceName) {
    String elanName = elanInstance.getElanInstanceName();
    Integer defaultVlan = input.getSegmentId();
    Uuid l2GwConnId = input.getKey().getUuid();
    List<Devices> l2Devices = l2Gateway.getDevices();
    LOG.trace("Associating ELAN {} with L2Gw Conn Id {} having below L2Gw devices {}", elanName, l2GwConnId, l2Devices);
    for (Devices l2Device : l2Devices) {
        String l2DeviceName = l2Device.getDeviceName();
        // preprovisioning/re-provisioning
        if (l2GwDeviceName != null && !l2GwDeviceName.equals(l2DeviceName)) {
            LOG.debug("Associating Hwvtep to ELAN is not been processed for {}; as only {} got connected now!", l2DeviceName, l2GwDeviceName);
            continue;
        }
        L2GatewayDevice l2GatewayDevice = l2GatewayCache.get(l2DeviceName);
        if (isL2GwDeviceConnected(l2GatewayDevice)) {
            NodeId hwvtepNodeId = new NodeId(l2GatewayDevice.getHwvtepNodeId());
            // Delete pending delete logical switch task if scheduled
            elanL2GatewayUtils.cancelDeleteLogicalSwitch(hwvtepNodeId, ElanL2GatewayUtils.getLogicalSwitchFromElan(elanName));
            // Add L2 Gateway device to 'ElanL2GwDevice' cache
            boolean createLogicalSwitch;
            LogicalSwitches logicalSwitch = HwvtepUtils.getLogicalSwitch(broker, LogicalDatastoreType.CONFIGURATION, hwvtepNodeId, elanName);
            if (logicalSwitch == null) {
                HwvtepLogicalSwitchListener hwVTEPLogicalSwitchListener = new HwvtepLogicalSwitchListener(elanInstanceCache, elanL2GatewayUtils, elanClusterUtils, elanL2GatewayMulticastUtils, this, l2GatewayDevice, elanName, l2Device, defaultVlan, l2GwConnId);
                hwVTEPLogicalSwitchListener.registerListener(LogicalDatastoreType.OPERATIONAL, broker);
                closeables.add(hwVTEPLogicalSwitchListener);
                createLogicalSwitch = true;
            } else {
                addL2DeviceToElanL2GwCache(elanName, l2GatewayDevice, l2GwConnId, l2Device);
                createLogicalSwitch = false;
            }
            AssociateHwvtepToElanJob associateHwvtepToElanJob = new AssociateHwvtepToElanJob(broker, elanL2GatewayUtils, elanL2GatewayMulticastUtils, elanInstanceCache, l2GatewayDevice, elanInstance, l2Device, defaultVlan, createLogicalSwitch);
            elanClusterUtils.runOnlyInOwnerNode(associateHwvtepToElanJob.getJobKey(), "create logical switch in hwvtep topo", associateHwvtepToElanJob);
        } else {
            LOG.info("L2GwConn create is not handled for device with id {} as it's not connected", l2DeviceName);
        }
    }
}
Also used : LogicalSwitches(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) AssociateHwvtepToElanJob(org.opendaylight.netvirt.elan.l2gw.jobs.AssociateHwvtepToElanJob) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) Devices(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices) HwvtepLogicalSwitchListener(org.opendaylight.netvirt.elan.l2gw.listeners.HwvtepLogicalSwitchListener) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Example 85 with Uuid

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid in project netvirt by opendaylight.

the class L2GatewayConnectionUtils method deleteL2GatewayConnection.

public void deleteL2GatewayConnection(L2gatewayConnection input) {
    LOG.info("Deleting L2gateway Connection with ID: {}", input.getKey().getUuid());
    Uuid networkUuid = input.getNetworkId();
    String elanName = networkUuid.getValue();
    disAssociateHwvtepsFromElan(elanName, input);
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)

Aggregations

Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)283 ArrayList (java.util.ArrayList)114 BigInteger (java.math.BigInteger)79 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)55 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)53 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)52 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)48 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)40 ExecutionException (java.util.concurrent.ExecutionException)35 Port (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port)32 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)29 Network (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network)27 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)25 HashSet (java.util.HashSet)23 List (java.util.List)23 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)23 ProviderTypes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProviderTypes)22 VpnInterface (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface)19 Optional (com.google.common.base.Optional)17 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)17