use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Other in project lispflowmapping by opendaylight.
the class MapReplySerializationTest method deserialize__All.
@Test
public void deserialize__All() throws Exception {
MapReply mr = MapReplySerializer.getInstance().deserialize(hexToByteBuffer("20 00 00 02 00 00 " + "00 00 00 00 00 02 00 00 " + "00 02 02 20 00 00 00 00 " + "00 01 01 02 03 04 01 02 " + "03 04 00 06 00 01 0a 0a " + "0a 0a 04 03 02 01 00 01 " + "00 02 00 01 00 02 00 03 " + "00 04 00 05 00 06 00 07 00 08 00 00 00 00 00 10 30 00 00 02 00 01 04 03 00 00"));
assertEquals(2, mr.getNonce().longValue());
assertArrayEquals(new byte[] { 1, 2, 3, 4 }, ((Ipv4PrefixBinary) mr.getMappingRecordItem().get(0).getMappingRecord().getEid().getAddress()).getIpv4AddressBinary().getValue());
// XXX Why here normalized and other cases not normalized?
assertArrayEquals(new byte[] { 4, 3, 0, 0 }, ((Ipv4PrefixBinary) mr.getMappingRecordItem().get(1).getMappingRecord().getEid().getAddress()).getIpv4AddressBinary().getValue());
assertEquals(false, mr.getMappingRecordItem().get(0).getMappingRecord().isAuthoritative());
assertEquals(true, mr.getMappingRecordItem().get(1).getMappingRecord().isAuthoritative());
assertEquals(Action.NoAction, mr.getMappingRecordItem().get(0).getMappingRecord().getAction());
assertEquals(Action.NativelyForward, mr.getMappingRecordItem().get(1).getMappingRecord().getAction());
assertEquals(0, mr.getMappingRecordItem().get(0).getMappingRecord().getMapVersion().shortValue());
assertEquals(2, mr.getMappingRecordItem().get(1).getMappingRecord().getMapVersion().shortValue());
assertEquals(32, MaskUtil.getMaskForAddress(mr.getMappingRecordItem().get(0).getMappingRecord().getEid().getAddress()));
assertEquals(16, MaskUtil.getMaskForAddress(mr.getMappingRecordItem().get(1).getMappingRecord().getEid().getAddress()));
assertEquals(2, mr.getMappingRecordItem().get(0).getMappingRecord().getRecordTtl().byteValue());
assertEquals(0, mr.getMappingRecordItem().get(1).getMappingRecord().getRecordTtl().byteValue());
assertArrayEquals(new byte[] { 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8 }, ((Ipv6Binary) mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(1).getRloc().getAddress()).getIpv6Binary().getValue());
assertArrayEquals(new byte[] { 10, 10, 10, 10 }, ((Ipv4Binary) mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).getRloc().getAddress()).getIpv4Binary().getValue());
assertEquals(1, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).getPriority().byteValue());
assertEquals(2, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).getWeight().byteValue());
assertEquals(3, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).getMulticastPriority().byteValue());
assertEquals(4, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).getMulticastWeight().byteValue());
assertEquals(4, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(1).getPriority().byteValue());
assertEquals(3, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(1).getWeight().byteValue());
assertEquals(2, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(1).getMulticastPriority().byteValue());
assertEquals(1, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(1).getMulticastWeight().byteValue());
assertEquals(true, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).isLocalLocator());
assertEquals(true, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).isRlocProbed());
assertEquals(false, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).isRouted());
assertEquals(false, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(1).isLocalLocator());
assertEquals(false, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(1).isRlocProbed());
assertEquals(true, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(1).isRouted());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Other in project genius by opendaylight.
the class LockManagerTest method testLockAndReLockSameAgain.
@Test
public // lock() RPC will infinitely retry, and it will only come out when the key is unlocked
void testLockAndReLockSameAgain() throws InterruptedException, ExecutionException, TimeoutException {
LockInput lockInput = new LockInputBuilder().setLockName("testLock").build();
assertVoidRpcSuccess(lockManager.lock(lockInput));
runUnlockTimerTask("testLock", 3000);
// This will retry infinitely since the other lock is not released!
// After 5 seconds, the parallel thread will unlock the key, and the below TC will pass
assertVoidRpcSuccess(lockManager.lock(lockInput));
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Other in project genius by opendaylight.
the class OvsdbTepRemoveConfigHelper method removeTepReceivedFromOvsdb.
/**
* Removes the TEP from ITM configuration/operational Datastore in one of the following cases.
* 1) default transport zone
* 2) Configured transport zone
* 3) Unhosted transport zone
* Function checks for above three cases and calls other sub-function to remove the TEP
*
* @param tepIp TEP-IP address in string
* @param strDpnId bridge datapath ID in string
* @param tzName transport zone name in string
* @param dataBroker data broker handle to perform operations on config/operational datastore
* @param wrTx WriteTransaction object
*/
public static void removeTepReceivedFromOvsdb(String tepIp, String strDpnId, String tzName, DataBroker dataBroker, WriteTransaction wrTx) {
BigInteger dpnId = BigInteger.valueOf(0);
LOG.trace("Remove TEP: TEP-IP: {}, TZ name: {}, DPID: {}", tepIp, tzName, strDpnId);
if (strDpnId != null && !strDpnId.isEmpty()) {
dpnId = MDSALUtil.getDpnId(strDpnId);
}
// Get tep IP
IpAddress tepIpAddress = IpAddressBuilder.getDefaultInstance(tepIp);
TransportZone transportZone = null;
// Case: TZ name is not given from OVS's other_config parameters.
if (tzName == null) {
tzName = ITMConstants.DEFAULT_TRANSPORT_ZONE;
// add TEP into default-TZ
transportZone = ItmUtils.getTransportZoneFromConfigDS(tzName, dataBroker);
if (transportZone == null) {
LOG.error("Error: default-transport-zone is not yet created.");
return;
}
LOG.trace("Remove TEP from default-transport-zone.");
} else {
// Case: Add TEP into corresponding TZ created from Northbound.
transportZone = ItmUtils.getTransportZoneFromConfigDS(tzName, dataBroker);
if (transportZone == null) {
// Case: TZ is not configured from Northbound, then add TEP into
// "teps-in-not-hosted-transport-zone"
LOG.trace("Removing TEP from teps-in-not-hosted-transport-zone list.");
removeUnknownTzTepFromTepsNotHosted(tzName, tepIpAddress, dpnId, dataBroker, wrTx);
return;
} else {
LOG.trace("Remove TEP from transport-zone already configured by Northbound.");
}
}
// Remove TEP from (default transport-zone) OR (transport-zone already configured by Northbound)
// Get subnet list of corresponding TZ created from Northbound.
List<Subnets> subnetList = transportZone.getSubnets();
if (subnetList == null || subnetList.isEmpty()) {
LOG.trace("No subnet list in transport-zone. Nothing to do.");
} else {
IpPrefix subnetMaskObj = ItmUtils.getDummySubnet();
List<Vteps> vtepList = null;
// subnet list already exists case; check for dummy-subnet
for (Subnets subnet : subnetList) {
if (subnet.getKey().getPrefix().equals(subnetMaskObj)) {
LOG.trace("Subnet exists in the subnet list of transport-zone {}.", tzName);
// get vtep list of existing subnet
vtepList = subnet.getVteps();
break;
}
}
if (vtepList == null || vtepList.isEmpty()) {
// case: vtep list does not exist or it has no elements
LOG.trace("No vtep list in subnet list of transport-zone. Nothing to do.");
} else {
// case: vtep list has elements
boolean vtepFound = false;
Vteps oldVtep = null;
for (Vteps vtep : vtepList) {
if (vtep.getDpnId().equals(dpnId)) {
vtepFound = true;
oldVtep = vtep;
break;
}
}
if (vtepFound) {
// vtep is found, update it with tep-ip
LOG.trace("Remove TEP from vtep list in subnet list of transport-zone.");
dpnId = oldVtep.getDpnId();
String portName = oldVtep.getPortname();
removeVtepFromTZConfig(subnetMaskObj, tzName, dpnId, portName, wrTx);
} else {
LOG.trace("TEP is not found in the vtep list in subnet list of transport-zone. Nothing to do.");
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Other in project genius by opendaylight.
the class FlowBasedServicesUtils method installInterfaceIngressFlow.
public static void installInterfaceIngressFlow(BigInteger dpId, Interface iface, BoundServices boundServiceNew, WriteTransaction writeTransaction, List<MatchInfo> matches, int lportTag, short tableId) {
List<Instruction> instructions = boundServiceNew.getAugmentation(StypeOpenflow.class).getInstruction();
int serviceInstructionsSize = instructions != null ? instructions.size() : 0;
List<Instruction> instructionSet = new ArrayList<>();
int vlanId = 0;
IfL2vlan l2vlan = iface.getAugmentation(IfL2vlan.class);
if (l2vlan != null && l2vlan.getVlanId() != null) {
vlanId = l2vlan.getVlanId().getValue();
}
if (vlanId != 0) {
// incrementing instructionSize and using it as actionKey. Because
// it won't clash with any other instructions
int actionKey = ++serviceInstructionsSize;
instructionSet.add(MDSALUtil.buildAndGetPopVlanActionInstruction(actionKey, ++serviceInstructionsSize));
}
if (lportTag != 0L) {
BigInteger[] metadataValues = IfmUtil.mergeOpenflowMetadataWriteInstructions(instructions);
short index = boundServiceNew.getServicePriority();
BigInteger metadata = MetaDataUtil.getMetaDataForLPortDispatcher(lportTag, ++index, metadataValues[0], isExternal(iface));
BigInteger metadataMask = MetaDataUtil.getMetaDataMaskForLPortDispatcher(MetaDataUtil.METADATA_MASK_SERVICE_INDEX, MetaDataUtil.METADATA_MASK_LPORT_TAG_SH_FLAG, metadataValues[1]);
instructionSet.add(MDSALUtil.buildAndGetWriteMetadaInstruction(metadata, metadataMask, ++serviceInstructionsSize));
}
if (instructions != null && !instructions.isEmpty()) {
for (Instruction info : instructions) {
// Skip meta data write as that is handled already
if (info.getInstruction() instanceof WriteMetadataCase) {
continue;
} else if (info.getInstruction() instanceof WriteActionsCase) {
info = MDSALUtil.buildWriteActionsInstruction(ActionConverterUtil.convertServiceActionToFlowAction(((WriteActionsCase) info.getInstruction()).getWriteActions().getAction()));
} else if (info.getInstruction() instanceof ApplyActionsCase) {
info = MDSALUtil.buildApplyActionsInstruction(ActionConverterUtil.convertServiceActionToFlowAction(((ApplyActionsCase) info.getInstruction()).getApplyActions().getAction()));
}
instructionSet.add(info);
}
}
String serviceRef = boundServiceNew.getServiceName();
String flowRef = getFlowRef(dpId, NwConstants.VLAN_INTERFACE_INGRESS_TABLE, iface.getName(), boundServiceNew.getServicePriority());
StypeOpenflow stypeOpenflow = boundServiceNew.getAugmentation(StypeOpenflow.class);
Flow ingressFlow = MDSALUtil.buildFlowNew(tableId, flowRef, stypeOpenflow.getFlowPriority(), serviceRef, 0, 0, stypeOpenflow.getFlowCookie(), matches, instructionSet);
installFlow(dpId, ingressFlow, writeTransaction);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Other in project genius by opendaylight.
the class SouthboundUtils method addTunnelPortToBridge.
private void addTunnelPortToBridge(IfTunnel ifTunnel, InstanceIdentifier<?> bridgeIid, Interface iface, String portName) {
LOG.debug("adding tunnel port {} to bridge {}", portName, bridgeIid);
Class<? extends InterfaceTypeBase> type = TUNNEL_TYPE_MAP.get(ifTunnel.getTunnelInterfaceType());
if (type == null) {
LOG.warn("Unknown Tunnel Type obtained while creating interface: {}", iface);
return;
}
int vlanId = 0;
IfL2vlan ifL2vlan = iface.getAugmentation(IfL2vlan.class);
if (ifL2vlan != null && ifL2vlan.getVlanId() != null) {
vlanId = ifL2vlan.getVlanId().getValue();
}
Map<String, String> options = Maps.newHashMap();
// Options common to any kind of tunnel
if (BooleanUtils.isTrue(ifTunnel.isTunnelSourceIpFlow())) {
options.put(TUNNEL_OPTIONS_LOCAL_IP, TUNNEL_OPTIONS_VALUE_FLOW);
} else {
IpAddress localIp = ifTunnel.getTunnelSource();
options.put(TUNNEL_OPTIONS_LOCAL_IP, String.valueOf(localIp.getValue()));
}
if (BooleanUtils.isTrue(ifTunnel.isTunnelRemoteIpFlow())) {
options.put(TUNNEL_OPTIONS_REMOTE_IP, TUNNEL_OPTIONS_VALUE_FLOW);
} else {
IpAddress remoteIp = ifTunnel.getTunnelDestination();
options.put(TUNNEL_OPTIONS_REMOTE_IP, String.valueOf(remoteIp.getValue()));
}
// Specific options for each type of tunnel
if (ifTunnel.getTunnelInterfaceType().equals(TunnelTypeMplsOverGre.class)) {
options.put(TUNNEL_OPTIONS_PKT_TYPE, TUNNEL_OPTIONS_VALUE_LEGACY_L3);
} else {
options.put(TUNNEL_OPTIONS_KEY, TUNNEL_OPTIONS_VALUE_FLOW);
}
if (ifTunnel.getTunnelInterfaceType().equals(TunnelTypeVxlanGpe.class)) {
options.put(TUNNEL_OPTIONS_EXTS, TUNNEL_OPTIONS_VALUE_GPE);
options.put(TUNNEL_OPTIONS_NSI, TUNNEL_OPTIONS_VALUE_FLOW);
options.put(TUNNEL_OPTIONS_NSP, TUNNEL_OPTIONS_VALUE_FLOW);
options.put(TUNNEL_OPTIONS_NSHC1, TUNNEL_OPTIONS_VALUE_FLOW);
options.put(TUNNEL_OPTIONS_NSHC2, TUNNEL_OPTIONS_VALUE_FLOW);
options.put(TUNNEL_OPTIONS_NSHC3, TUNNEL_OPTIONS_VALUE_FLOW);
options.put(TUNNEL_OPTIONS_NSHC4, TUNNEL_OPTIONS_VALUE_FLOW);
// VxLAN-GPE interfaces will not use the default UDP port to avoid
// problems with other meshes
options.put(TUNNEL_OPTIONS_DESTINATION_PORT, TUNNEL_OPTIONS_VALUE_GPE_DESTINATION_PORT);
}
if (ifTunnel.getTunnelOptions() != null) {
for (TunnelOptions tunOpt : ifTunnel.getTunnelOptions()) {
options.putIfAbsent(tunOpt.getTunnelOption(), tunOpt.getValue());
}
}
addTerminationPoint(bridgeIid, portName, vlanId, type, options, ifTunnel);
}
Aggregations