Search in sources :

Example 71 with Ports

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.port._case.Ports in project genius by opendaylight.

the class ShowOvsPorts method doExecute.

@Override
protected Object doExecute() {
    LOG.debug("Executing show ovs-ports command");
    List<OvsdbTerminationPointAugmentation> ports = interfaceManager.getPortsOnBridge(dpnId);
    if (!ports.isEmpty()) {
        IfmCLIUtil.showBridgePortsHeader(session, dpnId);
    }
    for (OvsdbTerminationPointAugmentation port : ports) {
        IfmCLIUtil.showBridgePortsOutput(session, port);
    }
    return null;
}
Also used : OvsdbTerminationPointAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation)

Example 72 with Ports

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.port._case.Ports in project netvirt by opendaylight.

the class QosNeutronUtils method displayQosPortsMap.

private void displayQosPortsMap(CommandSession session, Gson gson) {
    session.getConsole().println("\nQOS Ports Map");
    String policyId;
    String policyName;
    String portUuid;
    String portName;
    String portDetails;
    Uuid policyUuid;
    Uuid portId;
    JsonObject jsonObject;
    JsonArray jsonArrayOuter = new JsonArray();
    JsonArray jsonArray;
    for (ConcurrentMap.Entry<Uuid, ConcurrentMap<Uuid, Port>> policyEntry : qosPortsMap.entrySet()) {
        policyUuid = policyEntry.getKey();
        policyId = policyUuid.getValue();
        policyName = qosPolicyMap.get(policyUuid).getName();
        jsonObject = new JsonObject();
        jsonArray = new JsonArray();
        jsonObject.addProperty("Policy Uuid", policyId);
        jsonObject.addProperty("Policy Name", policyName);
        ConcurrentMap<Uuid, Port> portInnerMap = qosPortsMap.get(policyUuid);
        for (ConcurrentMap.Entry<Uuid, Port> portEntry : portInnerMap.entrySet()) {
            portId = portEntry.getKey();
            if (portId != null) {
                portUuid = portInnerMap.get(portId).getUuid().getValue();
                portName = portInnerMap.get(portId).getName();
                if (portName == null) {
                    portName = "null";
                }
                portDetails = portUuid + " : " + portName;
                jsonArray.add(portDetails);
            }
        }
        jsonObject.add("Port Details", jsonArray);
        jsonArrayOuter.add(jsonObject);
    }
    session.getConsole().println(gson.toJson(jsonArrayOuter));
}
Also used : JsonArray(com.google.gson.JsonArray) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) ConcurrentMap(java.util.concurrent.ConcurrentMap) JsonObject(com.google.gson.JsonObject)

Example 73 with Ports

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.port._case.Ports in project netvirt by opendaylight.

the class NeutronvpnNatManager method removeAdjacencyAndLearnedEntriesforExternalSubnet.

private void removeAdjacencyAndLearnedEntriesforExternalSubnet(Uuid extNetId, Uuid extSubnetId) {
    Collection<String> extElanInterfaces = elanService.getExternalElanInterfaces(extNetId.getValue());
    if (extElanInterfaces == null || extElanInterfaces.isEmpty()) {
        LOG.error("No external ports attached to external network {}", extNetId.getValue());
        return;
    }
    for (String infName : extElanInterfaces) {
        InstanceIdentifier<VpnInterface> vpnIfIdentifier = InstanceIdentifier.builder(VpnInterfaces.class).child(VpnInterface.class, new VpnInterfaceKey(infName)).build();
        InstanceIdentifier<Adjacencies> adjacenciesIdentifier = vpnIfIdentifier.augmentation(Adjacencies.class);
        try {
            // Looking for existing prefix in MDSAL database
            Optional<Adjacencies> optionalAdjacencies = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, adjacenciesIdentifier);
            if (optionalAdjacencies.isPresent()) {
                Map<AdjacencyKey, Adjacency> keyAdjacencyMap = optionalAdjacencies.get().nonnullAdjacency();
                Iterator<Adjacency> adjacencyIter = keyAdjacencyMap.values().iterator();
                while (adjacencyIter.hasNext()) {
                    Adjacency adjacency = adjacencyIter.next();
                    if (!adjacency.getSubnetId().equals(extSubnetId)) {
                        continue;
                    }
                    InstanceIdentifier<Adjacency> adjacencyIdentifier = adjacenciesIdentifier.child(Adjacency.class, new AdjacencyKey(adjacency.getIpAddress()));
                    SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, adjacencyIdentifier);
                    LOG.trace("Removed Adjacency for fixedIP {} for port {} on external subnet {} ", adjacency.getIpAddress(), infName, extSubnetId);
                    String extNetVpnName = extNetId.getValue();
                    String learnedSrcIp = adjacency.getIpAddress().split("/")[0];
                    InstanceIdentifier<LearntVpnVipToPort> id = NeutronvpnUtils.buildLearntVpnVipToPortIdentifier(extNetVpnName, learnedSrcIp);
                    Optional<LearntVpnVipToPort> optionalLearntVpnVipToPort = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
                    if (optionalLearntVpnVipToPort.isPresent()) {
                        neutronvpnUtils.removeLearntVpnVipToPort(extNetVpnName, learnedSrcIp);
                        LOG.trace("Removed Learnt Entry for fixedIP {} for port {}", adjacency.getIpAddress(), infName);
                    }
                }
            }
        } catch (TransactionCommitFailedException | ExecutionException | InterruptedException e) {
            LOG.error("exception in removeAdjacencyAndLearnedEntriesforExternalSubnet for interface {}", infName, e);
        }
    }
}
Also used : AdjacencyKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyKey) Adjacencies(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.Adjacencies) TransactionCommitFailedException(org.opendaylight.mdsal.common.api.TransactionCommitFailedException) VpnInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.VpnInterfaceKey) VpnInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.VpnInterface) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort) ExecutionException(java.util.concurrent.ExecutionException)

Example 74 with Ports

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.port._case.Ports in project netvirt by opendaylight.

the class VpnManagerImpl method createIdPool.

private void createIdPool() {
    CreateIdPoolInput createPool = new CreateIdPoolInputBuilder().setPoolName(VpnConstants.VPN_IDPOOL_NAME).setLow(VpnConstants.VPN_IDPOOL_LOW).setHigh(VpnConstants.VPN_IDPOOL_HIGH).build();
    try {
        Future<RpcResult<CreateIdPoolOutput>> result = idManager.createIdPool(createPool);
        if (result != null && result.get().isSuccessful()) {
            LOG.info("Created IdPool for VPN Service");
        } else {
            LOG.error("createIdPool: Unable to create ID pool for VPNService");
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Failed to create idPool for VPN Service", e);
    }
    // Now an IdPool for InterVpnLink endpoint's pseudo ports
    CreateIdPoolInput createPseudoLporTagPool = new CreateIdPoolInputBuilder().setPoolName(VpnConstants.PSEUDO_LPORT_TAG_ID_POOL_NAME).setLow(VpnConstants.LOWER_PSEUDO_LPORT_TAG).setHigh(VpnConstants.UPPER_PSEUDO_LPORT_TAG).build();
    try {
        Future<RpcResult<CreateIdPoolOutput>> result = idManager.createIdPool(createPseudoLporTagPool);
        if (result != null && result.get().isSuccessful()) {
            LOG.debug("Created IdPool for Pseudo Port tags");
        } else {
            StringBuilder errMsg = new StringBuilder();
            if (result != null && result.get() != null) {
                Collection<RpcError> errors = result.get().getErrors();
                for (RpcError err : errors) {
                    errMsg.append(err.getMessage()).append("\n");
                }
            }
            LOG.error("IdPool creation for PseudoPort tags failed. Reasons: {}", errMsg);
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Failed to create idPool for Pseudo Port tags", e);
    }
}
Also used : RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) RpcError(org.opendaylight.yangtools.yang.common.RpcError) CreateIdPoolInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInput) ExecutionException(java.util.concurrent.ExecutionException) CreateIdPoolInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInputBuilder)

Example 75 with Ports

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.port._case.Ports in project netvirt by opendaylight.

the class NeutronBgpvpnChangeListener method handleRoutersUpdate.

/**
 * Handle routers update.
 *
 * @deprecated Retaining method for backward compatibility. Below method needs to be removed once
 *             updated to latest BGPVPN API's.
 *
 * @param vpnId the vpn id
 * @param oldRouters the old routers
 * @param newRouters the new routers
 */
@Deprecated
private void handleRoutersUpdate(Uuid vpnId, List<Uuid> oldRouters, List<Uuid> newRouters) {
    // TODO: check router ports ethertype to follow this restriction
    if (oldRouters != null && !oldRouters.isEmpty()) {
        // remove to oldRouters the newRouters if existing
        List<Uuid> oldRoutersCopy = new ArrayList<>();
        oldRoutersCopy.addAll(oldRouters);
        if (newRouters != null) {
            newRouters.forEach(r -> oldRoutersCopy.remove(r));
        }
        /* dissociate old router */
        oldRoutersCopy.forEach(r -> {
            nvpnManager.dissociateRouterFromVpn(vpnId, r);
        });
    }
    if (newRouters != null && !newRouters.isEmpty()) {
        if (newRouters.size() > NeutronConstants.MAX_ROUTERS_PER_BGPVPN) {
            LOG.debug("In handleRoutersUpdate: maximum allowed number of associated routers is 2. VPN: {} " + "is already associated with router: {} and with router: {}", vpnId, newRouters.get(0).getValue(), newRouters.get(1).getValue());
            return;
        } else {
            for (Uuid routerId : newRouters) {
                if (oldRouters != null && oldRouters.contains(routerId)) {
                    continue;
                }
                /* If the first time BGP-VPN is getting associated with router, then no need
                       to validate if the router is already been associated with any other BGP-VPN.
                       This will avoid unnecessary MD-SAL data store read operations in VPN-MAPS.
                     */
                if (oldRouters == null || oldRouters.isEmpty()) {
                    nvpnManager.associateRouterToVpn(vpnId, routerId);
                } else if (validateRouteInfo(routerId)) {
                    nvpnManager.associateRouterToVpn(vpnId, routerId);
                }
            }
        }
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)36 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)32 ExecutionException (java.util.concurrent.ExecutionException)22 Ports (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports)21 RouterPorts (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts)19 InternalToExternalPortMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMap)18 Port (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port)13 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)13 BigInteger (java.math.BigInteger)11 Test (org.junit.Test)11 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)9 LearntVpnVipToPort (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort)9 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)9 PortsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.PortsKey)8 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)7 HashSet (java.util.HashSet)6 VpnPortipToPort (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPort)6 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)5 ByteBuf (io.netty.buffer.ByteBuf)5 HashMap (java.util.HashMap)5