use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.TenantId in project netvirt by opendaylight.
the class VpnSubnetRouteHandlerTest method setupMocks.
private void setupMocks() {
nexthopIp = "10.1.1.25";
idKey = "100:1.10.1.1.24";
poolName = "vpnservices";
elanTag = 2L;
longId = Long.valueOf("100");
nodeConnectorId = buildNodeConnectorId(dpId, 2L);
ipAddress = IpAddressBuilder.getDefaultInstance(nexthopIp);
vpnIntfaces = new VpnInterfacesBuilder().setInterfaceName(interfaceName).setKey(new VpnInterfacesKey(interfaceName)).build();
List<VpnInterfaces> vpnInterfaces = new ArrayList<>();
final List<SubnetToDpn> subToDpn = new ArrayList<>();
final List<Uuid> portList = new ArrayList<>();
final List<PortOpDataEntry> listPortOpDataEntry = new ArrayList<>();
final List<TunnelEndPoints> tunnelEndPoints = new ArrayList<>();
List<Uuid> subnetIdList = new ArrayList<>();
subnetIdList.add(subnetId);
vpnInterfaces.add(vpnIntfaces);
lowerLayerIfList.add(nodeConnectorId.getValue());
portOp = new PortOpDataEntryBuilder().setDpnId(dpId).setKey(new PortOpDataEntryKey(tenantId.getValue())).setSubnetIds(subnetIdList).setPortId(tenantId.getValue()).build();
subnetToDpn = new SubnetToDpnBuilder().setDpnId(dpId).setKey(new SubnetToDpnKey(dpId)).setVpnInterfaces(vpnInterfaces).build();
allocateIdOutput = new AllocateIdOutputBuilder().setIdValue(longId).build();
allocateIdInput = new AllocateIdInputBuilder().setPoolName(poolName).setIdKey(idKey).build();
subToDpn.add(subnetToDpn);
portList.add(portId);
listPortOpDataEntry.add(portOp);
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder ifaceBuilder = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder();
ifaceBuilder.setLowerLayerIf(lowerLayerIfList).setType(L2vlan.class).setAdminStatus(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus.Up).setOperStatus(Interface.OperStatus.Up).setIfIndex(100).setKey(new InterfaceKey(interfaceName)).setName(interfaceName).setPhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress.getDefaultInstance("AA:AA:AA:AA:AA:AA"));
stateInterface = ifaceBuilder.build();
subnetOp = new SubnetOpDataEntryBuilder().setElanTag(elanTag).setNhDpnId(dpId).setSubnetCidr(subnetIp).setSubnetId(subnetId).setKey(new SubnetOpDataEntryKey(subnetId)).setVpnName(interfaceName).setVrfId(primaryRd).setSubnetToDpn(subToDpn).setRouteAdvState(TaskState.Advertised).build();
vpnInstance = new VpnInstanceBuilder().setVpnId(elanTag).setVpnInstanceName(interfaceName).setVrfId(interfaceName).setKey(new VpnInstanceKey(interfaceName)).build();
subnetmap = new SubnetmapBuilder().setSubnetIp(subnetIp).setId(subnetId).setNetworkId(portId).setKey(new SubnetmapKey(subnetId)).setRouterId(portId).setVpnId(subnetId).setTenantId(tenantId).setPortList(portList).build();
portOpData = new PortOpDataBuilder().setPortOpDataEntry(listPortOpDataEntry).build();
dpntePsInfo = new DPNTEPsInfoBuilder().setDPNID(dpId).setUp(true).setKey(new DPNTEPsInfoKey(dpId)).setTunnelEndPoints(tunnelEndPoints).build();
tunlEndPts = new TunnelEndPointsBuilder().setInterfaceName(interfaceName).setVLANID(10).setIpAddress(ipAddress).build();
tunnelEndPoints.add(tunlEndPts);
ipv4Family = new Ipv4FamilyBuilder().setRouteDistinguisher(routeDistinguishers).build();
vpnInstnce = new org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstanceBuilder().setKey(new org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstanceKey(interfaceName)).setVpnInstanceName(interfaceName).setIpv4Family(ipv4Family).build();
networks = new NetworksBuilder().setId(portId).setKey(new NetworksKey(portId)).build();
doReturn(mockReadTx).when(dataBroker).newReadOnlyTransaction();
doReturn(mockWriteTx).when(dataBroker).newWriteOnlyTransaction();
doReturn(Futures.immediateCheckedFuture(null)).when(mockWriteTx).submit();
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.TenantId in project netvirt by opendaylight.
the class PortPairTranslator method buildServiceFunction.
@Nonnull
public static ServiceFunction buildServiceFunction(PortPair portPair, PortPairGroup portPairGroup) {
Preconditions.checkNotNull(portPair, "Port pair must not be null");
Preconditions.checkNotNull(portPairGroup, "Port pair group must not be null");
ServiceFunctionBuilder serviceFunctionBuilder = new ServiceFunctionBuilder();
// Set SF name and tenant-id
serviceFunctionBuilder.setName(new SfName(portPair.getName()));
serviceFunctionBuilder.setTenantId(new TenantId(portPair.getTenantId().getValue()));
// Set SF Type. Setting it to PortPairGroup Type, this will be overridden if user pass
// it through service_function_params
serviceFunctionBuilder.setType(SftTypeName.getDefaultInstance(portPairGroup.getName()));
// If user pass specific param using service_function_parameters, set/override it accordingly
Class transportTypeClass = null;
List<ServiceFunctionParameters> sfParams = portPair.getServiceFunctionParameters();
if (sfParams != null) {
for (ServiceFunctionParameters sfParam : sfParams) {
// There is by default type set to port pair group name, override it if user pass it specific type
if (sfParam.getServiceFunctionParameter().equals(SF_TYPE_PARAM)) {
serviceFunctionBuilder.setType(new SftTypeName(sfParam.getServiceFunctionParameterValue()));
}
if (sfParam.getServiceFunctionParameter().equals(DPL_TRANSPORT_PARAM)) {
transportTypeClass = DPL_TRANSPORT_TYPE.get(sfParam.getServiceFunctionParameterValue());
}
}
}
// Build forward DPL
SfDataPlaneLocatorBuilder sfForwardDplBuilder = new SfDataPlaneLocatorBuilder();
sfForwardDplBuilder.setName(new SfDataPlaneLocatorName(portPair.getName() + DPL_INGRESS_SUFFIX));
sfForwardDplBuilder.setTransport(transportTypeClass == null ? Mac.class : transportTypeClass);
sfForwardDplBuilder.setServiceFunctionForwarder(new SffName(SfcMdsalHelper.NETVIRT_LOGICAL_SFF_NAME));
String forwardPort = portPair.getIngress().getValue();
LogicalInterface forwardInterface = new LogicalInterfaceBuilder().setInterfaceName(forwardPort).build();
sfForwardDplBuilder.setLocatorType(forwardInterface);
// Build reverse DPL
SfDataPlaneLocatorBuilder sfReverseDplBuilder = new SfDataPlaneLocatorBuilder();
sfReverseDplBuilder.setName(new SfDataPlaneLocatorName(portPair.getName() + DPL_EGRESS_SUFFIX));
sfReverseDplBuilder.setTransport(transportTypeClass == null ? Mac.class : transportTypeClass);
sfReverseDplBuilder.setServiceFunctionForwarder(new SffName(SfcMdsalHelper.NETVIRT_LOGICAL_SFF_NAME));
String reversePort = portPair.getEgress().getValue();
LogicalInterface reverseInterface = new LogicalInterfaceBuilder().setInterfaceName(reversePort).build();
sfReverseDplBuilder.setLocatorType(reverseInterface);
// Set all data plane locator
List<SfDataPlaneLocator> sfDataPlaneLocatorList = new ArrayList<>();
sfDataPlaneLocatorList.add(sfForwardDplBuilder.build());
sfDataPlaneLocatorList.add(sfReverseDplBuilder.build());
serviceFunctionBuilder.setSfDataPlaneLocator(sfDataPlaneLocatorList);
return serviceFunctionBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.TenantId in project netvirt by opendaylight.
the class IfMgr method addSubnet.
/**
* Add Subnet.
*
* @param snetId subnet id
* @param name subnet name
* @param tenantId tenant id
* @param gatewayIp gateway ip address
* @param ipVersion IP Version "IPv4 or IPv6"
* @param subnetCidr subnet CIDR
* @param ipV6AddressMode Address Mode of IPv6 Subnet
* @param ipV6RaMode RA Mode of IPv6 Subnet.
*/
public void addSubnet(Uuid snetId, String name, Uuid tenantId, IpAddress gatewayIp, String ipVersion, IpPrefix subnetCidr, String ipV6AddressMode, String ipV6RaMode) {
// in expanded form and are used during Neighbor Discovery Support.
if (gatewayIp != null) {
Ipv6Address addr = new Ipv6Address(InetAddresses.forString(gatewayIp.getIpv6Address().getValue()).getHostAddress());
gatewayIp = new IpAddress(addr);
}
VirtualSubnet snet = VirtualSubnet.builder().subnetUUID(snetId).tenantID(tenantId).name(name).gatewayIp(gatewayIp).subnetCidr(subnetCidr).ipVersion(ipVersion).ipv6AddressMode(ipV6AddressMode).ipv6RAMode(ipV6RaMode).build();
vsubnets.put(snetId, snet);
List<VirtualPort> intfList = unprocessedSubnetIntfs.remove(snetId);
if (intfList == null) {
LOG.debug("No unprocessed interfaces for the subnet {}", snetId);
return;
}
synchronized (intfList) {
for (VirtualPort intf : intfList) {
if (intf != null) {
intf.setSubnet(snetId, snet);
snet.addInterface(intf);
VirtualRouter rtr = intf.getRouter();
if (rtr != null) {
rtr.addSubnet(snet);
}
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.TenantId in project netvirt by opendaylight.
the class NeutronvpnManager method updateVpnMaps.
private void updateVpnMaps(Uuid vpnId, String name, Uuid router, Uuid tenantId, List<Uuid> networks) {
VpnMapBuilder builder;
boolean isLockAcquired = false;
InstanceIdentifier<VpnMap> vpnMapIdentifier = InstanceIdentifier.builder(VpnMaps.class).child(VpnMap.class, new VpnMapKey(vpnId)).build();
try {
Optional<VpnMap> optionalVpnMap = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnMapIdentifier);
if (optionalVpnMap.isPresent()) {
builder = new VpnMapBuilder(optionalVpnMap.get());
} else {
builder = new VpnMapBuilder().setKey(new VpnMapKey(vpnId)).setVpnId(vpnId);
}
if (name != null) {
builder.setName(name);
}
if (tenantId != null) {
builder.setTenantId(tenantId);
}
if (router != null) {
builder.setRouterId(router);
}
if (networks != null) {
List<Uuid> nwList = builder.getNetworkIds();
if (nwList == null) {
nwList = new ArrayList<>();
}
nwList.addAll(networks);
builder.setNetworkIds(nwList);
}
isLockAcquired = vpnLock.tryLock(vpnId, LOCK_WAIT_TIME, TimeUnit.SECONDS);
LOG.debug("Creating/Updating vpnMaps node: {} ", vpnId.getValue());
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnMapIdentifier, builder.build());
LOG.debug("VPNMaps DS updated for VPN {} ", vpnId.getValue());
} catch (ReadFailedException | TransactionCommitFailedException e) {
LOG.error("UpdateVpnMaps failed for node: {} ", vpnId.getValue());
} finally {
if (isLockAcquired) {
vpnLock.unlock(vpnId);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.TenantId 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;
}
Aggregations