Search in sources :

Example 61 with Error

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error in project netvirt by opendaylight.

the class NeutronvpnManager method addToNeutronRouterInterfacesMap.

protected void addToNeutronRouterInterfacesMap(Uuid routerId, String interfaceName) {
    synchronized (routerId.getValue().intern()) {
        InstanceIdentifier<RouterInterfaces> routerInterfacesId = getRouterInterfacesId(routerId);
        try {
            Optional<RouterInterfaces> optRouterInterfaces = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, routerInterfacesId);
            Interfaces routerInterface = new InterfacesBuilder().setKey(new InterfacesKey(interfaceName)).setInterfaceId(interfaceName).build();
            if (optRouterInterfaces.isPresent()) {
                SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routerInterfacesId.child(Interfaces.class, new InterfacesKey(interfaceName)), routerInterface);
            } else {
                // TODO Shouldn't we be doing something with builder and interfaces?
                // RouterInterfacesBuilder builder = new RouterInterfacesBuilder().setRouterId(routerId);
                // List<Interfaces> interfaces = new ArrayList<>();
                // interfaces.add(routerInterface);
                SingleTransactionDataBroker.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, routerInterfacesId.child(Interfaces.class, new InterfacesKey(interfaceName)), routerInterface);
            }
        } catch (ReadFailedException | TransactionCommitFailedException e) {
            LOG.error("Error reading router interfaces for {}", routerInterfacesId, e);
        }
    }
}
Also used : VpnInterfaces(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.VpnInterfaces) RouterInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.RouterInterfaces) Interfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.router.interfaces.Interfaces) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) RouterInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.RouterInterfaces) RouterInterfacesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.RouterInterfacesKey) InterfacesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.router.interfaces.InterfacesKey) InterfacesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.router.interfaces.InterfacesBuilder)

Example 62 with Error

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error in project netvirt by opendaylight.

the class NeutronBgpvpnChangeListener method update.

@Override
protected void update(InstanceIdentifier<Bgpvpn> identifier, Bgpvpn original, Bgpvpn update) {
    LOG.trace("Update Bgpvpn : key: {}, value={}", identifier, update);
    Uuid vpnId = update.getUuid();
    if (isBgpvpnTypeL3(update.getType())) {
        try {
            handleVpnInstanceUpdate(original.getUuid().getValue(), original.getRouteDistinguishers(), update.getRouteDistinguishers());
        } catch (UnsupportedOperationException e) {
            LOG.error("Error while processing Update Bgpvpn.", e);
            return;
        }
        List<Uuid> oldNetworks = original.getNetworks();
        List<Uuid> newNetworks = update.getNetworks();
        handleNetworksUpdate(vpnId, oldNetworks, newNetworks);
        List<Uuid> oldRouters = original.getRouters();
        List<Uuid> newRouters = update.getRouters();
        handleRoutersUpdate(vpnId, oldRouters, newRouters);
    } else {
        LOG.warn("BGPVPN type for VPN {} is not L3", vpnId.getValue());
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)

Example 63 with Error

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error in project netvirt by opendaylight.

the class NeutronNetworkChangeListener method buildSegments.

@Nonnull
private List<ElanSegments> buildSegments(Network input) {
    Long numSegments = NeutronUtils.getNumberSegmentsFromNeutronNetwork(input);
    List<ElanSegments> segments = new ArrayList<>();
    for (long index = 0L; index < numSegments; index++) {
        ElanSegmentsBuilder elanSegmentsBuilder = new ElanSegmentsBuilder();
        elanSegmentsBuilder.setSegmentationId(0L);
        if (NeutronUtils.getSegmentationIdFromNeutronNetworkSegment(input, index) != null) {
            try {
                elanSegmentsBuilder.setSegmentationId(Long.valueOf(NeutronUtils.getSegmentationIdFromNeutronNetworkSegment(input, index)));
            } catch (NumberFormatException error) {
                LOG.error("Failed to get the segment id for network {}", input);
            }
        }
        if (NeutronUtils.isNetworkSegmentType(input, index, NetworkTypeVxlan.class)) {
            elanSegmentsBuilder.setSegmentType(SegmentTypeVxlan.class);
        } else if (NeutronUtils.isNetworkSegmentType(input, index, NetworkTypeVlan.class)) {
            elanSegmentsBuilder.setSegmentType(SegmentTypeVlan.class);
        } else if (NeutronUtils.isNetworkSegmentType(input, index, NetworkTypeFlat.class)) {
            elanSegmentsBuilder.setSegmentType(SegmentTypeFlat.class);
        }
        elanSegmentsBuilder.setSegmentationIndex(index);
        segments.add(elanSegmentsBuilder.build());
        LOG.debug("Added segment {} to ELANInstance", segments.get((int) index - 1));
    }
    return segments;
}
Also used : SegmentTypeVlan(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.SegmentTypeVlan) ElanSegments(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.elan.instance.ElanSegments) ElanSegmentsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.elan.instance.ElanSegmentsBuilder) ArrayList(java.util.ArrayList) NetworkTypeVlan(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeVlan) Nonnull(javax.annotation.Nonnull)

Example 64 with Error

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error in project netvirt by opendaylight.

the class OpenflowRenderer method renderPath.

@Override
// FindBugs reports "Useless object stored in variable flows" however it doesn't recognize the usage of forEach.
@SuppressFBWarnings("UC_USELESS_OBJECT")
public void renderPath(NodeId nodeId, Long nsp, short nsi, short nsl, String firstHopIp) {
    List<Flow> flows = new ArrayList<>();
    if (firstHopIp != null) {
        Long port = geniusProvider.getEgressVxlanPortForNode(OpenFlow13Provider.getDpnIdFromNodeId(nodeId)).orElse(null);
        if (port == null) {
            LOG.error("OpenflowRenderer: cant get egressPort for nodeId [{}]", nodeId.getValue());
            return;
        }
        Flow flow;
        flow = openFlow13Provider.createEgressClassifierTransportEgressRemoteFlow(nodeId, nsp, port, firstHopIp);
        flows.add(flow);
    } else {
        Flow flow;
        flow = openFlow13Provider.createEgressClassifierTransportEgressLocalFlow(nodeId, nsp);
        flows.add(flow);
    }
    short egressNsi = (short) (nsi - nsl);
    flows.add(openFlow13Provider.createIngressClassifierFilterChainEgressFlow(nodeId, nsp, egressNsi));
    ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> flows.forEach(flow -> this.openFlow13Provider.appendFlowForCreate(nodeId, flow, tx))), LOG, "Error rendering a path");
}
Also used : Logger(org.slf4j.Logger) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) LoggerFactory(org.slf4j.LoggerFactory) ClassifierEntryRenderer(org.opendaylight.netvirt.sfc.classifier.service.domain.api.ClassifierEntryRenderer) 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) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) OpenFlow13Provider(org.opendaylight.netvirt.sfc.classifier.providers.OpenFlow13Provider) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) ArrayList(java.util.ArrayList) ListenableFutures(org.opendaylight.infrautils.utils.concurrent.ListenableFutures) List(java.util.List) GeniusProvider(org.opendaylight.netvirt.sfc.classifier.providers.GeniusProvider) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) ArrayList(java.util.ArrayList) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 65 with Error

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error in project netvirt by opendaylight.

the class ConfigureL3VpnCommand method createL3VpnCLI.

private void createL3VpnCLI() throws InterruptedException, ExecutionException {
    if (vid == null) {
        session.getConsole().println("Please supply a valid VPN ID");
        session.getConsole().println(getHelp("create"));
        return;
    }
    if (rd == null) {
        session.getConsole().println("Please supply a valid RD");
        session.getConsole().println(getHelp("create"));
        return;
    }
    if (irt == null) {
        session.getConsole().println("Please supply a valid list of import RTs separated by {,}");
        session.getConsole().println(getHelp("create"));
        return;
    }
    if (ert == null) {
        session.getConsole().println("Please supply a valid list of export RTs separated by {,}");
        session.getConsole().println(getHelp("create"));
        return;
    }
    Uuid vuuid = new Uuid(vid);
    RpcResult<CreateL3VPNOutput> createL3VpnRpcResult = null;
    {
        ArrayList<String> rdList = new ArrayList<>(Arrays.asList(rd.split(",")));
        ArrayList<String> irtList = new ArrayList<>(Arrays.asList(irt.split(",")));
        ArrayList<String> ertList = new ArrayList<>(Arrays.asList(ert.split(",")));
        Uuid tuuid = null;
        if (tid != null) {
            tuuid = new Uuid(tid);
        }
        List<L3vpn> l3vpns = new ArrayList<>();
        L3vpn l3vpn = new L3vpnBuilder().setId(vuuid).setName(name).setRouteDistinguisher(rdList).setImportRT(irtList).setExportRT(ertList).setTenantId(tuuid).build();
        l3vpns.add(l3vpn);
        Future<RpcResult<CreateL3VPNOutput>> result = neutronvpnService.createL3VPN(new CreateL3VPNInputBuilder().setL3vpn(l3vpns).build());
        createL3VpnRpcResult = result.get();
        if (createL3VpnRpcResult.isSuccessful()) {
            session.getConsole().println("L3VPN created successfully");
            LOG.trace("createl3vpn: {}", result);
        } else {
            session.getConsole().println("Error populating createL3VPN : " + result.get().getErrors());
            session.getConsole().println(getHelp("create"));
        }
    }
    /**
     * passing a subnetId list alongwith create-l3-vpn CLI implicitly indicates that
     * association of network(s) to VPN is being intended.
     */
    if (createL3VpnRpcResult.isSuccessful()) {
        {
            List<Uuid> networkIdList = new ArrayList<>();
            if (sid != null) {
                for (String sidStr : sid.split(",")) {
                    Uuid subnetId = new Uuid(sidStr);
                    Uuid networkId = neutronVpnManager.getNetworkForSubnet(subnetId);
                    if (networkId != null) {
                        networkIdList.add(networkId);
                    } else {
                        session.getConsole().println("Could not find network for subnet " + subnetId.getValue() + ". Not proceeding with adding subnet to VPN");
                    }
                }
                if (!networkIdList.isEmpty()) {
                    Future<RpcResult<AssociateNetworksOutput>> result = neutronvpnService.associateNetworks(new AssociateNetworksInputBuilder().setVpnId(vuuid).setNetworkId(networkIdList).build());
                    RpcResult<AssociateNetworksOutput> associateNetworksRpcResult = result.get();
                    if (associateNetworksRpcResult.isSuccessful()) {
                        session.getConsole().println("Subnet(s) added to VPN successfully");
                        LOG.trace("associateNetworks: {}", result);
                    } else {
                        session.getConsole().println("Error while adding subnet(s) to VPN: " + result.get().getErrors());
                        session.getConsole().println(getHelp("create"));
                    }
                }
            }
        }
    }
}
Also used : CreateL3VPNOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.CreateL3VPNOutput) ArrayList(java.util.ArrayList) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) L3vpn(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.createl3vpn.input.L3vpn) AssociateNetworksInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.AssociateNetworksInputBuilder) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) AssociateNetworksOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.AssociateNetworksOutput) Future(java.util.concurrent.Future) ArrayList(java.util.ArrayList) List(java.util.List) L3vpnBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.createl3vpn.input.L3vpnBuilder) CreateL3VPNInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.CreateL3VPNInputBuilder)

Aggregations

RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)81 ArrayList (java.util.ArrayList)65 ExecutionException (java.util.concurrent.ExecutionException)61 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)41 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)30 BigInteger (java.math.BigInteger)29 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)25 List (java.util.List)24 Optional (com.google.common.base.Optional)23 Test (org.junit.Test)22 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)22 RpcError (org.opendaylight.yangtools.yang.common.RpcError)20 Logger (org.slf4j.Logger)20 LoggerFactory (org.slf4j.LoggerFactory)20 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)19 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)17 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)17 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)16 Nonnull (javax.annotation.Nonnull)15 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)15