Search in sources :

Example 46 with Other

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Other in project netvirt by opendaylight.

the class NeutronvpnManager method showVpnConfigCLI.

/**
 * Implementation of the "vpnservice:l3vpn-config-show" karaf CLI command.
 *
 * @param vpnuuid Uuid of the VPN whose config must be shown
 * @return formatted output list
 * @throws InterruptedException if there was a thread related problem getting the data to display
 * @throws ExecutionException if there was any other problem getting the data to display
 */
public List<String> showVpnConfigCLI(Uuid vpnuuid) throws InterruptedException, ExecutionException {
    List<String> result = new ArrayList<>();
    if (vpnuuid == null) {
        result.add("");
        result.add("Displaying VPN config for all VPNs");
        result.add("To display VPN config for a particular VPN, use the following syntax");
        result.add(getshowVpnConfigCLIHelp());
    }
    RpcResult<GetL3VPNOutput> rpcResult = getL3VPN(new GetL3VPNInputBuilder().setId(vpnuuid).build()).get();
    if (rpcResult.isSuccessful()) {
        result.add("");
        result.add(String.format(" %-37s %-37s %-7s ", "VPN ID", "Tenant ID", "RD"));
        result.add("");
        result.add(String.format(" %-80s ", "Import-RTs"));
        result.add("");
        result.add(String.format(" %-80s ", "Export-RTs"));
        result.add("");
        result.add(String.format(" %-76s ", "Subnet IDs"));
        result.add("");
        result.add("------------------------------------------------------------------------------------");
        result.add("");
        List<L3vpnInstances> vpnList = rpcResult.getResult().getL3vpnInstances();
        for (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.VpnInstance vpn : vpnList) {
            String tenantId = vpn.getTenantId() != null ? vpn.getTenantId().getValue() : "\"                 " + "                  \"";
            result.add(String.format(" %-37s %-37s %-7s ", vpn.getId().getValue(), tenantId, vpn.getRouteDistinguisher()));
            result.add("");
            result.add(String.format(" %-80s ", vpn.getImportRT()));
            result.add("");
            result.add(String.format(" %-80s ", vpn.getExportRT()));
            result.add("");
            Uuid vpnid = vpn.getId();
            List<Uuid> subnetList = neutronvpnUtils.getSubnetsforVpn(vpnid);
            if (!subnetList.isEmpty()) {
                for (Uuid subnetuuid : subnetList) {
                    result.add(String.format(" %-76s ", subnetuuid.getValue()));
                }
            } else {
                result.add(String.format(" %-76s ", "\"                                    \""));
            }
            result.add("");
            result.add("----------------------------------------");
            result.add("");
        }
    } else {
        String errortag = rpcResult.getErrors().iterator().next().getTag();
        if (Objects.equals(errortag, "")) {
            result.add("");
            result.add("No VPN has been configured yet");
        } else if (Objects.equals(errortag, "invalid-value")) {
            result.add("");
            result.add("VPN " + vpnuuid.getValue() + " is not present");
        } else {
            result.add("error getting VPN info : " + rpcResult.getErrors());
            result.add(getshowVpnConfigCLIHelp());
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) GetL3VPNOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetL3VPNOutput) L3vpnInstances(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.getl3vpn.output.L3vpnInstances) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) GetL3VPNInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetL3VPNInputBuilder)

Example 47 with Other

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Other in project netvirt by opendaylight.

the class L2GatewayListener method removeL2Device.

private void removeL2Device(Devices l2Device, L2gateway input) {
    final String l2DeviceName = l2Device.getDeviceName();
    L2GatewayDevice l2GwDevice = l2GatewayCache.get(l2DeviceName);
    if (l2GwDevice != null) {
        // Also, do not delete device from cache if it's connected
        if (L2GatewayUtils.isLastL2GatewayBeingDeleted(l2GwDevice)) {
            if (l2GwDevice.isConnected()) {
                l2GwDevice.removeL2GatewayId(input.getUuid());
                // Delete ITM tunnels
                final String hwvtepId = l2GwDevice.getHwvtepNodeId();
                final Set<IpAddress> tunnelIps = l2GwDevice.getTunnelIps();
                jobCoordinator.enqueueJob(hwvtepId, () -> {
                    if (entityOwnershipUtils.isEntityOwner(HwvtepSouthboundConstants.ELAN_ENTITY_TYPE, HwvtepSouthboundConstants.ELAN_ENTITY_NAME)) {
                        LOG.info("Deleting ITM Tunnels for {} connected to cluster node owner", l2DeviceName);
                        for (IpAddress tunnelIp : tunnelIps) {
                            L2GatewayUtils.deleteItmTunnels(itmRpcService, hwvtepId, l2DeviceName, tunnelIp);
                        }
                    } else {
                        LOG.info("ITM Tunnels are not deleted on the cluster node as this is not owner for {}", l2DeviceName);
                    }
                    return null;
                });
            } else {
                l2GatewayCache.remove(l2DeviceName);
                // Cleaning up the config DS
                NodeId nodeId = new NodeId(l2GwDevice.getHwvtepNodeId());
                NodeId psNodeId = HwvtepSouthboundUtils.createManagedNodeId(nodeId, l2DeviceName);
                // FIXME: These should be removed
                MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, HwvtepSouthboundUtils.createInstanceIdentifier(nodeId));
                MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, HwvtepSouthboundUtils.createInstanceIdentifier(psNodeId));
            }
        } else {
            l2GwDevice.removeL2GatewayId(input.getUuid());
            LOG.trace("ITM tunnels are not deleted for {} as this device has other L2gateway associations", l2DeviceName);
        }
    } else {
        LOG.error("Unable to find L2 Gateway details for {}", l2DeviceName);
    }
}
Also used : NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Example 48 with Other

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Other in project openflowplugin by opendaylight.

the class ConntrackCodec method deserializeCtAction.

private void deserializeCtAction(final ByteBuf message, final NxActionConntrackBuilder nxActionConntrackBuilder, final int ctActionsLength) {
    List<CtActions> ctActionsList = new ArrayList<>();
    int processedCtActionsLength = ctActionsLength;
    while (processedCtActionsLength > 0) {
        int startReaderIndex = message.readerIndex();
        if (EncodeConstants.EXPERIMENTER_VALUE == message.readUnsignedShort()) {
            // NAT action
            // reset indices
            message.setIndex(startReaderIndex, message.writerIndex());
            final int startIndex = message.readerIndex();
            int length = deserializeCtHeader(message);
            processedCtActionsLength = processedCtActionsLength - length;
            NxActionNatBuilder nxActionNatBuilder = new NxActionNatBuilder();
            message.skipBytes(2);
            nxActionNatBuilder.setFlags(message.readUnsignedShort());
            int rangePresent = message.readUnsignedShort();
            nxActionNatBuilder.setRangePresent(rangePresent);
            if (0 != (rangePresent & NxActionNatRangePresent.NXNATRANGEIPV4MIN.getIntValue())) {
                InetAddress address = InetAddresses.fromInteger((int) message.readUnsignedInt());
                nxActionNatBuilder.setIpAddressMin(new IpAddress(address.getHostAddress().toCharArray()));
            }
            if (0 != (rangePresent & NxActionNatRangePresent.NXNATRANGEIPV4MAX.getIntValue())) {
                InetAddress address = InetAddresses.fromInteger((int) message.readUnsignedInt());
                nxActionNatBuilder.setIpAddressMax(new IpAddress(address.getHostAddress().toCharArray()));
            }
            if (0 != (rangePresent & NxActionNatRangePresent.NXNATRANGEPROTOMIN.getIntValue())) {
                nxActionNatBuilder.setPortMin(message.readUnsignedShort());
            }
            if (0 != (rangePresent & NxActionNatRangePresent.NXNATRANGEPROTOMAX.getIntValue())) {
                nxActionNatBuilder.setPortMax(message.readUnsignedShort());
            }
            NxActionNatCaseBuilder caseBuilder = new NxActionNatCaseBuilder();
            caseBuilder.setNxActionNat(nxActionNatBuilder.build());
            CtActionsBuilder ctActionsBuilder = new CtActionsBuilder();
            ctActionsBuilder.setOfpactActions(caseBuilder.build());
            ctActionsList.add(ctActionsBuilder.build());
            int pad = length - (message.readerIndex() - startIndex);
            message.skipBytes(pad);
        } else {
            // only other possible action here is currently ct_mark
            // reset indices
            message.setIndex(startReaderIndex, message.writerIndex());
            processedCtActionsLength = processedCtActionsLength - SET_FIELD_LENGTH;
            deserializeCtHeaderWithoutSubtype(message);
            NxActionCtMarkBuilder nxActionCtMarkBuilder = new NxActionCtMarkBuilder();
            nxActionCtMarkBuilder.setCtMark(message.readUnsignedInt());
            NxActionCtMarkCaseBuilder caseBuilder = new NxActionCtMarkCaseBuilder();
            caseBuilder.setNxActionCtMark(nxActionCtMarkBuilder.build());
            CtActionsBuilder ctActionsBuilder = new CtActionsBuilder();
            ctActionsBuilder.setOfpactActions(caseBuilder.build());
            ctActionsList.add(ctActionsBuilder.build());
            // padding
            message.skipBytes(EncodeConstants.SIZE_OF_INT_IN_BYTES);
        }
    }
    nxActionConntrackBuilder.setCtActions(ctActionsList);
}
Also used : NxActionCtMarkCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionCtMarkCaseBuilder) CtActions(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActions) NxActionCtMarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.ct.mark._case.NxActionCtMarkBuilder) ArrayList(java.util.ArrayList) NxActionNatBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.nat._case.NxActionNatBuilder) NxActionNatCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionNatCaseBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) CtActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActionsBuilder) InetAddress(java.net.InetAddress)

Example 49 with Other

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Other in project openflowplugin by opendaylight.

the class OnfExperimenterErrorFactory method deserialize.

@Override
public ErrorMessage deserialize(ByteBuf message) {
    ErrorMessageBuilder builder = new ErrorMessageBuilder();
    builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
    builder.setXid(message.readUnsignedInt());
    int type = message.readUnsignedShort();
    ErrorType errorType = ErrorType.forValue(type);
    if (errorType != null && errorType.equals(ErrorType.EXPERIMENTER)) {
        builder.setType(errorType.getIntValue());
        builder.setTypeString(errorType.getName());
    } else {
        LOG.warn("Deserializing other than {} error message with {}", ErrorType.EXPERIMENTER.getName(), this.getClass().getCanonicalName());
        builder.setType(type);
        builder.setTypeString(UNKNOWN_TYPE);
    }
    int code = message.readUnsignedShort();
    OnfExperimenterErrorCode errorCode = OnfExperimenterErrorCode.forValue(code);
    if (errorCode != null) {
        builder.setCode(errorCode.getIntValue());
        builder.setCodeString(errorCode.getName());
    } else {
        builder.setCode(code);
        builder.setCodeString(UNKNOWN_CODE);
    }
    builder.addAugmentation(ExperimenterIdError.class, new ExperimenterIdErrorBuilder().setExperimenter(new ExperimenterId(message.readUnsignedInt())).build());
    if (message.readableBytes() > 0) {
        byte[] data = new byte[message.readableBytes()];
        message.readBytes(data);
        builder.setData(data);
    }
    return builder.build();
}
Also used : ErrorMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder) ErrorType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ErrorType) OnfExperimenterErrorCode(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.OnfExperimenterErrorCode) ExperimenterIdErrorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdErrorBuilder) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId)

Example 50 with Other

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Other in project openflowplugin by opendaylight.

the class OFDatagramPacketEncoderTest method startUp.

/**
 * Initializes mocks and other objects.
 *
 * @param version openflow protocol wire version
 */
public void startUp(Short version) {
    MockitoAnnotations.initMocks(this);
    out = new ArrayList<>();
    HelloInputBuilder builder = new HelloInputBuilder();
    builder.setVersion(version);
    HelloInput hello = builder.build();
    wrapper = new UdpMessageListenerWrapper(hello, listener, address);
}
Also used : HelloInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput) UdpMessageListenerWrapper(org.opendaylight.openflowjava.protocol.impl.core.connection.UdpMessageListenerWrapper) HelloInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder)

Aggregations

ArrayList (java.util.ArrayList)26 BigInteger (java.math.BigInteger)23 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)13 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)10 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)8 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)7 ExecutionException (java.util.concurrent.ExecutionException)6 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)6 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 Test (org.junit.Test)4 L2vlan (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan)4 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)4 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)4 VrfTablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey)4 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)4 HashSet (java.util.HashSet)3 List (java.util.List)3 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)3