import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import org.opendaylight.controller.liblldp.Packet;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.endpoint.endpoint.type.Interface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.endpoint.endpoint.type.IpAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.monitor.configs.MonitoringInfo;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetInterfaceFromIfIndexInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetInterfaceFromIfIndexInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetInterfaceFromIfIndexOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.arputil.rev151126.OdlArputilService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.arputil.rev151126.SendArpRequestInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.arputil.rev151126.SendArpRequestInputBuilder;
BigInteger metadata = packetReceived.getMatch().getMetadata().getMetadata();
int portTag = MetaDataUtil.getLportFromMetadata(metadata).intValue();
String interfaceName = null;
- NodeConnectorId connId = packetReceived.getMatch().getInPort();
-// try {
-// interfaceName = serviceProvider.getInterfaceManager().getInterfaceNameForInterfaceTag(portTag);
-// } catch(InterfaceNotFoundException e) {
-// LOG.warn("Error retrieving interface Name for tag {}", portTag, e);
-// }
+
+ try {
+ GetInterfaceFromIfIndexInput input = new GetInterfaceFromIfIndexInputBuilder().setIfIndex(portTag).build();
+ Future<RpcResult<GetInterfaceFromIfIndexOutput>> output = serviceProvider.getInterfaceManager().getInterfaceFromIfIndex(input);
+ RpcResult<GetInterfaceFromIfIndexOutput> result = output.get();
+ if(result.isSuccessful()) {
+ GetInterfaceFromIfIndexOutput ifIndexOutput = result.getResult();
+ interfaceName = ifIndexOutput.getInterfaceName();
+ } else {
+ LOG.warn("RPC call to get interface name for if index {} failed with errors {}", portTag, result.getErrors());
+ return null;
+ }
+ } catch(InterruptedException | ExecutionException e) {
+ LOG.warn("Error retrieving interface Name for tag {}", portTag, e);
+ }
if(!Strings.isNullOrEmpty(interfaceName)) {
String sourceIp = toStringIpAddress(packet.getSenderProtocolAddress());
String targetIp = toStringIpAddress(packet.getTargetProtocolAddress());
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.endpoint.endpoint.type.Interface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.monitor.configs.MonitoringInfo;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel;
-//import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetDpidFromInterfaceInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetDpidFromInterfaceInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetDpidFromInterfaceOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetInterfaceFromIfIndexInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetInterfaceFromIfIndexInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetInterfaceFromIfIndexOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetPortFromInterfaceInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetPortFromInterfaceInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetPortFromInterfaceOutput;
}
String destInterfaceName = null;
- //TODO: Use latest interface RPC
-// try {
-// destInterfaceName = serviceProvider.getInterfaceManager().getInterfaceNameForInterfaceTag(portTag);
-// } catch(InterfaceNotFoundException e) {
-// LOG.warn("Error retrieving interface Name for tag {}", portTag, e);
-// }
+
+ try {
+ GetInterfaceFromIfIndexInput input = new GetInterfaceFromIfIndexInputBuilder().setIfIndex(portTag).build();
+ Future<RpcResult<GetInterfaceFromIfIndexOutput>> output = serviceProvider.getInterfaceManager().getInterfaceFromIfIndex(input);
+ RpcResult<GetInterfaceFromIfIndexOutput> result = output.get();
+ if(result.isSuccessful()) {
+ GetInterfaceFromIfIndexOutput ifIndexOutput = result.getResult();
+ destInterfaceName = ifIndexOutput.getInterfaceName();
+ } else {
+ LOG.warn("RPC call to get interface name for if index {} failed with errors {}", portTag, result.getErrors());
+ return null;
+ }
+ } catch(InterruptedException | ExecutionException e) {
+ LOG.warn("Error retrieving interface Name for tag {}", portTag, e);
+ }
if(!Strings.isNullOrEmpty(interfaceName)) {
String monitorKey = new StringBuilder().append(interfaceName).append(EtherTypes.LLDP).toString();
return;
}
}catch(InterruptedException | ExecutionException e) {
- LOG.error("Failed to retrieve RPC Result ", e);
+ LOG.error("Failed to retrieve interface service RPC Result ", e);
return;
}
public static final short dhcpServerPort = 67;
public static final int DEFAULT_LEASE_TIME = 86400;
+ public static final String DEFAULT_DOMAIN_NAME = "openstacklocal";
}
<artifactId>mdsalutil-api</artifactId>
<version>${vpnservices.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>neutronvpn-api</artifactId>
+ <version>${vpnservices.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
+ <version>${karaf.shell.console.version}</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.neutron</groupId>
<artifactId>model</artifactId>
<capability>urn:opendaylight:params:xml:ns:yang:dhcpservice:impl?module=dhcpservice-impl&revision=2015-07-10</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28</capability>
<capability>urn:opendaylight:params:xml:ns:yang:mdsalutil:api?module=odl-mdsalutil&revision=2015-04-10</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:neutronvpn:api?module=neutronvpn-api&revision=2015-08-12</capability>
</required-capabilities>
<configuration>
<type xmlns:mdsalutil="urn:opendaylight:params:xml:ns:yang:mdsalutil:api">mdsalutil:odl-mdsalutil</type>
<name>mdsalutil-service</name>
</mdsalutil>
+ <neutronvpn>
+ <type xmlns:neutronvpn="urn:opendaylight:params:xml:ns:yang:neutronvpn:api">neutronvpn:neutronvpn-api</type>
+ <name>neutronvpn</name>
+ </neutronvpn>
</module>
</modules>
</data>
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.dhcpservice;
+
+import org.opendaylight.controller.md.sal.binding.api.ClusteredDataChangeListener;
+
+import org.opendaylight.vpnservice.datastoreutils.AsyncClusteredDataChangeListenerBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.dhcp.config.Configs;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
+import org.opendaylight.vpnservice.datastoreutils.AsyncDataChangeListenerBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.DhcpConfig;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.vpnservice.dhcpservice.api.DHCPMConstants;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DhcpConfigListener extends AsyncClusteredDataChangeListenerBase<DhcpConfig, DhcpConfigListener> implements AutoCloseable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(DhcpConfigListener.class);
+
+ private ListenerRegistration<DataChangeListener> listenerRegistration;
+ private DhcpManager dhcpManager;
+
+ public DhcpConfigListener(final DataBroker db, final DhcpManager dhcpMgr) {
+ super(DhcpConfig.class, DhcpConfigListener.class);
+ dhcpManager = dhcpMgr;
+ registerListener(db);
+ }
+
+ private void registerListener(final DataBroker db) {
+ try {
+ listenerRegistration = db.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
+ getWildCardPath(), DhcpConfigListener.this, AsyncDataBroker.DataChangeScope.SUBTREE);
+ } catch (final Exception e) {
+ LOG.error("NodeListener: DataChange listener registration fail!", e);
+ throw new IllegalStateException("NodeListener: registration Listener failed.", e);
+ }
+ }
+
+ protected InstanceIdentifier<DhcpConfig> getWildCardPath() {
+ return InstanceIdentifier.create(DhcpConfig.class);
+ }
+
+ @Override
+ public void close() throws Exception {
+ if (listenerRegistration != null) {
+ try {
+ listenerRegistration.close();
+ } catch (final Exception e) {
+ LOG.error("Error when cleaning up DhcpConfigListener.", e);
+ }
+ listenerRegistration = null;
+ }
+ LOG.debug("DhcpConfig Listener Closed");
+ }
+
+ @Override
+ protected void remove(InstanceIdentifier<DhcpConfig> identifier, DhcpConfig del) {
+ LOG.trace("DhcpConfig removed: {}", del);
+ updateConfig(null);
+ }
+
+ @Override
+ protected void update(InstanceIdentifier<DhcpConfig> identifier, DhcpConfig original, DhcpConfig update) {
+ LOG.trace("DhcpConfig changed to {}", update);
+ updateConfig(update);
+ }
+
+ @Override
+ protected void add(InstanceIdentifier<DhcpConfig> identifier, DhcpConfig add) {
+ LOG.trace("DhcpConfig added {}", add);
+ updateConfig(add);
+ }
+
+ private void updateConfig(DhcpConfig update) {
+ //TODO: Update operational with actual values
+ if(update == null || update.getConfigs() == null || update.getConfigs().isEmpty()) {
+ dhcpManager.setLeaseDuration(DHCPMConstants.DEFAULT_LEASE_TIME);
+ dhcpManager.setDefaultDomain(DHCPMConstants.DEFAULT_DOMAIN_NAME);
+ return;
+ }
+ Configs config = update.getConfigs().get(0);
+ if(config.getLeaseDuration() != null) {
+ dhcpManager.setLeaseDuration(config.getLeaseDuration());
+ }
+ if(config.getDefaultDomain() != null) {
+ dhcpManager.setDefaultDomain(config.getDefaultDomain());
+ //TODO: What to do if string is ""
+ }
+ }
+
+ @Override
+ protected ClusteredDataChangeListener getDataChangeListener() {
+ return DhcpConfigListener.this;
+ }
+
+ @Override
+ protected DataChangeScope getDataChangeScope() {
+ return AsyncDataBroker.DataChangeScope.BASE;
+ }
+}
*/
package org.opendaylight.vpnservice.dhcpservice;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.SubnetKey;
+import org.opendaylight.vpnservice.neutronvpn.interfaces.INeutronVpnManager;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.SubnetKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets;
import com.google.common.base.Optional;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
private int dhcpOptLeaseTime = 0;
private int dhcpOptRenewalTime = 0;
private int dhcpOptRebindingTime = 0;
- private String dhcpOptDefDomainName = "openstacklocal";
+ private String dhcpOptDefDomainName;
+ private INeutronVpnManager neutronVpnService;
private static final FutureCallback<Void> DEFAULT_CALLBACK =
new FutureCallback<Void>() {
this.mdsalUtil = mdsalManager;
}
+ public void setNeutronVpnService(INeutronVpnManager neutronVpnService) {
+ logger.debug("Setting NeutronVpn dependency");
+ this.neutronVpnService = neutronVpnService;
+ }
+
@Override
public void close() throws Exception {
logger.info("DHCP Manager Closed");
}
public Subnet getNeutronSubnet(Port nPort) {
- /* TODO: Once NeutronVpn is merged, use it to get Subnet
if (nPort != null) {
try {
return neutronVpnService.getNeutronSubnet(nPort.getFixedIps().get(0).getSubnetId());
logger.warn("Failed to get Neutron Subnet from Port: {}", e);
}
}
- */
- if (nPort.getFixedIps() != null && !nPort.getFixedIps().isEmpty()) {
- InstanceIdentifier<Subnet> sIid =
- InstanceIdentifier.create(Neutron.class).child(Subnets.class)
- .child(Subnet.class, new SubnetKey(nPort.getFixedIps().get(0).getSubnetId()));
- Optional<Subnet> optSubnet = MDSALUtil.read(LogicalDatastoreType.CONFIGURATION, sIid, broker);
- if (optSubnet.isPresent()) {
- return optSubnet.get();
- }
- }
return null;
}
public Port getNeutronPort(String name) {
- // TODO Once NeutronVpn is merged, use it to get port
- //return neutronVpnService.getNeutronPort(name);
- InstanceIdentifier<Ports> pIid = InstanceIdentifier.create(Neutron.class).child(Ports.class);
- Optional<Ports> optPorts = MDSALUtil.read(LogicalDatastoreType.CONFIGURATION, pIid, broker);
- if(optPorts.isPresent()) {
- for(Port port: optPorts.get().getPort()) {
- if(port.getUuid().getValue().startsWith(name.substring(3))) {
- return port;
- }
- }
- }
- return null;
+ return neutronVpnService.getNeutronPort(name);
}
}
*/
package org.opendaylight.vpnservice.dhcpservice;
-import java.math.BigInteger;
+import org.opendaylight.vpnservice.neutronvpn.interfaces.INeutronVpnManager;
import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
private NotificationProviderService notificationService;
private DhcpManager dhcpManager;
private NodeListener dhcpNodeListener;
+ private INeutronVpnManager neutronVpnManager;
+ private DhcpConfigListener dhcpConfigListener;
@Override
public void onSessionInitiated(ProviderContext session) {
final PacketProcessingService pktProcessingService = session.getRpcService(PacketProcessingService.class);
dhcpManager = new DhcpManager(dataBroker);
dhcpManager.setMdsalManager(mdsalManager);
+ dhcpManager.setNeutronVpnService(neutronVpnManager);
dhcpPktHandler = new DhcpPktHandler(dataBroker, dhcpManager);
dhcpPktHandler.setPacketProcessingService(pktProcessingService);
packetListener = notificationService.registerNotificationListener(dhcpPktHandler);
dhcpNodeListener = new NodeListener(dataBroker, dhcpManager);
+ dhcpConfigListener = new DhcpConfigListener(dataBroker, dhcpManager);
} catch (Exception e) {
LOG.error("Error initializing services", e);
}
this.mdsalManager = mdsalManager;
}
+ public void setNeutronVpnManager(INeutronVpnManager neutronVpnManager) {
+ this.neutronVpnManager = neutronVpnManager;
+ }
+
@Override
public void close() throws Exception {
if(packetListener != null) {
DhcpProvider dhcpProvider = new DhcpProvider();
dhcpProvider.setNotificationProviderService(getNotificationServiceDependency());
dhcpProvider.setMdsalManager(getMdsalutilDependency());
+ dhcpProvider.setNeutronVpnManager(getNeutronvpnDependency());
getBrokerDependency().registerProvider(dhcpProvider);
return dhcpProvider;
}
import config { prefix config; revision-date 2013-04-05; }
import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;}
import odl-mdsalutil { prefix odl-mdsal; revision-date 2015-04-10;}
+ import neutronvpn-api { prefix nvpn; revision-date 2015-08-12;}
description
"Service definition for dhcpservice project";
}
}
}
+
+ container neutronvpn {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity nvpn:neutronvpn-api;
+ }
+ }
+ }
}
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.overlay.rev150105.TunnelTypeVxlan;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.GetTunnelInterfaceNameOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.ItmRpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.fibmanager.rev150330.FibEntries;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.fibmanager.rev150330.fibentries.VrfTables;
private NexthopManager nextHopManager;
private ItmRpcService itmManager;
private OdlInterfaceRpcService interfaceManager;
-
- private static final short L3_FIB_TABLE = 21;
- private static final short L3_LFIB_TABLE = 20;
- private static final short L3_PROTOCOL_TABLE = 36;
- private static final short L3_INTERFACE_TABLE = 80;
- public static final short LPORT_DISPATCHER_TABLE = 30;
private static final BigInteger COOKIE_VM_LFIB_TABLE = new BigInteger("8000002", 16);
private static final BigInteger COOKIE_VM_FIB_TABLE = new BigInteger("8000003", 16);
private static final int DEFAULT_FIB_FLOW_PRIORITY = 10;
private static final BigInteger METADATA_MASK_CLEAR = new BigInteger("000000FFFFFFFFFF", 16);
private static final BigInteger CLEAR_METADATA = BigInteger.valueOf(0);
+ public static final BigInteger COOKIE_TUNNEL = new BigInteger("9000000", 16);
private static final FutureCallback<Void> DEFAULT_CALLBACK =
Preconditions.checkNotNull(vpnInstance.getVpnId(), "Vpn Instance with rd " + vpnInstance.getVrfId() + "has null vpnId!");
Collection<VpnToDpnList> vpnToDpnList = vpnInstance.getVpnToDpnList();
+ BigInteger localDpnId = createLocalFibEntry(vpnInstance.getVpnId(),
+ vrfTableKey.getRouteDistinguisher(), vrfEntry);
if (vpnToDpnList != null) {
- BigInteger localDpnId = createLocalFibEntry(vpnInstance.getVpnId(),
- vrfTableKey.getRouteDistinguisher(), vrfEntry);
for (VpnToDpnList curDpn : vpnToDpnList) {
if (!curDpn.getDpnId().equals(localDpnId)) {
createRemoteFibEntry(localDpnId, curDpn.getDpnId(), vpnInstance.getVpnId(),
}
public void createTerminatingServiceActions( BigInteger destDpId, int label, List<ActionInfo> actionsInfos) {
- // FIXME
-/* List<MatchInfo> mkMatches = new ArrayList<MatchInfo>();
+ List<MatchInfo> mkMatches = new ArrayList<MatchInfo>();
LOG.info("create terminatingServiceAction on DpnId = {} and serviceId = {} and actions = {}", destDpId , label,actionsInfos);
// Matching metadata
- mkMatches.add(new MatchInfo(MatchFieldType.tunnel_id, new BigInteger[] {
- MetaDataUtil.getTunnelIdWithValidVniBitAndVniSet(label),
- MetaDataUtil.METADA_MASK_TUNNEL_ID }));
+ // FIXME vxlan vni bit set is not working properly with OVS.need to revisit
+ mkMatches.add(new MatchInfo(MatchFieldType.tunnel_id, new BigInteger[] {BigInteger.valueOf(label)}));
List<InstructionInfo> mkInstructions = new ArrayList<InstructionInfo>();
mkInstructions.add(new InstructionInfo(InstructionType.write_actions, actionsInfos));
- FlowEntity terminatingServiceTableFlowEntity = MDSALUtil.buildFlowEntity(destDpId,ITMConstants.TERMINATING_SERVICE_TABLE,
- getFlowRef(destDpId, ITMConstants.TERMINATING_SERVICE_TABLE,label), 5, String.format("%s:%d","TST Flow Entry ",label),
- 0, 0, ITMConstants.COOKIE_ITM.add(BigInteger.valueOf(label)),mkMatches, mkInstructions);
+ FlowEntity terminatingServiceTableFlowEntity = MDSALUtil.buildFlowEntity(destDpId, NwConstants.INTERNAL_TUNNEL_TABLE,
+ getFlowRef(destDpId, NwConstants.INTERNAL_TUNNEL_TABLE,label), 5, String.format("%s:%d","TST Flow Entry ",label),
+ 0, 0, COOKIE_TUNNEL.add(BigInteger.valueOf(label)),mkMatches, mkInstructions);
- mdsalManager.installFlow(terminatingServiceTableFlowEntity);*/
+ mdsalManager.installFlow(terminatingServiceTableFlowEntity);
}
private void removeTunnelTableEntry(BigInteger dpId, long label) {
- // FIXME
- // itmManager.removeTerminatingServiceAction(dpId, (int)label);
-
- // LOG.debug("Terminating service Entry for dpID {} : label : {} removed successfully {}",dpId, label);
+ FlowEntity flowEntity;
+ LOG.info("remove terminatingServiceActions called with DpnId = {} and label = {}", dpId , label);
+ List<MatchInfo> mkMatches = new ArrayList<MatchInfo>();
+ // Matching metadata
+ mkMatches.add(new MatchInfo(MatchFieldType.tunnel_id, new BigInteger[] {
+ MetaDataUtil.getTunnelIdWithValidVniBitAndVniSet((int)label),
+ MetaDataUtil.METADA_MASK_TUNNEL_ID }));
+ flowEntity = MDSALUtil.buildFlowEntity(dpId,
+ NwConstants.INTERNAL_TUNNEL_TABLE,
+ getFlowRef(dpId, NwConstants.INTERNAL_TUNNEL_TABLE, (int)label),
+ 5, String.format("%s:%d","TST Flow Entry ",label), 0, 0,
+ COOKIE_TUNNEL.add(BigInteger.valueOf(label)), mkMatches, null);
+ mdsalManager.removeFlow(flowEntity);
+ LOG.debug("Terminating service Entry for dpID {} : label : {} removed successfully {}",dpId, label);
}
public BigInteger deleteLocalFibEntry(Long vpnId, String rd, VrfEntry vrfEntry) {
vrfEntry.getDestPrefix(), rd);
return;
}
- List<ActionInfo> actionInfos = nextHopManager.getEgressActionsForInterface(tunnelInterface);
+ List<ActionInfo> actionInfos = new ArrayList<>();
Class<? extends TunnelTypeBase> tunnel_type = getTunnelType(tunnelInterface);
if (tunnel_type.equals(TunnelTypeMplsOverGre.class)) {
LOG.debug("Push label action for prefix {}", vrfEntry.getDestPrefix());
} else {
int label = vrfEntry.getLabel().intValue();
BigInteger tunnelId;
+ // FIXME vxlan vni bit set is not working properly with OVS.need to revisit
if(tunnel_type.equals(TunnelTypeVxlan.class)) {
- tunnelId = MetaDataUtil.getTunnelIdWithValidVniBitAndVniSet(label);
+ tunnelId = BigInteger.valueOf(label);
} else {
tunnelId = BigInteger.valueOf(label);
}
LOG.debug("adding set tunnel id action for label {}", label);
- actionInfos.add(new ActionInfo(ActionType.set_field_tunnel_id, new BigInteger[] {
- tunnelId, MetaDataUtil.METADA_MASK_VALID_TUNNEL_ID_BIT_AND_TUNNEL_ID }));
+ actionInfos.add(new ActionInfo(ActionType.set_field_tunnel_id, new BigInteger[]{
+ tunnelId}));
}
+ actionInfos.addAll(nextHopManager.getEgressActionsForInterface(tunnelInterface));
/*
List<ActionInfo> actionInfos = resolveAdjacency(localDpnId, remoteDpnId, vpnId, vrfEntry);
if(actionInfos == null) {
MetaDataUtil.METADA_MASK_VALID_TUNNEL_ID_BIT_AND_TUNNEL_ID }));
}
**/
- makeConnectedRoute(remoteDpnId, vpnId, vrfEntry, rd, actionInfos, NwConstants.ADD_FLOW);
+ makeConnectedRoute(remoteDpnId, vpnId, vrfEntry, rd, actionInfos, NwConstants.ADD_FLOW);
LOG.debug(
"Successfully added fib entry for " + vrfEntry.getDestPrefix() + " vpnId " + vpnId);
}
VpnInstanceOpDataEntry vpnInstance = getVpnInstance(vrfTableKey.getRouteDistinguisher());
Preconditions.checkNotNull(vpnInstance, "Vpn Instance not available!");
Collection<VpnToDpnList> vpnToDpnList = vpnInstance.getVpnToDpnList();
+ BigInteger localDpnId = deleteLocalFibEntry(vpnInstance.getVpnId(),
+ vrfTableKey.getRouteDistinguisher(), vrfEntry);
if (vpnToDpnList != null) {
- BigInteger localDpnId = deleteLocalFibEntry(vpnInstance.getVpnId(),
- vrfTableKey.getRouteDistinguisher(), vrfEntry);
for (VpnToDpnList curDpn : vpnToDpnList) {
if (!curDpn.getDpnId().equals(localDpnId)) {
deleteRemoteRoute(localDpnId, curDpn.getDpnId(), vpnInstance.getVpnId(), vrfTableKey, vrfEntry);
instructions.add(new InstructionInfo(InstructionType.write_actions, actionInfos));
}
- String flowRef = getFlowRef(dpId, L3_FIB_TABLE, rd, destPrefix);
+ String flowRef = getFlowRef(dpId, NwConstants.L3_FIB_TABLE, rd, destPrefix);
FlowEntity flowEntity;
int priority = DEFAULT_FIB_FLOW_PRIORITY + prefixLength;
- flowEntity = MDSALUtil.buildFlowEntity(dpId, L3_FIB_TABLE, flowRef,
+ flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.L3_FIB_TABLE, flowRef,
priority, flowRef, 0, 0,
COOKIE_VM_FIB_TABLE, matches, instructions);
instructions.add(new InstructionInfo(InstructionType.write_actions, actionsInfos));
// Install the flow entry in L3_LFIB_TABLE
- String flowRef = getFlowRef(dpId, L3_LFIB_TABLE, label, nextHop);
+ String flowRef = getFlowRef(dpId, NwConstants.L3_LFIB_TABLE, label, nextHop);
FlowEntity flowEntity;
- flowEntity = MDSALUtil.buildFlowEntity(dpId, L3_LFIB_TABLE, flowRef,
+ flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.L3_LFIB_TABLE, flowRef,
DEFAULT_FIB_FLOW_PRIORITY, flowRef, 0, 0,
COOKIE_VM_LFIB_TABLE, matches, instructions);
final BigInteger COOKIE_TABLE_MISS = new BigInteger("1030000", 16);
// Instruction to goto L3 InterfaceTable
List<InstructionInfo> instructions = new ArrayList<InstructionInfo>();
- instructions.add(new InstructionInfo(InstructionType.goto_table, new long[] { L3_INTERFACE_TABLE }));
+ instructions.add(new InstructionInfo(InstructionType.goto_table, new long[] { NwConstants.L3_INTERFACE_TABLE }));
List<MatchInfo> matches = new ArrayList<MatchInfo>();
- FlowEntity flowEntityLfib = MDSALUtil.buildFlowEntity(dpnId, L3_LFIB_TABLE,
- getFlowRef(dpnId, L3_LFIB_TABLE, NwConstants.TABLE_MISS_FLOW),
+ FlowEntity flowEntityLfib = MDSALUtil.buildFlowEntity(dpnId, NwConstants.L3_LFIB_TABLE,
+ getFlowRef(dpnId, NwConstants.L3_LFIB_TABLE, NwConstants.TABLE_MISS_FLOW),
NwConstants.TABLE_MISS_PRIORITY, "Table Miss", 0, 0, COOKIE_TABLE_MISS, matches, instructions);
- FlowEntity flowEntityFib = MDSALUtil.buildFlowEntity(dpnId,L3_FIB_TABLE, getFlowRef(dpnId, L3_FIB_TABLE, NwConstants.TABLE_MISS_FLOW),
+ FlowEntity flowEntityFib = MDSALUtil.buildFlowEntity(dpnId,NwConstants.L3_FIB_TABLE, getFlowRef(dpnId, NwConstants.L3_FIB_TABLE, NwConstants.TABLE_MISS_FLOW),
NwConstants.TABLE_MISS_PRIORITY, "FIB Table Miss Flow", 0, 0, COOKIE_VM_FIB_TABLE,
matches, instructions);
final BigInteger COOKIE_PROTOCOL_TABLE = new BigInteger("1070000", 16);
// Instruction to goto L3 InterfaceTable
List<InstructionInfo> instructions = new ArrayList<>();
- instructions.add(new InstructionInfo(InstructionType.goto_table, new long[] {L3_LFIB_TABLE}));
+ instructions.add(new InstructionInfo(InstructionType.goto_table, new long[] {NwConstants.L3_LFIB_TABLE}));
List<MatchInfo> matches = new ArrayList<MatchInfo>();
matches.add(new MatchInfo(MatchFieldType.eth_type,
new long[] { 0x8847L }));
- FlowEntity flowEntityToLfib = MDSALUtil.buildFlowEntity(dpnId, L3_PROTOCOL_TABLE,
- getFlowRef(dpnId, L3_PROTOCOL_TABLE,
- L3_LFIB_TABLE),
+ FlowEntity flowEntityToLfib = MDSALUtil.buildFlowEntity(dpnId, NwConstants.L3_PROTOCOL_TABLE,
+ getFlowRef(dpnId, NwConstants.L3_PROTOCOL_TABLE,
+ NwConstants.L3_LFIB_TABLE),
DEFAULT_FIB_FLOW_PRIORITY,
"Protocol Table For LFIB",
0, 0,
instructions.add(new InstructionInfo(InstructionType.clear_actions));
// Instruction to goto L3 InterfaceTable
- instructions.add(new InstructionInfo(InstructionType.goto_table, new long[] { LPORT_DISPATCHER_TABLE }));
+ instructions.add(new InstructionInfo(InstructionType.goto_table, new long[] { NwConstants.LPORT_DISPATCHER_TABLE }));
- FlowEntity flowEntityL3Intf = MDSALUtil.buildFlowEntity(dpnId, L3_INTERFACE_TABLE,
- getFlowRef(dpnId, L3_INTERFACE_TABLE, NwConstants.TABLE_MISS_FLOW),
+ FlowEntity flowEntityL3Intf = MDSALUtil.buildFlowEntity(dpnId, NwConstants.L3_INTERFACE_TABLE,
+ getFlowRef(dpnId, NwConstants.L3_INTERFACE_TABLE, NwConstants.TABLE_MISS_FLOW),
NwConstants.TABLE_MISS_PRIORITY, "L3 Interface Table Miss", 0, 0, COOKIE_TABLE_MISS, matches, instructions);
if (addOrRemove == NwConstants.ADD_FLOW) {
LOG.info("Invoking MDSAL to install L3 interface Table Miss Entries");
}
protected String getTunnelInterfaceName(BigInteger srcDpId, BigInteger dstDpId) {
- // FIXME: Enable during itm integration
-
try {
Future<RpcResult<GetTunnelInterfaceNameOutput>> result = itmManager.getTunnelInterfaceName(new GetTunnelInterfaceNameInputBuilder()
.setSourceDpid(srcDpId)
}
protected String getExternalTunnelInterfaceName(BigInteger srcDpId, IpAddress dstIp) {
- // FIXME: Enable during itm integration
-
try {
Future<RpcResult<GetExternalTunnelInterfaceNameOutput>> result = itmManager.getExternalTunnelInterfaceName(new GetExternalTunnelInterfaceNameInputBuilder()
.setSourceDpid(srcDpId)
public static final int DEFAULT_IFINDEX = 65536;
public static final int DEFAULT_FLOW_PRIORITY = 5;
public static final String IFM_LPORT_TAG_IDPOOL_NAME = "vlaninterfaces.lporttag";
- public static final short VLAN_INTERFACE_INGRESS_TABLE = 0;
- public static final short INTERNAL_TUNNEL_TABLE = 22;
- public static final short EXTERNAL_TUNNEL_TABLE = 23;
- public static final short LFIB_TABLE = 20;
public static final BigInteger COOKIE_VM_LFIB_TABLE = new BigInteger("8000002", 16);;
public static final String TUNNEL_TABLE_FLOWID_PREFIX = "TUNNEL.";
public static final BigInteger TUNNEL_TABLE_COOKIE = new BigInteger("9000000", 16);
}
public static void makeTunnelIngressFlow(List<ListenableFuture<Void>> futures, IMdsalApiManager mdsalApiManager,
IfTunnel tunnel, BigInteger dpnId, long portNo, Interface iface, int addOrRemoveFlow) {
- String flowRef = InterfaceManagerCommonUtils.getTunnelInterfaceFlowRef(dpnId, VpnConstants.LPORT_INGRESS_TABLE, iface.getName());
+ String flowRef = InterfaceManagerCommonUtils.getTunnelInterfaceFlowRef(dpnId, NwConstants.VLAN_INTERFACE_INGRESS_TABLE, iface.getName());
List<MatchInfo> matches = new ArrayList<MatchInfo>();
List<InstructionInfo> mkInstructions = new ArrayList<InstructionInfo>();
if (NwConstants.ADD_FLOW == addOrRemoveFlow) {
matches.add(new MatchInfo(MatchFieldType.in_port, new BigInteger[] {
dpnId, BigInteger.valueOf(portNo) }));
- short tableId = tunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeMplsOverGre.class) ? IfmConstants.LFIB_TABLE :
- tunnel.isInternal() ? IfmConstants.INTERNAL_TUNNEL_TABLE : IfmConstants.EXTERNAL_TUNNEL_TABLE;
+ short tableId = tunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeMplsOverGre.class) ? NwConstants.L3_LFIB_TABLE :
+ tunnel.isInternal() ? NwConstants.INTERNAL_TUNNEL_TABLE : NwConstants.EXTERNAL_TUNNEL_TABLE;
mkInstructions.add(new InstructionInfo(InstructionType.goto_table, new long[] {tableId}));}
BigInteger COOKIE_VM_INGRESS_TABLE = new BigInteger("8000001", 16);
- FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpnId, IfmConstants.VLAN_INTERFACE_INGRESS_TABLE, flowRef,
+ FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpnId, NwConstants.VLAN_INTERFACE_INGRESS_TABLE, flowRef,
IfmConstants.DEFAULT_FLOW_PRIORITY, iface.getName(), 0, 0, COOKIE_VM_INGRESS_TABLE, matches, mkInstructions);
if (NwConstants.ADD_FLOW == addOrRemoveFlow) {
futures.add(mdsalApiManager.installFlow(dpnId, flowEntity));
private ListenableFuture<Void> makeTerminatingServiceFlow(IfTunnel tunnelInfo, BigInteger dpnId, BigInteger tunnelKey, List<Instruction> instruction, int addOrRemove) {
List<MatchInfo> mkMatches = new ArrayList<MatchInfo>();
mkMatches.add(new MatchInfo(MatchFieldType.tunnel_id, new BigInteger[] {tunnelKey}));
- short tableId = tunnelInfo.isInternal() ? IfmConstants.INTERNAL_TUNNEL_TABLE :
- IfmConstants.EXTERNAL_TUNNEL_TABLE;
+ short tableId = tunnelInfo.isInternal() ? NwConstants.INTERNAL_TUNNEL_TABLE :
+ NwConstants.EXTERNAL_TUNNEL_TABLE;
final String flowRef = getFlowRef(dpnId,tableId, tunnelKey);
Flow terminatingSerFlow = MDSALUtil.buildFlowNew(tableId, flowRef,
5, "TST Flow Entry", 0, 0,
new long[]{0x8847L}));
mkMatches.add(new MatchInfo(MatchFieldType.mpls_label, new String[]{Long.toString(tunnelKey.longValue())}));
// Install the flow entry in L3_LFIB_TABLE
- String flowRef = getFlowRef(dpnId, IfmConstants.LFIB_TABLE, tunnelKey);
+ String flowRef = getFlowRef(dpnId, NwConstants.L3_LFIB_TABLE, tunnelKey);
- Flow lfibFlow = MDSALUtil.buildFlowNew(IfmConstants.LFIB_TABLE, flowRef,
+ Flow lfibFlow = MDSALUtil.buildFlowNew(NwConstants.L3_LFIB_TABLE, flowRef,
IfmConstants.DEFAULT_FLOW_PRIORITY, "LFIB Entry", 0, 0,
IfmConstants.COOKIE_VM_LFIB_TABLE, mkMatches, instruction);
if (addOrRemove == NwConstants.ADD_FLOW) {
import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
import org.opendaylight.vpnservice.interfacemgr.servicebindings.flowbased.utilities.FlowBasedServicesUtils;
import org.opendaylight.vpnservice.mdsalutil.MatchInfo;
+import org.opendaylight.vpnservice.mdsalutil.NwConstants;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
if (matches != null) {
FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, iface, boundServiceNew,
- transaction, matches, ifState.getIfIndex(), IfmConstants.VLAN_INTERFACE_INGRESS_TABLE);
+ transaction, matches, ifState.getIfIndex(), NwConstants.VLAN_INTERFACE_INGRESS_TABLE);
}
if (transaction != null) {
WriteTransaction installFlowTransaction = dataBroker.newWriteOnlyTransaction();
FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, iface, boundServiceNew, installFlowTransaction,
- matches, ifState.getIfIndex(), IfmConstants.VLAN_INTERFACE_INGRESS_TABLE);
+ matches, ifState.getIfIndex(), NwConstants.VLAN_INTERFACE_INGRESS_TABLE);
futures.add(installFlowTransaction.submit());
}
}
import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
import org.opendaylight.vpnservice.interfacemgr.servicebindings.flowbased.utilities.FlowBasedServicesUtils;
import org.opendaylight.vpnservice.mdsalutil.MatchInfo;
+import org.opendaylight.vpnservice.mdsalutil.NwConstants;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
BoundServices toBeMoved = tmpServicesMap.get(highestPriority);
FlowBasedServicesUtils.removeIngressFlow(iface, boundServiceOld, dpId, t);
FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, iface, toBeMoved, t,
- matches, ifState.getIfIndex(), IfmConstants.VLAN_INTERFACE_INGRESS_TABLE);
+ matches, ifState.getIfIndex(), NwConstants.VLAN_INTERFACE_INGRESS_TABLE);
FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, iface, toBeMoved, t);
if (t != null) {
import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
import org.opendaylight.vpnservice.interfacemgr.servicebindings.flowbased.utilities.FlowBasedServicesUtils;
import org.opendaylight.vpnservice.mdsalutil.MatchInfo;
+import org.opendaylight.vpnservice.mdsalutil.NwConstants;
import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel;
if (matches != null) {
FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, iface, highestPriorityBoundService,
- t, matches, ifaceState.getIfIndex(), IfmConstants.VLAN_INTERFACE_INGRESS_TABLE);
+ t, matches, ifaceState.getIfIndex(), NwConstants.VLAN_INTERFACE_INGRESS_TABLE);
}
for (BoundServices boundService : allServices) {
Node nodeDpn = buildInventoryDpnNode(dpId);
InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class)
.child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class)
- .child(Table.class, new TableKey(IfmConstants.VLAN_INTERFACE_INGRESS_TABLE)).child(Flow.class, flowKey).build();
+ .child(Table.class, new TableKey(NwConstants.VLAN_INTERFACE_INGRESS_TABLE)).child(Flow.class, flowKey).build();
t.delete(LogicalDatastoreType.CONFIGURATION, flowInstanceId);
}
Node nodeDpn = buildInventoryDpnNode(dpId);
InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class)
.child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class)
- .child(Table.class, new TableKey(IfmConstants.VLAN_INTERFACE_INGRESS_TABLE)).child(Flow.class, flowKey).build();
+ .child(Table.class, new TableKey(NwConstants.VLAN_INTERFACE_INGRESS_TABLE)).child(Flow.class, flowKey).build();
t.delete(LogicalDatastoreType.CONFIGURATION, flowInstanceId);
}
}
private static String getFlowRef(BigInteger dpnId, String iface, BoundServices service) {
- return new StringBuffer().append(dpnId).append(IfmConstants.VLAN_INTERFACE_INGRESS_TABLE).append(NwConstants.FLOWID_SEPARATOR)
+ return new StringBuffer().append(dpnId).append( NwConstants.VLAN_INTERFACE_INGRESS_TABLE).append(NwConstants.FLOWID_SEPARATOR)
.append(iface).append(NwConstants.FLOWID_SEPARATOR).append(service.getServiceName()).append(NwConstants.FLOWID_SEPARATOR)
.append(service.getServicePriority()).toString();
}
import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
import org.opendaylight.vpnservice.interfacemgr.servicebindings.flowbased.statehelpers.FlowBasedServicesStateBindHelper;
import org.opendaylight.vpnservice.interfacemgr.servicebindings.flowbased.statehelpers.FlowBasedServicesStateUnbindHelper;
-import org.opendaylight.vpnservice.mdsalutil.MDSALUtil;
-import org.opendaylight.vpnservice.mdsalutil.MatchFieldType;
-import org.opendaylight.vpnservice.mdsalutil.MatchInfo;
-import org.opendaylight.vpnservice.mdsalutil.MetaDataUtil;
+import org.opendaylight.vpnservice.mdsalutil.*;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus;
.setLowerLayerIf(lowerLayerIfList)
.setKey(IfmUtil.getStateInterfaceKeyFromName(InterfaceManagerTestUtil.interfaceName))
.setName(InterfaceManagerTestUtil.interfaceName);
- stypeOpenflow = InterfaceManagerTestUtil.buildStypeOpenflow(dpId,flowpriority, IfmConstants.VLAN_INTERFACE_INGRESS_TABLE, instructions);
+ stypeOpenflow = InterfaceManagerTestUtil.buildStypeOpenflow(dpId,flowpriority, NwConstants.VLAN_INTERFACE_INGRESS_TABLE, instructions);
instructionKey = new InstructionKey(instructionKeyval);
BigInteger[] metadataValues = IfmUtil.mergeOpenflowMetadataWriteInstructions(instructions);
boundService = InterfaceManagerTestUtil.buildBoundServices(serviceName,key,new BoundServicesKey(key),stypeOpenflow);
public static String buildflowRef(BigInteger dpId,String servicaName,String boundServicename, short servicePriority)
{
- String flowRef = new StringBuffer().append(dpId).append(IfmConstants.VLAN_INTERFACE_INGRESS_TABLE).append(NwConstants.FLOWID_SEPARATOR).
+ String flowRef = new StringBuffer().append(dpId).append(NwConstants.VLAN_INTERFACE_INGRESS_TABLE).append(NwConstants.FLOWID_SEPARATOR).
append(servicaName).append(NwConstants.FLOWID_SEPARATOR).append(boundServicename).
append(NwConstants.FLOWID_SEPARATOR).append(servicePriority).toString();
return flowRef;
--- /dev/null
+/target/
+/target/
+/target/
+/target/
public class ITMConstants{
- public static final short INTERNAL_TUNNEL_TABLE = 22;
- public static final BigInteger COOKIE_ITM = new BigInteger("9000000", 16);
+ public static final BigInteger COOKIE_ITM = new BigInteger("9000000", 16);
+ public static final String ITM_IDPOOL_NAME = "Itmservices";
+ public static final long ITM_IDPOOL_START = 1L;
+ public static final String ITM_IDPOOL_SIZE = "100000";
+
+
}
}
}
+ rpc get-internal-or-external-interface-name {
+ description "used to retrieve tunnel interface id with src Dpn and destination ip";
+ input {
+ leaf source-dpid {
+ type uint64;
+ }
+ leaf destination-ip {
+ type inet:ip-address;
+ }
+ }
+ output {
+ leaf interface-name {
+ type string;
+ }
+ }
+ }
+
rpc get-external-tunnel-interface-name {
description "used to retrieve tunnel interface id between Dpns";
input {
}
}
- rpc remove-external-tunnel-endpoint {
+ rpc remove-external-tunnel-endpoint {
description "used for building tunnels between teps on all Dpns and external node";
input {
leaf destination-ip {
description "used for programming the terminating service actions";
input {
leaf dpn-id {
- type uint64;
+ type uint64;
}
leaf service-id {
type uint16;
description "used for removing the terminating service actions";
input {
leaf dpn-id {
- type uint64;
+ type uint64;
}
leaf service-id {
type uint16;
container tunnel-list {
- list tunnel {
+ list internal-tunnel {
key "source-DPN destination-DPN";
}
}
}
-
+
container external-tunnel-list {
list external-tunnel {
}
}
-
+
notification itm-tunnel-build-complete{
}
<artifactId>itm-api</artifactId>
<version>${vpnservices.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.vpnservice</groupId>
+ <artifactId>idmanager-api</artifactId>
+ <version>${vpnservices.version}</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.vpnservice</groupId>
<artifactId>interfacemgr-api</artifactId>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.vpnservice</groupId>
+ <artifactId>idmanager-api</artifactId>
+ <version>0.2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.vpnservice</groupId>
+ <artifactId>idmanager-api</artifactId>
+ <version>0.2.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
</project>
-->
<snapshot>
<required-capabilities>
- <capability>urn:opendaylight:params:xml:ns:yang:itm?module=itm&revision=2015-07-01</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:itm:impl?module=itm-impl&revision=2014-12-10</capability>
+ <capability>urn:opendaylight:vpnservice:itm?module=itm&revision=2015-07-01</capability>
+ <capability>urn:opendaylight:vpnservice:itm:impl?module=itm-impl&revision=2014-12-10</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&revision=2013-10-28</capability>
<capability>urn:opendaylight:params:xml:ns:yang:mdsalutil:api?module=odl-mdsalutil&revision=2015-04-10</capability>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
<module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:itm:impl">prefix:itm</type>
+ <type xmlns:prefix="urn:opendaylight:vpnservice:itm:impl">prefix:itm</type>
<name>itm-default</name>
<broker>
<type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
</modules>
<services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
<service>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:itm">prefix:itm</type>
+ <type xmlns:prefix="urn:opendaylight:vpnservice:itm">prefix:itm</type>
<instance>
<name>itm</name>
<provider>/modules/module[type='itm'][name='itm-default']</provider>
import org.opendaylight.vpnservice.itm.impl.ItmUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeGre;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeVxlan;
};
};
- public static List<ListenableFuture<Void>> buildTunnelsToExternalEndPoint(DataBroker dataBroker,List<DPNTEPsInfo> cfgDpnList, IpAddress extIp, Class<? extends TunnelTypeBase> tunType) {
+ public static List<ListenableFuture<Void>> buildTunnelsToExternalEndPoint(DataBroker dataBroker, IdManagerService idManagerService,
+ List<DPNTEPsInfo> cfgDpnList, IpAddress extIp, Class<? extends TunnelTypeBase> tunType) {
List<ListenableFuture<Void>> futures = new ArrayList<>();
WriteTransaction t = dataBroker.newWriteOnlyTransaction();
if( null != cfgDpnList) {
// CHECK -- Assumption -- Only one End Point / Dpn for GRE/Vxlan Tunnels
TunnelEndPoints firstEndPt = teps.getTunnelEndPoints().get(0) ;
String interfaceName = firstEndPt.getInterfaceName() ;
- String trunkInterfaceName = ItmUtils.getTrunkInterfaceName(interfaceName, firstEndPt.getIpAddress().getIpv4Address().getValue(), extIp.getIpv4Address().getValue()) ;
+ String trunkInterfaceName = ItmUtils.getTrunkInterfaceName(idManagerService, interfaceName, firstEndPt.getIpAddress().getIpv4Address().getValue(), extIp.getIpv4Address().getValue()) ;
char[] subnetMaskArray = firstEndPt.getSubnetMask().getValue() ;
String subnetMaskStr = String.valueOf(subnetMaskArray) ;
SubnetUtils utils = new SubnetUtils(subnetMaskStr);
IpAddress gwyIpAddress = (utils.getInfo().isInRange(dcGwyIpStr) ) ? null : firstEndPt.getGwIpAddress() ;
String ifDescription = tunType.getName();
logger.debug( " Creating Trunk Interface with parameters trunk I/f Name - {}, parent I/f name - {}, source IP - {}, DC Gateway IP - {} gateway IP - {}",trunkInterfaceName, interfaceName, firstEndPt.getIpAddress(), extIp, gwyIpAddress ) ;
- Interface iface = ItmUtils.buildTunnelInterface(teps.getDPNID(), trunkInterfaceName, String.format( "%s %s",ifDescription, "Trunk Interface"), true, tunType, firstEndPt.getIpAddress(), extIp, gwyIpAddress) ;
+ Interface iface = ItmUtils.buildTunnelInterface(teps.getDPNID(), trunkInterfaceName, String.format( "%s %s",ifDescription, "Trunk Interface"), true, tunType, firstEndPt.getIpAddress(), extIp, gwyIpAddress, false) ;
logger.debug( " Trunk Interface builder - {} ", iface ) ;
InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(trunkInterfaceName);
logger.debug( " Trunk Interface Identifier - {} ", trunkIdentifier ) ;
logger.trace( " Writing Trunk Interface to Config DS {}, {} ", trunkIdentifier, iface ) ;
- //ItmUtils.asyncUpdate(LogicalDatastoreType.CONFIGURATION,trunkIdentifier, iface , dataBroker, ItmUtils.DEFAULT_CALLBACK);
t.merge(LogicalDatastoreType.CONFIGURATION, trunkIdentifier, iface, true);
- // update_external_tunnels_ds(teps.getDPNID(), extIp, trunkInterfaceName, tunType);
+ // update external_tunnel_list ds
InstanceIdentifier<ExternalTunnel> path = InstanceIdentifier.create(
ExternalTunnelList.class)
- .child(ExternalTunnel.class, new ExternalTunnelKey(extIp, teps.getDPNID()));
- ExternalTunnel tnl = new ExternalTunnelBuilder().setKey(new ExternalTunnelKey(extIp, teps.getDPNID()))
- .setDestinationIP(extIp)
- .setSourceDPN(teps.getDPNID())
- .setTunnelInterfaceName(trunkInterfaceName).build();
- ItmUtils.asyncUpdate(LogicalDatastoreType.CONFIGURATION, path, tnl, dataBroker, DEFAULT_CALLBACK);
+ .child(ExternalTunnel.class, new ExternalTunnelKey(extIp, teps.getDPNID()));
+ ExternalTunnel tnl = ItmUtils.buildExternalTunnel(teps.getDPNID(), extIp, trunkInterfaceName);
+ t.merge(LogicalDatastoreType.CONFIGURATION,path, tnl, true) ;
}
futures.add( t.submit()) ;
}
return futures ;
}
- public static List<ListenableFuture<Void>> buildTunnelsFromDpnToExternalEndPoint(DataBroker dataBroker, List<BigInteger> dpnId, IpAddress extIp, Class<? extends TunnelTypeBase> tunType) {
+ public static List<ListenableFuture<Void>> buildTunnelsFromDpnToExternalEndPoint(DataBroker dataBroker, IdManagerService idManagerService,
+ List<BigInteger> dpnId, IpAddress extIp, Class<? extends TunnelTypeBase> tunType) {
List<ListenableFuture<Void>> futures = new ArrayList<>();
- List<DPNTEPsInfo> cfgDpnList = new ArrayList<DPNTEPsInfo>() ;
- List<DPNTEPsInfo> meshedDpnList = ItmUtils.getTunnelMeshInfo(dataBroker) ;
- if( null != meshedDpnList) {
- for (BigInteger dpn : dpnId){
- for( DPNTEPsInfo teps : meshedDpnList ) {
- if( teps.getDPNID().equals(dpn)) {
- cfgDpnList.add(teps) ;
- }
- }
- }
- futures = buildTunnelsToExternalEndPoint( dataBroker, cfgDpnList, extIp, tunType) ;
- }
+ List<DPNTEPsInfo> cfgDpnList =( dpnId == null ) ? ItmUtils.getTunnelMeshInfo(dataBroker) :ItmUtils.getDPNTEPListFromDPNId(dataBroker, dpnId) ;
+ futures = buildTunnelsToExternalEndPoint( dataBroker, idManagerService, cfgDpnList, extIp, tunType) ;
return futures ;
}
}
import org.opendaylight.vpnservice.itm.impl.ItmUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.ExternalTunnelList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.DPNTEPsInfo;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.dpn.teps.info.TunnelEndPoints;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.external.tunnel.list.ExternalTunnel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.external.tunnel.list.ExternalTunnelKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ItmExternalTunnelDeleteWorker {
private static final Logger logger = LoggerFactory.getLogger(ItmExternalTunnelDeleteWorker.class ) ;
- public static List<ListenableFuture<Void>> deleteTunnels(DataBroker dataBroker, List<DPNTEPsInfo> dpnTepsList,IpAddress extIp ) {
+ public static List<ListenableFuture<Void>> deleteTunnels(DataBroker dataBroker, IdManagerService idManagerService, List<DPNTEPsInfo> dpnTepsList,IpAddress extIp, Class<? extends TunnelTypeBase> tunType ) {
logger.trace( " Delete Tunnels towards DC Gateway with Ip {}", extIp ) ;
List<ListenableFuture<Void>> futures = new ArrayList<>();
WriteTransaction t = dataBroker.newWriteOnlyTransaction();
}
for( DPNTEPsInfo teps : dpnTepsList) {
TunnelEndPoints firstEndPt = teps.getTunnelEndPoints().get(0) ;
- String interfaceName = firstEndPt.getInterfaceName() ;
- String trunkInterfaceName = ItmUtils.getTrunkInterfaceName(interfaceName, firstEndPt.getIpAddress().getIpv4Address().getValue(), extIp.getIpv4Address().getValue()) ;
- InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(trunkInterfaceName);
- t.delete(LogicalDatastoreType.CONFIGURATION, trunkIdentifier);
+ if( firstEndPt.getTunnelType().equals(tunType)) {
+ String interfaceName = firstEndPt.getInterfaceName() ;
+ String trunkInterfaceName = ItmUtils.getTrunkInterfaceName(idManagerService, interfaceName,firstEndPt.getIpAddress().getIpv4Address().getValue(), extIp.getIpv4Address().getValue()) ;
+ InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(trunkInterfaceName);
+ t.delete(LogicalDatastoreType.CONFIGURATION, trunkIdentifier);
+
+ InstanceIdentifier<ExternalTunnel> path = InstanceIdentifier.create(
+ ExternalTunnelList.class)
+ .child(ExternalTunnel.class, new ExternalTunnelKey(extIp, teps.getDPNID()));
+ t.delete(LogicalDatastoreType.CONFIGURATION, path);
+ // Release the Ids for the trunk interface
+ ItmUtils.releaseId(idManagerService, trunkInterfaceName);
+ }
}
futures.add(t.submit()) ;
return futures ;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeGre;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeVxlan;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.external.tunnel.list.ExternalTunnel;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.external.tunnel.list.ExternalTunnelBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.external.tunnel.list.ExternalTunnelKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.tunnel.list.Tunnel;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.tunnel.list.TunnelBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.tunnel.list.TunnelKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.tunnel.list.InternalTunnel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.tunnel.list.InternalTunnelKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.slf4j.Logger;
};
- public static List<ListenableFuture<Void>> build_all_tunnels(DataBroker dataBroker, List<DPNTEPsInfo> cfgdDpnList, List<DPNTEPsInfo> meshedDpnList) {
+ public static List<ListenableFuture<Void>> build_all_tunnels(DataBroker dataBroker, IdManagerService idManagerService,
+ List<DPNTEPsInfo> cfgdDpnList, List<DPNTEPsInfo> meshedDpnList) {
logger.trace( "Building tunnels with DPN List {} " , cfgdDpnList );
List<ListenableFuture<Void>> futures = new ArrayList<>();
WriteTransaction t = dataBroker.newWriteOnlyTransaction();
for( DPNTEPsInfo dpn : cfgdDpnList) {
//#####if dpn is not in meshedDpnList
- build_tunnel_from(dpn, meshedDpnList, dataBroker, t, futures);
+ build_tunnel_from(dpn, meshedDpnList, dataBroker, idManagerService, t, futures);
if(null == meshedDpnList) {
meshedDpnList = new ArrayList<DPNTEPsInfo>() ;
}
t.merge(LogicalDatastoreType.CONFIGURATION, dep, tnlBuilder, true);
}
- private static void build_tunnel_from( DPNTEPsInfo srcDpn,List<DPNTEPsInfo> meshedDpnList, DataBroker dataBroker, WriteTransaction t, List<ListenableFuture<Void>> futures) {
+ private static void build_tunnel_from( DPNTEPsInfo srcDpn,List<DPNTEPsInfo> meshedDpnList, DataBroker dataBroker, IdManagerService idManagerService, WriteTransaction t, List<ListenableFuture<Void>> futures) {
logger.trace( "Building tunnels from DPN {} " , srcDpn );
if( null == meshedDpnList || 0 == meshedDpnList.size()) {
}
for( DPNTEPsInfo dstDpn: meshedDpnList) {
if ( ! srcDpn.equals(dstDpn) )
- wireUpWithinTransportZone(srcDpn, dstDpn, dataBroker, t, futures) ;
+ wireUpWithinTransportZone(srcDpn, dstDpn, dataBroker, idManagerService, t, futures) ;
}
}
- private static void wireUpWithinTransportZone( DPNTEPsInfo srcDpn, DPNTEPsInfo dstDpn, DataBroker dataBroker, WriteTransaction t, List<ListenableFuture<Void>> futures) {
+ private static void wireUpWithinTransportZone( DPNTEPsInfo srcDpn, DPNTEPsInfo dstDpn, DataBroker dataBroker,
+ IdManagerService idManagerService, WriteTransaction t, List<ListenableFuture<Void>> futures) {
logger.trace( "Wiring up within Transport Zone for Dpns {}, {} " , srcDpn, dstDpn );
List<TunnelEndPoints> srcEndPts = srcDpn.getTunnelEndPoints();
List<TunnelEndPoints> dstEndPts = dstDpn.getTunnelEndPoints();
if (!srcDpn.getDPNID().equals(dstDpn.getDPNID())) {
if( (srcte.getTransportZone().equals(dstte.getTransportZone()))) {
// wire them up
- wireUpBidirectionalTunnel( srcte, dstte, srcDpn.getDPNID(), dstDpn.getDPNID(), dataBroker, t, futures );
+ wireUpBidirectionalTunnel( srcte, dstte, srcDpn.getDPNID(), dstDpn.getDPNID(), dataBroker, idManagerService, t, futures );
// CHECK THIS -- Assumption -- One end point per Dpn per transport zone
break ;
}
}
private static void wireUpBidirectionalTunnel( TunnelEndPoints srcte, TunnelEndPoints dstte, BigInteger srcDpnId, BigInteger dstDpnId,
- DataBroker dataBroker, WriteTransaction t, List<ListenableFuture<Void>> futures) {
+ DataBroker dataBroker, IdManagerService idManagerService, WriteTransaction t, List<ListenableFuture<Void>> futures) {
// Setup the flow for LLDP monitoring -- PUNT TO CONTROLLER
// setUpOrRemoveTerminatingServiceTable(srcDpnId, true);
// setUpOrRemoveTerminatingServiceTable(dstDpnId, true);
// Create the forward direction tunnel
- if(!wireUp( srcte, dstte, srcDpnId, dstDpnId, dataBroker, t, futures ))
+ if(!wireUp( srcte, dstte, srcDpnId, dstDpnId, dataBroker, idManagerService, t, futures ))
logger.error("Could not build tunnel between end points {}, {} " , srcte, dstte );
// CHECK IF FORWARD IS NOT BUILT , REVERSE CAN BE BUILT
// Create the tunnel for the reverse direction
- if(! wireUp( dstte, srcte, dstDpnId, srcDpnId, dataBroker, t, futures ))
+ if(! wireUp( dstte, srcte, dstDpnId, srcDpnId, dataBroker, idManagerService, t, futures ))
logger.error("Could not build tunnel between end points {}, {} " , dstte, srcte);
}
- private static boolean wireUp( TunnelEndPoints srcte, TunnelEndPoints dstte, BigInteger srcDpnId, BigInteger dstDpnId ,
- DataBroker dataBroker, WriteTransaction t, List<ListenableFuture<Void>> futures) {
+ private static boolean wireUp(TunnelEndPoints srcte, TunnelEndPoints dstte, BigInteger srcDpnId, BigInteger dstDpnId ,
+ DataBroker dataBroker, IdManagerService idManagerService, WriteTransaction t, List<ListenableFuture<Void>> futures) {
// Wire Up logic
logger.trace( "Wiring between source tunnel end points {}, destination tunnel end points {} " , srcte, dstte );
String interfaceName = srcte.getInterfaceName() ;
Class<? extends TunnelTypeBase> tunType = srcte.getTunnelType();
String ifDescription = srcte.getTunnelType().getName();
// Form the trunk Interface Name
- String trunkInterfaceName = ItmUtils.getTrunkInterfaceName(interfaceName,srcte.getIpAddress().getIpv4Address().getValue(), dstte.getIpAddress().getIpv4Address().getValue()) ;
+ String trunkInterfaceName = ItmUtils.getTrunkInterfaceName(idManagerService, interfaceName,srcte.getIpAddress().getIpv4Address().getValue(), dstte.getIpAddress().getIpv4Address().getValue()) ;
IpAddress gwyIpAddress = ( srcte.getSubnetMask().equals(dstte.getSubnetMask()) ) ? null : srcte.getGwIpAddress() ;
logger.debug( " Creating Trunk Interface with parameters trunk I/f Name - {}, parent I/f name - {}, source IP - {}, destination IP - {} gateway IP - {}",trunkInterfaceName, interfaceName, srcte.getIpAddress(), dstte.getIpAddress(), gwyIpAddress ) ;
- Interface iface = ItmUtils.buildTunnelInterface(srcDpnId, trunkInterfaceName, String.format( "%s %s",ifDescription, "Trunk Interface"), true, tunType, srcte.getIpAddress(), dstte.getIpAddress(), gwyIpAddress) ;
+ Interface iface = ItmUtils.buildTunnelInterface(srcDpnId, trunkInterfaceName, String.format( "%s %s",ifDescription, "Trunk Interface"), true, tunType, srcte.getIpAddress(), dstte.getIpAddress(), gwyIpAddress, true) ;
logger.debug( " Trunk Interface builder - {} ", iface ) ;
InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(trunkInterfaceName);
logger.debug( " Trunk Interface Identifier - {} ", trunkIdentifier ) ;
logger.trace( " Writing Trunk Interface to Config DS {}, {} ", trunkIdentifier, iface ) ;
t.merge(LogicalDatastoreType.CONFIGURATION, trunkIdentifier, iface, true);
// also update itm-state ds?
- InstanceIdentifier<Tunnel> path = InstanceIdentifier.create(
+ InstanceIdentifier<InternalTunnel> path = InstanceIdentifier.create(
TunnelList.class)
- .child(Tunnel.class, new TunnelKey(dstDpnId, srcDpnId));
- Tunnel tnl = new TunnelBuilder().setKey(new TunnelKey(dstDpnId, srcDpnId))
- .setDestinationDPN(dstDpnId)
- .setSourceDPN(srcDpnId)
- .setTunnelInterfaceName(trunkInterfaceName).build();
- ItmUtils.asyncUpdate(LogicalDatastoreType.CONFIGURATION, path, tnl, dataBroker, DEFAULT_CALLBACK);
+ .child(InternalTunnel.class, new InternalTunnelKey( srcDpnId, dstDpnId));
+ InternalTunnel tnl = ItmUtils.buildInternalTunnel(srcDpnId, dstDpnId, trunkInterfaceName);
+ //ItmUtils.asyncUpdate(LogicalDatastoreType.CONFIGURATION, path, tnl, dataBroker, DEFAULT_CALLBACK);
+ t.merge(LogicalDatastoreType.CONFIGURATION,path, tnl, true) ;
return true;
}
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.vpnservice.itm.impl.ItmUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.DpnEndpoints;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.TunnelList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.DPNTEPsInfo;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.dpn.teps.info.TunnelEndPoints;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.tunnel.list.InternalTunnel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.tunnel.list.InternalTunnelKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ItmInternalTunnelDeleteWorker {
private static final Logger logger = LoggerFactory.getLogger(ItmInternalTunnelDeleteWorker.class) ;
- public static List<ListenableFuture<Void>> deleteTunnels(DataBroker dataBroker, List<DPNTEPsInfo> dpnTepsList, List<DPNTEPsInfo> meshedDpnList)
+ public static List<ListenableFuture<Void>> deleteTunnels(DataBroker dataBroker, IdManagerService idManagerService,
+ List<DPNTEPsInfo> dpnTepsList, List<DPNTEPsInfo> meshedDpnList)
{
List<ListenableFuture<Void>> futures = new ArrayList<>();
WriteTransaction t = dataBroker.newWriteOnlyTransaction();
if (dstTep.getTransportZone().equals(srcTZone)) {
// remove all trunk interfaces
logger.trace("Invoking removeTrunkInterface between source TEP {} , Destination TEP {} " ,srcTep , dstTep);
- removeTrunkInterface(dataBroker, srcTep, dstTep, srcDpn.getDPNID(), dstDpn.getDPNID(), t, futures);
+ removeTrunkInterface(dataBroker, idManagerService, srcTep, dstTep, srcDpn.getDPNID(), dstDpn.getDPNID(), t, futures);
}
}
}
return futures ;
}
- private static void removeTrunkInterface(DataBroker dataBroker, TunnelEndPoints srcTep, TunnelEndPoints dstTep, BigInteger srcDpnId, BigInteger dstDpnId,
- WriteTransaction t, List<ListenableFuture<Void>> futures) {
+ private static void removeTrunkInterface(DataBroker dataBroker, IdManagerService idManagerService,
+ TunnelEndPoints srcTep, TunnelEndPoints dstTep, BigInteger srcDpnId, BigInteger dstDpnId,
+ WriteTransaction t, List<ListenableFuture<Void>> futures) {
String trunkfwdIfName =
- ItmUtils.getTrunkInterfaceName(srcTep.getInterfaceName(), srcTep.getIpAddress()
+ ItmUtils.getTrunkInterfaceName(idManagerService, srcTep.getInterfaceName(), srcTep.getIpAddress()
.getIpv4Address().getValue(), dstTep.getIpAddress().getIpv4Address()
.getValue());
logger.trace("Removing forward Trunk Interface " + trunkfwdIfName);
InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(trunkfwdIfName);
logger.debug( " Removing Trunk Interface Name - {} , Id - {} from Config DS {}, {} ", trunkfwdIfName, trunkIdentifier ) ;
t.delete(LogicalDatastoreType.CONFIGURATION, trunkIdentifier);
+
+ // also update itm-state ds -- Delete the forward tunnel-interface from the tunnel list
+ InstanceIdentifier<InternalTunnel> path = InstanceIdentifier.create(
+ TunnelList.class)
+ .child(InternalTunnel.class, new InternalTunnelKey( srcDpnId, dstDpnId));
+ t.delete(LogicalDatastoreType.CONFIGURATION,path) ;
+ // Release the Id for the forward trunk
+ ItmUtils.releaseId(idManagerService, trunkfwdIfName);
+
String trunkRevIfName =
- ItmUtils.getTrunkInterfaceName(dstTep.getInterfaceName(), dstTep.getIpAddress()
+ ItmUtils.getTrunkInterfaceName(idManagerService, dstTep.getInterfaceName(), dstTep.getIpAddress()
.getIpv4Address().getValue(), srcTep.getIpAddress().getIpv4Address()
.getValue());
logger.trace("Removing Reverse Trunk Interface " + trunkRevIfName);
trunkIdentifier = ItmUtils.buildId(trunkfwdIfName);
logger.debug( " Removing Trunk Interface Name - {} , Id - {} from Config DS {}, {} ", trunkfwdIfName, trunkIdentifier ) ;
t.delete(LogicalDatastoreType.CONFIGURATION, trunkIdentifier);
+
+ // also update itm-state ds -- Delete the reverse tunnel-interface from the tunnel list
+ path = InstanceIdentifier.create(
+ TunnelList.class)
+ .child(InternalTunnel.class, new InternalTunnelKey(dstDpnId, srcDpnId));
+ t.delete(LogicalDatastoreType.CONFIGURATION,path) ;
+
+ // Release the Id for the Reverse trunk
+ ItmUtils.releaseId(idManagerService, trunkRevIfName);
}
}
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.vpnservice.itm.impl.ItmUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.DPNTEPsInfo;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
public class ItmTepAddWorker implements Callable<List<ListenableFuture<Void>>> {
private static final Logger logger = LoggerFactory.getLogger(ItmTepAddWorker.class ) ;
private DataBroker dataBroker;
+ private IdManagerService idManagerService;
private List<DPNTEPsInfo> meshedDpnList;
private List<DPNTEPsInfo> cfgdDpnList ;
- public ItmTepAddWorker( List<DPNTEPsInfo> cfgdDpnList, DataBroker broker) {
+ public ItmTepAddWorker( List<DPNTEPsInfo> cfgdDpnList, DataBroker broker, IdManagerService idManagerService) {
this.cfgdDpnList = cfgdDpnList ;
this.dataBroker = broker ;
+ this.idManagerService = idManagerService;
logger.trace("ItmTepAddWorker initialized with DpnList {}",cfgdDpnList );
}
List<ListenableFuture<Void>> futures = new ArrayList<>() ;
this.meshedDpnList = ItmUtils.getTunnelMeshInfo(dataBroker) ;
logger.debug("Invoking Internal Tunnel build method with Configured DpnList {} ; Meshed DpnList {} ",cfgdDpnList, meshedDpnList );
- futures.addAll( ItmInternalTunnelAddWorker.build_all_tunnels(dataBroker, cfgdDpnList, meshedDpnList) ) ;
+ futures.addAll( ItmInternalTunnelAddWorker.build_all_tunnels(dataBroker, idManagerService, cfgdDpnList, meshedDpnList) ) ;
// IF EXTERNAL TUNNELS NEEDS TO BE BUILT, DO IT HERE. IT COULD BE TO DC GATEWAY OR TOR SWITCH
//futures.addAll(ItmExternalTunnelAddWorker.buildTunnelsToExternalEndPoint(dataBroker,meshedDpnList, extIp) ;
return futures ;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.vpnservice.itm.impl.ItmUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.DPNTEPsInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private DataBroker dataBroker;
private List<DPNTEPsInfo> delDpnList ;
private List<DPNTEPsInfo> meshedDpnList ;
+ private IdManagerService idManagerService;
- public ItmTepRemoveWorker( List<DPNTEPsInfo> delDpnList, DataBroker broker) {
+ public ItmTepRemoveWorker( List<DPNTEPsInfo> delDpnList, DataBroker broker, IdManagerService idManagerService) {
this.delDpnList = delDpnList ;
this.dataBroker = broker ;
+ this.idManagerService = idManagerService;
logger.trace("ItmTepRemoveWorker initialized with DpnList {}",delDpnList );
}
public List<ListenableFuture<Void>> call() throws Exception {
List<ListenableFuture<Void>> futures = new ArrayList<>() ;
this.meshedDpnList = ItmUtils.getTunnelMeshInfo(dataBroker) ;
- futures.addAll( ItmInternalTunnelDeleteWorker.deleteTunnels(dataBroker, delDpnList, meshedDpnList));
+ futures.addAll( ItmInternalTunnelDeleteWorker.deleteTunnels(dataBroker, idManagerService, delDpnList, meshedDpnList));
logger.debug("Invoking Internal Tunnel delete method with DpnList to be deleted {} ; Meshed DpnList {} ",delDpnList, meshedDpnList );
// IF EXTERNAL TUNNELS NEEDS TO BE DELETED, DO IT HERE, IT COULD BE TO DC GATEWAY OR TOR SWITCH
return futures ;
import java.math.BigInteger;
import java.util.List;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.vpnservice.interfacemgr.interfaces.IInterfaceManager;
import org.opendaylight.vpnservice.itm.api.IITMProvider;
+import org.opendaylight.vpnservice.itm.globals.ITMConstants;
import org.opendaylight.vpnservice.itm.listeners.TransportZoneListener;
import org.opendaylight.vpnservice.itm.rpc.ItmManagerRpcService;
import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.CreateIdPoolInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.CreateIdPoolInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.OdlInterfaceRpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.ItmRpcService;
private DataBroker dataBroker;
private NotificationPublishService notificationPublishService;
private ItmManagerRpcService itmRpcService ;
+ private IdManagerService idManager;
private NotificationService notificationService;
private TransportZoneListener tzChangeListener;
private RpcProviderRegistry rpcProviderRegistry;
LOG.info("ItmProvider Session Initiated");
try {
dataBroker = session.getSALService(DataBroker.class);
+ idManager = getRpcProviderRegistry().getRpcService(IdManagerService.class);
itmManager = new ITMManager(dataBroker);
- tzChangeListener = new TransportZoneListener(dataBroker) ;
- itmRpcService = new ItmManagerRpcService(dataBroker);
+ tzChangeListener = new TransportZoneListener(dataBroker, idManager) ;
+ itmRpcService = new ItmManagerRpcService(dataBroker, idManager);
final BindingAwareBroker.RpcRegistration<ItmRpcService> rpcRegistration = getRpcProviderRegistry().addRpcImplementation(ItmRpcService.class, itmRpcService);
itmRpcService.setMdsalManager(mdsalManager);
itmManager.setMdsalManager(mdsalManager);
itmManager.setMdsalManager(mdsalManager);
tzChangeListener.setItmManager(itmManager);
tzChangeListener.registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
+ createIdPool();
} catch (Exception e) {
LOG.error("Error initializing services", e);
}
LOG.info("ItmProvider Closed");
}
-
+ private void createIdPool() {
+ CreateIdPoolInput createPool = new CreateIdPoolInputBuilder()
+ .setPoolName(ITMConstants.ITM_IDPOOL_NAME)
+ .setLow(ITMConstants.ITM_IDPOOL_START)
+ .setHigh(new BigInteger(ITMConstants.ITM_IDPOOL_SIZE).longValue())
+ .build();
+ try {
+ Future<RpcResult<Void>> result = idManager.createIdPool(createPool);
+ if ((result != null) && (result.get().isSuccessful())) {
+ LOG.debug("Created IdPool for ITM Service");
+ }
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("Failed to create idPool for ITM Service",e);
+ }
+ }
}
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.net.util.SubnetUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.AllocateIdInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.AllocateIdInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.AllocateIdOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.ReleaseIdInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.ReleaseIdInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.*;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.DpnEndpoints;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.DpnEndpointsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.dpn.teps.info.TunnelEndPoints;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.dpn.teps.info.TunnelEndPointsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.dpn.teps.info.TunnelEndPointsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.external.tunnel.list.ExternalTunnel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.external.tunnel.list.ExternalTunnelBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.external.tunnel.list.ExternalTunnelKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.tunnel.list.InternalTunnel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.tunnel.list.InternalTunnelBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.tunnel.list.InternalTunnelKey;
import org.opendaylight.vpnservice.itm.globals.ITMConstants;
import org.opendaylight.vpnservice.mdsalutil.MDSALUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
+import org.opendaylight.yangtools.yang.common.RpcResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public static final String DUMMY_IP_ADDRESS = "0.0.0.0";
public static final String TUNNEL_TYPE_VXLAN = "VXLAN";
public static final String TUNNEL_TYPE_GRE = "GRE";
+ public static final String TUNNEL = "TUNNEL";
private static final Logger LOG = LoggerFactory.getLogger(ItmUtils.class);
return dpnId;
}
- public static String getTrunkInterfaceName(String parentInterfaceName, String localHostName, String remoteHostName) {
+ public static String getTrunkInterfaceName(IdManagerService idManager, String parentInterfaceName, String localHostName, String remoteHostName) {
String trunkInterfaceName = String.format("%s:%s:%s", parentInterfaceName, localHostName, remoteHostName);
+ trunkInterfaceName = String.format("%s:%s", TUNNEL, getUniqueId(idManager, trunkInterfaceName));
return trunkInterfaceName;
}
}
public static Interface buildTunnelInterface(BigInteger dpn, String ifName, String desc, boolean enabled, Class<? extends TunnelTypeBase> tunType,
- IpAddress localIp, IpAddress remoteIp, IpAddress gatewayIp) {
+ IpAddress localIp, IpAddress remoteIp, IpAddress gatewayIp, boolean internal) {
InterfaceBuilder builder = new InterfaceBuilder().setKey(new InterfaceKey(ifName)).setName(ifName)
.setDescription(desc).setEnabled(enabled).setType(Tunnel.class);
ParentRefs parentRefs = new ParentRefsBuilder().setDatapathNodeIdentifier(dpn).build();
builder.addAugmentation(ParentRefs.class, parentRefs);
IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(remoteIp).setTunnelGateway(gatewayIp).setTunnelSource(localIp)
- .setTunnelInterfaceType( tunType).build();
+ .setTunnelInterfaceType( tunType).setInternal(internal).build();
builder.addAugmentation(IfTunnel.class, tunnel);
return builder.build();
}
+ public static InternalTunnel buildInternalTunnel( BigInteger srcDpnId, BigInteger dstDpnId, String trunkInterfaceName) {
+ InternalTunnel tnl = new InternalTunnelBuilder().setKey(new InternalTunnelKey(srcDpnId, dstDpnId))
+ .setDestinationDPN(dstDpnId)
+ .setSourceDPN(srcDpnId)
+ .setTunnelInterfaceName(trunkInterfaceName).build();
+ return tnl ;
+ }
+
+ public static ExternalTunnel buildExternalTunnel( BigInteger srcDpnId, IpAddress dstIp, String trunkInterfaceName) {
+ ExternalTunnel extTnl = new ExternalTunnelBuilder().setKey(new ExternalTunnelKey(dstIp, srcDpnId)).setSourceDPN(srcDpnId).setDestinationIP(dstIp).setTunnelInterfaceName(trunkInterfaceName).build();
+ return extTnl ;
+ }
+
public static List<DPNTEPsInfo> getTunnelMeshInfo(DataBroker dataBroker) {
List<DPNTEPsInfo> dpnTEPs= null ;
LOG.debug( "No Dpn information in CONFIGURATION datastore " );
return dpnTEPs ;
}
+
+ public static int getUniqueId(IdManagerService idManager, String idKey) {
+ AllocateIdInput getIdInput = new AllocateIdInputBuilder()
+ .setPoolName(ITMConstants.ITM_IDPOOL_NAME)
+ .setIdKey(idKey).build();
+
+ try {
+ Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
+ RpcResult<AllocateIdOutput> rpcResult = result.get();
+ if(rpcResult.isSuccessful()) {
+ return rpcResult.getResult().getIdValue().intValue();
+ } else {
+ LOG.warn("RPC Call to Get Unique Id returned with Errors {}", rpcResult.getErrors());
+ }
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.warn("Exception when getting Unique Id",e);
+ }
+ return 0;
+ }
+
+ public static void releaseId(IdManagerService idManager, String idKey) {
+ ReleaseIdInput idInput = new ReleaseIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey(idKey).build();
+ try {
+ Future<RpcResult<Void>> result = idManager.releaseId(idInput);
+ RpcResult<Void> rpcResult = result.get();
+ if(!rpcResult.isSuccessful()) {
+ LOG.warn("RPC Call to Get Unique Id returned with Errors {}", rpcResult.getErrors());
+ }
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.warn("Exception when getting Unique Id for key {}", idKey, e);
+ }
+ }
+
+ public static List<DPNTEPsInfo> getDPNTEPListFromDPNId(DataBroker dataBroker, List<BigInteger> dpnIds) {
+ List<DPNTEPsInfo> meshedDpnList = getTunnelMeshInfo(dataBroker) ;
+ List<DPNTEPsInfo> cfgDpnList = new ArrayList<DPNTEPsInfo>();
+ if( null != meshedDpnList) {
+ for(BigInteger dpnId : dpnIds) {
+ for( DPNTEPsInfo teps : meshedDpnList ) {
+ if( dpnId.equals(teps.getDPNID()))
+ cfgDpnList.add( teps) ;
+ }
+ }
+ }
+ return cfgDpnList;
+ }
}
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.DPNTEPsInfo;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.dpn.teps.info.TunnelEndPoints;
public class TransportZoneListener extends AsyncDataTreeChangeListenerBase<TransportZone, TransportZoneListener> implements AutoCloseable{
private static final Logger LOG = LoggerFactory.getLogger(TransportZoneListener.class);
private DataBroker dataBroker;
+ private IdManagerService idManagerService;
private ITMManager itmManager;
- public TransportZoneListener(final DataBroker dataBroker) {
+ public TransportZoneListener(final DataBroker dataBroker, final IdManagerService idManagerService) {
super(TransportZone.class, TransportZoneListener.class);
this.dataBroker = dataBroker;
+ this.idManagerService = idManagerService;
initializeTZNode(dataBroker);
}
LOG.trace("Delete: Invoking ItmManager");
// itmManager.deleteTunnels(opDpnList);
DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
- ItmTepRemoveWorker removeWorker = new ItmTepRemoveWorker(opDpnList, dataBroker);
+ ItmTepRemoveWorker removeWorker = new ItmTepRemoveWorker(opDpnList, dataBroker, idManagerService);
coordinator.enqueueJob(tzOld.getZoneName(), removeWorker);
}
}
LOG.trace("Add: Invoking ItmManager with DPN List {} " , opDpnList);
//itmManager.build_all_tunnels(opDpnList);
DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
- ItmTepAddWorker addWorker = new ItmTepAddWorker(opDpnList,dataBroker);
+ ItmTepAddWorker addWorker = new ItmTepAddWorker(opDpnList,dataBroker, idManagerService);
coordinator.enqueueJob(tzNew.getZoneName(), addWorker);
}
}
import java.util.List;
import java.util.concurrent.Future;
+import org.opendaylight.vpnservice.mdsalutil.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
import org.opendaylight.vpnservice.itm.confighelpers.ItmExternalTunnelAddWorker;
+import org.opendaylight.vpnservice.itm.confighelpers.ItmExternalTunnelDeleteWorker;
import org.opendaylight.vpnservice.itm.globals.ITMConstants;
import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.vpnservice.itm.impl.ItmUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.ExternalTunnelList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.TunnelList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.DPNTEPsInfo;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.dpn.teps.info.TunnelEndPoints;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.external.tunnel.list.ExternalTunnel;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.external.tunnel.list.ExternalTunnelKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.tunnel.list.Tunnel;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.tunnel.list.TunnelKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.tunnel.list.InternalTunnel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.tunnel.list.InternalTunnelKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.AddExternalTunnelEndpointInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.BuildExternalTunnelFromDpnsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.CreateTerminatingServiceActionsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.GetExternalTunnelInterfaceNameInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.GetExternalTunnelInterfaceNameOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.GetExternalTunnelInterfaceNameOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.GetInternalOrExternalInterfaceNameInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.GetInternalOrExternalInterfaceNameOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.GetInternalOrExternalInterfaceNameOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.GetTunnelInterfaceNameInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.GetTunnelInterfaceNameOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.GetTunnelInterfaceNameOutputBuilder;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.opendaylight.vpnservice.mdsalutil.MDSALUtil;
-import org.opendaylight.vpnservice.mdsalutil.MatchFieldType;
-import org.opendaylight.vpnservice.mdsalutil.MatchInfo;
-import org.opendaylight.vpnservice.mdsalutil.MetaDataUtil;
-import org.opendaylight.vpnservice.mdsalutil.ActionInfo;
-import org.opendaylight.vpnservice.mdsalutil.ActionType;
import com.google.common.base.Optional;
private static final Logger LOG = LoggerFactory.getLogger(ItmManagerRpcService.class);
DataBroker dataBroker;
private IMdsalApiManager mdsalManager;
- public ItmManagerRpcService(DataBroker dataBroker) {
- this.dataBroker = dataBroker;
- }
+
public void setMdsalManager(IMdsalApiManager mdsalManager) {
this.mdsalManager = mdsalManager;
}
+ IdManagerService idManagerService;
+
+ public ItmManagerRpcService(DataBroker dataBroker, IdManagerService idManagerService) {
+ this.dataBroker = dataBroker;
+ this.idManagerService = idManagerService;
+ }
+
@Override
public Future<RpcResult<GetTunnelInterfaceNameOutput>> getTunnelInterfaceName(GetTunnelInterfaceNameInput input) {
RpcResultBuilder<GetTunnelInterfaceNameOutput> resultBld = null;
BigInteger sourceDpn = input.getSourceDpid() ;
BigInteger destinationDpn = input.getDestinationDpid() ;
- InstanceIdentifier<Tunnel> path = InstanceIdentifier.create(
+ InstanceIdentifier<InternalTunnel> path = InstanceIdentifier.create(
TunnelList.class)
- .child(Tunnel.class, new TunnelKey(destinationDpn, sourceDpn));
+ .child(InternalTunnel.class, new InternalTunnelKey(destinationDpn, sourceDpn));
- Optional<Tunnel> tnl = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
+ Optional<InternalTunnel> tnl = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
if( tnl != null && tnl.isPresent())
{
- Tunnel tunnel = tnl.get();
+ InternalTunnel tunnel = tnl.get();
GetTunnelInterfaceNameOutputBuilder output = new GetTunnelInterfaceNameOutputBuilder() ;
output.setInterfaceName(tunnel.getTunnelInterfaceName()) ;
resultBld = RpcResultBuilder.success();
@Override
public Future<RpcResult<Void>> removeExternalTunnelEndpoint(
RemoveExternalTunnelEndpointInput input) {
- // TODO Auto-generated method stub
- return null;
+ //Ignore the Futures for now
+ final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
+ List<DPNTEPsInfo> meshedDpnList = ItmUtils.getTunnelMeshInfo(dataBroker) ;
+ ItmExternalTunnelDeleteWorker.deleteTunnels(dataBroker, idManagerService,meshedDpnList , input.getDestinationIp(), input.getTunnelType());
+ result.set(RpcResultBuilder.<Void>success().build());
+ return result;
}
@Override
RemoveExternalTunnelFromDpnsInput input) {
//Ignore the Futures for now
final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
-// ItmExternalTunnelDeleteWorker.buildTunnelsFromDpnToExternalEndPoint(dataBroker, input.getDpnId(), null, input.getDestinationIp());
+ List<DPNTEPsInfo> cfgDpnList = ItmUtils.getDPNTEPListFromDPNId(dataBroker, input.getDpnId()) ;
+ ItmExternalTunnelDeleteWorker.deleteTunnels(dataBroker, idManagerService, cfgDpnList, input.getDestinationIp(), input.getTunnelType());
result.set(RpcResultBuilder.<Void>success().build());
return result;
}
BuildExternalTunnelFromDpnsInput input) {
//Ignore the Futures for now
final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
- List<ListenableFuture<Void>> extTunnelResultList = ItmExternalTunnelAddWorker.buildTunnelsFromDpnToExternalEndPoint(dataBroker, input.getDpnId(), input.getDestinationIp(), input.getTunnelType());
+ List<ListenableFuture<Void>> extTunnelResultList = ItmExternalTunnelAddWorker.buildTunnelsFromDpnToExternalEndPoint(dataBroker, idManagerService,input.getDpnId(), input.getDestinationIp(), input.getTunnelType());
for (ListenableFuture<Void> extTunnelResult : extTunnelResultList) {
Futures.addCallback(extTunnelResult, new FutureCallback<Void>(){
//Ignore the Futures for now
final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
- // ItmExternalTunnelAddWorker.buildTunnelsToExternalEndPoint(dataBroker, null, input.getDestinationIp()) ;
+ List<DPNTEPsInfo> meshedDpnList = ItmUtils.getTunnelMeshInfo(dataBroker) ;
+ ItmExternalTunnelAddWorker.buildTunnelsToExternalEndPoint(dataBroker, idManagerService,meshedDpnList, input.getDestinationIp(), input.getTunnelType()) ;
result.set(RpcResultBuilder.<Void>success().build());
return result;
}
new BigInteger(1, vxLANHeader),
MetaDataUtil.METADA_MASK_VALID_TUNNEL_ID_BIT_AND_TUNNEL_ID }));
- Flow terminatingServiceTableFlow = MDSALUtil.buildFlowNew(ITMConstants.INTERNAL_TUNNEL_TABLE,
- getFlowRef(ITMConstants.INTERNAL_TUNNEL_TABLE,serviceId), 5, String.format("%s:%d","ITM Flow Entry ",serviceId),
+ Flow terminatingServiceTableFlow = MDSALUtil.buildFlowNew(NwConstants.INTERNAL_TUNNEL_TABLE,
+ getFlowRef(NwConstants.INTERNAL_TUNNEL_TABLE,serviceId), 5, String.format("%s:%d","ITM Flow Entry ",serviceId),
0, 0, ITMConstants.COOKIE_ITM.add(BigInteger.valueOf(serviceId)),mkMatches, input.getInstruction());
ListenableFuture<Void> installFlowResult = mdsalManager.installFlow(input.getDpnId(), terminatingServiceTableFlow);
public Future<RpcResult<java.lang.Void>> removeTerminatingServiceActions(final RemoveTerminatingServiceActionsInput input) {
LOG.info("remove terminatingServiceActions called with DpnId = {} and serviceId = {}", input.getDpnId(), input.getServiceId());
final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
- Flow terminatingServiceTableFlow = MDSALUtil.buildFlowNew(ITMConstants.INTERNAL_TUNNEL_TABLE,
- getFlowRef(ITMConstants.INTERNAL_TUNNEL_TABLE,input.getServiceId()), 5, String.format("%s:%d","ITM Flow Entry ",input.getServiceId()),
+ Flow terminatingServiceTableFlow = MDSALUtil.buildFlowNew(NwConstants.INTERNAL_TUNNEL_TABLE,
+ getFlowRef(NwConstants.INTERNAL_TUNNEL_TABLE,input.getServiceId()), 5, String.format("%s:%d","ITM Flow Entry ",input.getServiceId()),
0, 0, ITMConstants.COOKIE_ITM.add(BigInteger.valueOf(input.getServiceId())),getTunnelMatchesForServiceId(input.getServiceId()), null );
ListenableFuture<Void> installFlowResult = mdsalManager.installFlow(input.getDpnId(), terminatingServiceTableFlow);
return new StringBuffer().append(termSvcTable).append(svcId).toString();
}
+ @Override
+ public Future<RpcResult<GetInternalOrExternalInterfaceNameOutput>> getInternalOrExternalInterfaceName(
+ GetInternalOrExternalInterfaceNameInput input) {
+ RpcResultBuilder<GetInternalOrExternalInterfaceNameOutput> resultBld = null;
+ BigInteger srcDpn = input.getSourceDpid() ;
+ IpAddress dstIp = input.getDestinationIp() ;
+ List<DPNTEPsInfo> meshedDpnList = ItmUtils.getTunnelMeshInfo(dataBroker) ;
+ // Look for external tunnels if not look for internal tunnel
+ for( DPNTEPsInfo teps : meshedDpnList) {
+ TunnelEndPoints firstEndPt = teps.getTunnelEndPoints().get(0) ;
+ if( dstIp.equals(firstEndPt.getIpAddress())) {
+ InstanceIdentifier<InternalTunnel> path = InstanceIdentifier.create(
+ TunnelList.class)
+ .child(InternalTunnel.class, new InternalTunnelKey(srcDpn, teps.getDPNID()));
+
+ Optional<InternalTunnel> tnl = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
+ if( tnl != null && tnl.isPresent())
+ {
+ InternalTunnel tunnel = tnl.get();
+ GetInternalOrExternalInterfaceNameOutputBuilder output = new GetInternalOrExternalInterfaceNameOutputBuilder().setInterfaceName(tunnel.getTunnelInterfaceName() );
+ resultBld = RpcResultBuilder.success();
+ resultBld.withResult(output.build()) ;
+ }else {
+ //resultBld = RpcResultBuilder.failed();
+ InstanceIdentifier<ExternalTunnel> path1 = InstanceIdentifier.create(
+ ExternalTunnelList.class)
+ .child(ExternalTunnel.class, new ExternalTunnelKey(dstIp, srcDpn));
+
+ Optional<ExternalTunnel> ext = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path1, dataBroker);
+
+ if( ext != null && ext.isPresent())
+ {
+ ExternalTunnel extTunnel = ext.get();
+ GetInternalOrExternalInterfaceNameOutputBuilder output = new GetInternalOrExternalInterfaceNameOutputBuilder().setInterfaceName(extTunnel.getTunnelInterfaceName() );
+ resultBld = RpcResultBuilder.success();
+ resultBld.withResult(output.build()) ;
+ }else {
+ resultBld = RpcResultBuilder.failed();
+ }
+ }
+ }
+ }
+ return Futures.immediateFuture(resultBld.build());
+ }
+
}
--- /dev/null
+/*
+ * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.datastoreutils;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import org.opendaylight.controller.md.sal.binding.api.*;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+public abstract class AsyncClusteredDataChangeListenerBase<T extends DataObject, K extends ClusteredDataChangeListener> implements ClusteredDataChangeListener, AutoCloseable {
+ private static final Logger LOG = LoggerFactory.getLogger(AsyncClusteredDataChangeListenerBase.class);
+
+ private static final int DATATREE_CHANGE_HANDLER_THREAD_POOL_CORE_SIZE = 1;
+ private static final int DATATREE_CHANGE_HANDLER_THREAD_POOL_MAX_SIZE = 1;
+ private static final int DATATREE_CHANGE_HANDLER_THREAD_POOL_KEEP_ALIVE_TIME_SECS = 300;
+ private static final int STARTUP_LOOP_TICK = 500;
+ private static final int STARTUP_LOOP_MAX_RETRIES = 8;
+
+ private static ThreadPoolExecutor dataChangeHandlerExecutor = new ThreadPoolExecutor(
+ DATATREE_CHANGE_HANDLER_THREAD_POOL_CORE_SIZE,
+ DATATREE_CHANGE_HANDLER_THREAD_POOL_MAX_SIZE,
+ DATATREE_CHANGE_HANDLER_THREAD_POOL_KEEP_ALIVE_TIME_SECS,
+ TimeUnit.SECONDS,
+ new LinkedBlockingQueue<Runnable>());
+
+ private ListenerRegistration<K> listenerRegistration;
+ protected final Class<T> clazz;
+ private final Class<K> eventClazz;
+
+ /**
+ * @param clazz - for which the data change event is received
+ */
+ public AsyncClusteredDataChangeListenerBase(Class<T> clazz, Class<K> eventClazz) {
+ this.clazz = Preconditions.checkNotNull(clazz, "Class can not be null!");
+ this.eventClazz = Preconditions.checkNotNull(eventClazz, "eventClazz can not be null!");
+ }
+
+ public void registerListener(final LogicalDatastoreType dsType, final DataBroker db) {
+ try {
+ TaskRetryLooper looper = new TaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
+ listenerRegistration = looper.loopUntilNoException(new Callable<ListenerRegistration<K>>() {
+ @Override
+ public ListenerRegistration call() throws Exception {
+ return db.registerDataChangeListener(dsType, getWildCardPath(), getDataChangeListener(), getDataChangeScope());
+ }
+ });
+ } catch (final Exception e) {
+ LOG.warn("{}: Data Tree Change listener registration failed.", eventClazz.getName());
+ LOG.debug("{}: Data Tree Change listener registration failed: {}", eventClazz.getName(), e);
+ throw new IllegalStateException( eventClazz.getName() + "{}startup failed. System needs restart.", e);
+ }
+ }
+
+ @Override
+ public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changeEvent) {
+ if (changeEvent == null) {
+ return;
+ }
+
+ DataChangeHandler dataChangeHandler = new DataChangeHandler(changeEvent);
+ dataChangeHandlerExecutor.execute(dataChangeHandler);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void createData(final Map<InstanceIdentifier<?>, DataObject> createdData) {
+ final Set<InstanceIdentifier<?>> keys = createdData.keySet() != null
+ ? createdData.keySet() : Collections.<InstanceIdentifier<?>>emptySet();
+ for (InstanceIdentifier<?> key : keys) {
+ if (clazz.equals(key.getTargetType())) {
+ InstanceIdentifier<T> createKeyIdent = key.firstIdentifierOf(clazz);
+ final Optional<DataObject> value = Optional.of(createdData.get(key));
+ if (value.isPresent()) {
+ this.add(createKeyIdent, (T)value.get());
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void updateData(final Map<InstanceIdentifier<?>, DataObject> updateData,
+ final Map<InstanceIdentifier<?>, DataObject> originalData) {
+
+ final Set<InstanceIdentifier<?>> keys = updateData.keySet() != null
+ ? updateData.keySet() : Collections.<InstanceIdentifier<?>>emptySet();
+ for (InstanceIdentifier<?> key : keys) {
+ if (clazz.equals(key.getTargetType())) {
+ InstanceIdentifier<T> updateKeyIdent = key.firstIdentifierOf(clazz);
+ final Optional<DataObject> value = Optional.of(updateData.get(key));
+ final Optional<DataObject> original = Optional.of(originalData.get(key));
+ if (value.isPresent() && original.isPresent()) {
+ this.update(updateKeyIdent, (T) original.get(), (T) value.get());
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void removeData(final Set<InstanceIdentifier<?>> removeData,
+ final Map<InstanceIdentifier<?>, DataObject> originalData) {
+
+ for (InstanceIdentifier<?> key : removeData) {
+ if (clazz.equals(key.getTargetType())) {
+ final InstanceIdentifier<T> ident = key.firstIdentifierOf(clazz);
+ final DataObject removeValue = originalData.get(key);
+ this.remove(ident, (T)removeValue);
+ }
+ }
+ }
+
+ @Override
+ public void close() throws Exception {
+ if (listenerRegistration != null) {
+ try {
+ listenerRegistration.close();
+ } catch (final Exception e) {
+ LOG.error("Error when cleaning up ClusteredDataChangeListener.", e);
+ }
+ listenerRegistration = null;
+ }
+ LOG.info("Interface Manager Closed");
+ }
+
+ protected abstract void remove(InstanceIdentifier<T> identifier, T del);
+
+ protected abstract void update(InstanceIdentifier<T> identifier, T original, T update);
+
+ protected abstract void add(InstanceIdentifier<T> identifier, T add);
+
+ protected abstract InstanceIdentifier<T> getWildCardPath();
+
+ protected abstract ClusteredDataChangeListener getDataChangeListener();
+
+ protected abstract AsyncDataBroker.DataChangeScope getDataChangeScope();
+
+ public class DataChangeHandler implements Runnable {
+ final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changeEvent;
+
+ public DataChangeHandler(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changeEvent) {
+ this.changeEvent = changeEvent;
+ }
+
+ @Override
+ public void run() {
+ Preconditions.checkNotNull(changeEvent,"Async ChangeEvent can not be null!");
+
+ /* All DataObjects for create */
+ final Map<InstanceIdentifier<?>, DataObject> createdData = changeEvent.getCreatedData() != null
+ ? changeEvent.getCreatedData() : Collections.<InstanceIdentifier<?>, DataObject>emptyMap();
+ /* All DataObjects for remove */
+ final Set<InstanceIdentifier<?>> removeData = changeEvent.getRemovedPaths() != null
+ ? changeEvent.getRemovedPaths() : Collections.<InstanceIdentifier<?>>emptySet();
+ /* All DataObjects for updates */
+ final Map<InstanceIdentifier<?>, DataObject> updateData = changeEvent.getUpdatedData() != null
+ ? changeEvent.getUpdatedData() : Collections.<InstanceIdentifier<?>, DataObject>emptyMap();
+ /* All Original DataObjects */
+ final Map<InstanceIdentifier<?>, DataObject> originalData = changeEvent.getOriginalData() != null
+ ? changeEvent.getOriginalData() : Collections.<InstanceIdentifier<?>, DataObject>emptyMap();
+
+ createData(createdData);
+ updateData(updateData, originalData);
+ removeData(removeData, originalData);
+ }
+ }
+}
@Override
public Action buildAction(ActionInfo actionInfo) {
BigInteger [] actionValues = actionInfo.getBigActionValues();
- return new ActionBuilder().setAction(
+ if (actionValues.length == 2) {
+ return new ActionBuilder().setAction(
+ new SetFieldCaseBuilder().setSetField(
+ new SetFieldBuilder()
+ .setTunnel(new TunnelBuilder().setTunnelId(actionValues[0])
+ .setTunnelMask(actionValues[1]).build()).build())
+ .build())
+ .setKey(new ActionKey(actionInfo.getActionKey())).build();
+ } else {
+ return new ActionBuilder().setAction(
new SetFieldCaseBuilder().setSetField(
- new SetFieldBuilder().setTunnel(new TunnelBuilder().setTunnelId(actionValues[0])
- .setTunnelMask(actionValues[1]).build()).build()).build())
- .setKey(new ActionKey(actionInfo.getActionKey())).build();
+ new SetFieldBuilder()
+ .setTunnel(new TunnelBuilder().setTunnelId(actionValues[0])
+ .build()).build())
+ .build())
+ .setKey(new ActionKey(actionInfo.getActionKey())).build();
+ }
}
public static final BigInteger METADATA_MASK_LPORT_WRITE = new BigInteger("00FFFF0000000000", 16);
public static final BigInteger METADA_MASK_VALID_TUNNEL_ID_BIT_AND_TUNNEL_ID = new BigInteger("08000000FFFFFF00", 16);
public static final BigInteger METADATA_MASK_LABEL_ITM = new BigInteger("40FFFFFF000000FF", 16);
+ public static final BigInteger METADA_MASK_TUNNEL_ID = new BigInteger("00000000FFFFFF00", 16);
public static BigInteger getMetaDataForLPortDispatcher(int lportTag, short serviceIndex) {
return getServiceIndexMetaData(serviceIndex).or(getLportTagMetaData(lportTag));
public static final int DEFAULT_ARP_FLOW_PRIORITY = 100;
+ //Table IDs
+ public static final short L3_FIB_TABLE = 21;
+ public static final short L3_LFIB_TABLE = 20;
+
+ public static final short L3_PROTOCOL_TABLE = 36;
+ public static final short L3_INTERFACE_TABLE = 80;
+ public static final short LPORT_DISPATCHER_TABLE = 30;
+ public static final short VLAN_INTERFACE_INGRESS_TABLE = 0;
+ public static final short INTERNAL_TUNNEL_TABLE = 36;
+ public static final short EXTERNAL_TUNNEL_TABLE = 38;
+
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
-Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v1.0 which accompanies this distribution,
/*
- * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
}
}
+ /* container for DHCP Configuration */
+ container dhcp-config {
+ list configs {
+ leaf lease-duration {
+ type int32;
+ description "default lease duration for dhcp lease.
+ -1 means infinite";
+ }
+ leaf default-domain {
+ type string;
+ description "default domain-name. used in dhcp reply";
+ }
+ }
+ }
+
rpc createL3VPN{
description "Create one or more L3 VPN";
input {
<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: --><!--
-Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+<!--
+Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v1.0 which accompanies this distribution,
<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
<!--
-Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v1.0 which accompanies this distribution,
/*
- * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
/*
- * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
/*
- * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
package org.opendaylight.vpnservice.neutronvpn;
+import com.google.common.base.Optional;
+
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.vpnservice.mdsalutil.AbstractDataChangeListener;
+import org.opendaylight.vpnservice.mdsalutil.MDSALUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.neutron.port.data
+ .PortFixedipToPortNameBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.neutron.port.data
+ .PortNameToPortUuidBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.subnetmaps.Subnetmap;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
if (LOG.isTraceEnabled()) {
LOG.trace("Adding Port : key: " + identifier + ", value=" + input);
}
- nvpnManager.handleNeutronPortCreated(input);
+ handleNeutronPortCreated(input);
}
if (LOG.isTraceEnabled()) {
LOG.trace("Removing Port : key: " + identifier + ", value=" + input);
}
- nvpnManager.handleNeutronPortDeleted(input);
+ handleNeutronPortDeleted(input);
}
iterator.remove();
}
}
- nvpnManager.handleNeutronPortUpdated(original, update);
+ handleNeutronPortUpdated(original, update);
+ }
+ }
+
+ private void handleNeutronPortCreated(Port port) {
+ LOG.info("Of-port-interface creation");
+ int portVlanId = NeutronvpnUtils.getVlanFromNeutronPort(port);
+ // Create of-port interface for this neutron port
+ createOfPortInterface(port, portVlanId);
+ LOG.debug("Add port to subnet");
+ // add port to local Subnets DS
+ Uuid vpnId = addPortToSubnets(port);
+
+ if (vpnId != null) {
+ // create vpn-interface on this neutron port
+ LOG.debug("Adding VPN Interface");
+ nvpnManager.createVpnInterface(vpnId, port);
+ }
+ }
+
+ private void handleNeutronPortDeleted(Port port) {
+ LOG.debug("Of-port-interface removal");
+ LOG.debug("Remove port from subnet");
+ // remove port from local Subnets DS
+ Uuid vpnId = removePortFromSubnets(port);
+
+ if (vpnId != null) {
+ // remove vpn-interface for this neutron port
+ LOG.debug("removing VPN Interface");
+ nvpnManager.deleteVpnInterface(port);
+ }
+ int portVlanId = NeutronvpnUtils.getVlanFromNeutronPort(port);
+ // Remove of-port interface for this neutron port
+ deleteOfPortInterface(port, portVlanId);
+
+ }
+
+ private void handleNeutronPortUpdated(Port portoriginal, Port portupdate) {
+ LOG.debug("Add port to subnet");
+ // add port FixedIPs to local Subnets DS
+ Uuid vpnIdup = addPortToSubnets(portupdate);
+
+ if (vpnIdup != null) {
+ nvpnManager.createVpnInterface(vpnIdup, portupdate);
+ }
+
+ // remove port FixedIPs from local Subnets DS
+ Uuid vpnIdor = removePortFromSubnets(portoriginal);
+
+ if (vpnIdor != null) {
+ nvpnManager.deleteVpnInterface(portoriginal);
+ }
+ }
+
+ private void createOfPortInterface(Port port, int portVlanId) {
+ String name = NeutronvpnUtils.uuidToTapPortName(port.getUuid());
+ //String ifname = new StringBuilder(name).append(":").append(Integer.toString(portVlanId)).toString();
+ //Network network = NeutronvpnUtils.getNeutronNetwork(broker, port.getNetworkId());
+ //Boolean isVlanTransparent = network.isVlanTransparent();
+
+ LOG.debug("Creating OFPort Interface {}", name);
+ InstanceIdentifier interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(name);
+ try {
+ Optional<Interface> optionalInf = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION,
+ interfaceIdentifier);
+ if (!optionalInf.isPresent()) {
+ // handle these for trunkport extensions : portVlanId, isVlanTransparent
+ Interface inf = new InterfaceBuilder().setEnabled(true).setName(name).setType(L2vlan.class).build();
+ MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, interfaceIdentifier, inf);
+ } else {
+ LOG.error("Interface {} is already present", name);
+ }
+ } catch (Exception e) {
+ LOG.error("failed to create interface {} due to the exception {} ", name, e.getMessage());
+ }
+
+ InstanceIdentifier portIdentifier = NeutronvpnUtils.buildPortNameToPortUuidIdentifier(name);
+ PortNameToPortUuidBuilder builder = new PortNameToPortUuidBuilder().setPortName(name).setPortId(port.getUuid());
+ MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, portIdentifier, builder.build());
+ LOG.debug("name-uuid map for port with name: {}, uuid: {} added to NeutronPortData DS", name, port.getUuid
+ ());
+ }
+
+ private void deleteOfPortInterface(Port port, int portVlanId) {
+ String name = NeutronvpnUtils.uuidToTapPortName(port.getUuid());
+ //String ifname = new StringBuilder(name).append(":").append(Integer.toString(portVlanId)).toString();
+ LOG.debug("Removing OFPort Interface {}", name);
+ InstanceIdentifier interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(name);
+ try {
+ Optional<Interface> optionalInf = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION,
+ interfaceIdentifier);
+ if (optionalInf.isPresent()) {
+ MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, interfaceIdentifier);
+ } else {
+ LOG.error("Interface {} is not present", name);
+ }
+ } catch (Exception e) {
+ LOG.error("Failed to delete interface {} due to the exception {}", name, e.getMessage());
+ }
+
+ InstanceIdentifier portIdentifier = NeutronvpnUtils.buildPortNameToPortUuidIdentifier(name);
+ MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, portIdentifier);
+ LOG.debug("name-uuid map for port with name: {}, uuid: {} deleted from NeutronPortData DS", name, port
+ .getUuid());
+ }
+
+ // adds port to subnet list and creates vpnInterface
+ private Uuid addPortToSubnets(Port port) {
+ Uuid subnetId = null;
+ Uuid vpnId = null;
+ String name = NeutronvpnUtils.uuidToTapPortName(port.getUuid());
+
+ // find all subnets to which this port is associated
+ List<FixedIps> ips = port.getFixedIps();
+ for (FixedIps ip : ips) {
+ String ipValue = ip.getIpAddress().getIpv4Address().getValue();
+
+ InstanceIdentifier id = NeutronvpnUtils.buildFixedIpToPortNameIdentifier(ipValue);
+ PortFixedipToPortNameBuilder builder = new PortFixedipToPortNameBuilder().setPortFixedip(ipValue)
+ .setPortName(name);
+ MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, id, builder.build());
+ LOG.debug("fixedIp-name map for neutron port with fixedIp: {}, name: {} added to NeutronPortData DS",
+ ipValue, name);
+
+ subnetId = ip.getSubnetId();
+ Subnetmap subnetmap = nvpnManager.updateSubnetNode(subnetId, null, null, null, null, port.getUuid());
+ if (vpnId == null && subnetmap != null) {
+ vpnId = subnetmap.getVpnId();
+ }
+ }
+ return vpnId;
+ }
+
+ private Uuid removePortFromSubnets(Port port) {
+ Uuid subnetId = null;
+ Uuid vpnId = null;
+
+ // find all Subnets to which this port is associated
+ List<FixedIps> ips = port.getFixedIps();
+ for (FixedIps ip : ips) {
+ String ipValue = ip.getIpAddress().getIpv4Address().getValue();
+
+ InstanceIdentifier id = NeutronvpnUtils.buildFixedIpToPortNameIdentifier(ipValue);
+ MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, id);
+ LOG.debug("fixedIp-name map for neutron port with fixedIp: {} deleted from NeutronPortData DS", ipValue);
+
+ subnetId = ip.getSubnetId();
+ Subnetmap subnetmap = nvpnManager.removeFromSubnetNode(subnetId, null, null, null, port.getUuid());
+ if (vpnId == null && subnetmap != null) {
+ vpnId = subnetmap.getVpnId();
+ }
}
+ return vpnId;
}
}
/*
- * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
/*
- * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
*/
package org.opendaylight.vpnservice.neutronvpn;
+import com.google.common.base.Optional;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.vpnservice.mdsalutil.AbstractDataChangeListener;
+import org.opendaylight.vpnservice.mdsalutil.MDSALUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.networkmaps.NetworkMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.networkmaps.NetworkMapBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.networkmaps.NetworkMapKey;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.ArrayList;
+import java.util.List;
+
public class NeutronSubnetChangeListener extends AbstractDataChangeListener<Subnet> implements AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(NeutronSubnetChangeListener.class);
if (LOG.isTraceEnabled()) {
LOG.trace("Adding Subnet : key: " + identifier + ", value=" + input);
}
- nvpnManager.handleNeutronSubnetCreated(input.getUuid(), input.getNetworkId(), input.getTenantId());
+ handleNeutronSubnetCreated(input.getUuid(), input.getNetworkId(), input.getTenantId());
}
@Override
if (LOG.isTraceEnabled()) {
LOG.trace("Removing subnet : key: " + identifier + ", value=" + input);
}
- nvpnManager.handleNeutronSubnetDeleted(input.getUuid(), input.getNetworkId(), null);
+ handleNeutronSubnetDeleted(input.getUuid(), input.getNetworkId(), null);
}
@Override
LOG.trace("Updating Subnet : key: " + identifier + ", original value=" + original + ", update value=" +
update);
}
- nvpnManager.handleNeutronSubnetUpdated(update.getUuid(), update.getNetworkId(), update.getTenantId());
+ handleNeutronSubnetUpdated(update.getUuid(), update.getNetworkId(), update.getTenantId());
+ }
+
+ private void handleNeutronSubnetCreated(Uuid subnetId, Uuid networkId, Uuid tenantId) {
+ nvpnManager.updateSubnetNode(subnetId, tenantId, networkId, null, null, null);
+ if (networkId != null && NeutronvpnUtils.getNeutronNetwork(broker, networkId) != null) {
+ createSubnetToNetworkMapping(subnetId, networkId);
+ }
+ }
+
+ private void handleNeutronSubnetDeleted(Uuid subnetId, Uuid networkId, Uuid tenantId) {
+ Uuid vpnId = NeutronvpnUtils.getVpnForNetwork(broker, networkId);
+ if (vpnId != null) {
+ nvpnManager.removeSubnetFromVpn(vpnId, subnetId);
+ }
+ if (networkId != null) {
+ deleteSubnetToNetworkMapping(subnetId, networkId);
+ }
+ }
+
+ private void handleNeutronSubnetUpdated(Uuid subnetId, Uuid networkId, Uuid tenantId) {
+ Uuid oldNetworkId = NeutronvpnUtils.getSubnetmap(broker, subnetId).getNetworkId();
+ if (oldNetworkId != null && !oldNetworkId.equals(networkId)) {
+ deleteSubnetToNetworkMapping(subnetId, oldNetworkId);
+ }
+ if (networkId != null && !networkId.equals(oldNetworkId)) {
+ createSubnetToNetworkMapping(subnetId, networkId);
+ }
+ nvpnManager.updateSubnetNode(subnetId, tenantId, networkId, null, null, null);
+ }
+
+ private void createSubnetToNetworkMapping(Uuid subnetId, Uuid networkId) {
+ try {
+ InstanceIdentifier networkMapIdentifier = NeutronvpnUtils.buildNetworkMapIdentifier(networkId);
+ Optional<NetworkMap> optionalNetworkMap = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION,
+ networkMapIdentifier);
+ NetworkMapBuilder nwMapBuilder = null;
+ if (optionalNetworkMap.isPresent()) {
+ nwMapBuilder = new NetworkMapBuilder(optionalNetworkMap.get());
+ } else {
+ nwMapBuilder = new NetworkMapBuilder().setKey(new NetworkMapKey(networkId)).setNetworkId(networkId);
+ LOG.debug("Adding a new network node in NetworkMaps DS for network {}", networkId.getValue());
+ }
+ List<Uuid> subnetIdList = nwMapBuilder.getSubnetIdList();
+ if (subnetIdList == null) {
+ subnetIdList = new ArrayList<>();
+ }
+ subnetIdList.add(subnetId);
+ nwMapBuilder.setSubnetIdList(subnetIdList);
+ MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, networkMapIdentifier, nwMapBuilder.build());
+ LOG.debug("Created subnet-network mapping for subnet {} network {}", subnetId.getValue(),
+ networkId.getValue());
+ } catch (Exception e) {
+ LOG.error("Create subnet-network mapping failed for subnet {} network {}", subnetId.getValue(),
+ networkId.getValue());
+ }
+ }
+
+ private void deleteSubnetToNetworkMapping(Uuid subnetId, Uuid networkId) {
+ try {
+ InstanceIdentifier networkMapIdentifier = NeutronvpnUtils.buildNetworkMapIdentifier(networkId);
+ Optional<NetworkMap> optionalNetworkMap = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION,
+ networkMapIdentifier);
+ if (optionalNetworkMap.isPresent()) {
+ NetworkMapBuilder nwMapBuilder = new NetworkMapBuilder(optionalNetworkMap.get());
+ List<Uuid> subnetIdList = nwMapBuilder.getSubnetIdList();
+ if (subnetIdList.remove(subnetId)) {
+ if (subnetIdList.size() == 0) {
+ MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, networkMapIdentifier);
+ LOG.debug("Deleted network node in NetworkMaps DS for network {}", subnetId.getValue(),
+ networkId.getValue());
+ } else {
+ nwMapBuilder.setSubnetIdList(subnetIdList);
+ MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, networkMapIdentifier,
+ nwMapBuilder.build());
+ LOG.debug("Deleted subnet-network mapping for subnet {} network {}", subnetId.getValue(),
+ networkId.getValue());
+ }
+ } else {
+ LOG.error("Subnet {} is not mapped to network {}", subnetId.getValue(), networkId.getValue());
+ }
+ } else {
+ LOG.error("network {} not present for subnet {} ", networkId, subnetId);
+ }
+ } catch (Exception e) {
+ LOG.error("Delete subnet-network mapping failed for subnet {} network {}", subnetId.getValue(),
+ networkId.getValue());
+ }
}
}
/*
- * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import com.google.common.util.concurrent.SettableFuture;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.vpnservice.mdsalutil.MDSALUtil;
import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface;
import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterfaceBuilder;
import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterfaceKey;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.Adjacencies;
import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.AdjacenciesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.getl3vpn.output.L3vpnInstances;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.getl3vpn.output
.L3vpnInstancesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.networkmaps.NetworkMap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.networkmaps.NetworkMapBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.networkmaps.NetworkMapKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.neutron.port.data
- .PortFixedipToPortNameBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.neutron.port.data
- .PortNameToPortUuidBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.subnetmaps.Subnetmap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.subnetmaps.SubnetmapBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.subnetmaps.SubnetmapKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.vpnmaps.VpnMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.vpnmaps.VpnMapBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.vpnmaps.VpnMapKey;
-import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
InstanceIdentifier<Subnetmap> id = InstanceIdentifier.builder(Subnetmaps.class).
child(Subnetmap.class, new SubnetmapKey(subnetId)).build();
- Optional<Subnetmap> sn = read(LogicalDatastoreType.CONFIGURATION, id);
+ Optional<Subnetmap> sn = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION, id);
logger.debug("updating Subnet :read: ");
if (sn.isPresent()) {
builder = new SubnetmapBuilder(sn.get());
try {
InstanceIdentifier<Subnetmap> id = InstanceIdentifier.builder(Subnetmaps.class).
child(Subnetmap.class, new SubnetmapKey(subnetId)).build();
- Optional<Subnetmap> sn = read(LogicalDatastoreType.CONFIGURATION, id);
+ Optional<Subnetmap> sn = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION, id);
if (sn.isPresent()) {
SubnetmapBuilder builder = new SubnetmapBuilder(sn.get());
return subnetmap;
}
- private void createSubnetToNetworkMapping(Uuid subnetId, Uuid networkId) {
- try {
- InstanceIdentifier networkMapIdentifier = NeutronvpnUtils.buildNetworkMapIdentifier(networkId);
- Optional<NetworkMap> optionalNetworkMap = read(LogicalDatastoreType.CONFIGURATION, networkMapIdentifier);
- NetworkMapBuilder nwMapBuilder = null;
- if (optionalNetworkMap.isPresent()) {
- nwMapBuilder = new NetworkMapBuilder(optionalNetworkMap.get());
- } else {
- nwMapBuilder = new NetworkMapBuilder().setKey(new NetworkMapKey(networkId)).setNetworkId(networkId);
- logger.debug("Adding a new network node in NetworkMaps DS for network {}", networkId.getValue());
- }
- List<Uuid> subnetIdList = nwMapBuilder.getSubnetIdList();
- if (subnetIdList == null) {
- subnetIdList = new ArrayList<>();
- }
- subnetIdList.add(subnetId);
- nwMapBuilder.setSubnetIdList(subnetIdList);
- MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, networkMapIdentifier, nwMapBuilder.build());
- logger.debug("Created subnet-network mapping for subnet {} network {}", subnetId.getValue(),
- networkId.getValue());
- } catch (Exception e) {
- logger.error("Create subnet-network mapping failed for subnet {} network {}", subnetId.getValue(),
- networkId.getValue());
- }
- }
-
- private void deleteSubnetToNetworkMapping(Uuid subnetId, Uuid networkId) {
- try {
- InstanceIdentifier networkMapIdentifier = NeutronvpnUtils.buildNetworkMapIdentifier(networkId);
- Optional<NetworkMap> optionalNetworkMap = read(LogicalDatastoreType.CONFIGURATION, networkMapIdentifier);
- if (optionalNetworkMap.isPresent()) {
- NetworkMapBuilder nwMapBuilder = new NetworkMapBuilder(optionalNetworkMap.get());
- List<Uuid> subnetIdList = nwMapBuilder.getSubnetIdList();
- if (subnetIdList.remove(subnetId)) {
- if (subnetIdList.size() == 0) {
- MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, networkMapIdentifier);
- logger.debug("Deleted network node in NetworkMaps DS for network {}", subnetId.getValue(),
- networkId.getValue());
- } else {
- nwMapBuilder.setSubnetIdList(subnetIdList);
- MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, networkMapIdentifier,
- nwMapBuilder.build());
- logger.debug("Deleted subnet-network mapping for subnet {} network {}", subnetId.getValue(),
- networkId.getValue());
- }
- } else {
- logger.error("Subnet {} is not mapped to network {}", subnetId.getValue(), networkId.getValue());
- }
- } else {
- logger.error("network {} not present for subnet {} ", networkId, subnetId);
- }
- } catch (Exception e) {
- logger.error("Delete subnet-network mapping failed for subnet {} network {}", subnetId.getValue(),
- networkId.getValue());
- }
- }
-
private void updateVpnInstanceNode(String name, List<String> rd, List<String> irt, List<String> ert) {
try {
List<VpnTarget> vpnTargetList = new ArrayList<VpnTarget>();
InstanceIdentifier<VpnInstance> vpnIdentifier = InstanceIdentifier.builder(VpnInstances.class).
child(VpnInstance.class, new VpnInstanceKey(name)).build();
- Optional<VpnInstance> optionalVpn = read(LogicalDatastoreType.CONFIGURATION, vpnIdentifier);
+ Optional<VpnInstance> optionalVpn = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION,
+ vpnIdentifier);
logger.debug("Creating/Updating a new vpn-instance node: {} ", name);
if (optionalVpn.isPresent()) {
builder = new VpnInstanceBuilder(optionalVpn.get());
VpnMapBuilder builder;
InstanceIdentifier<VpnMap> vpnMapIdentifier = InstanceIdentifier.builder(VpnMaps.class)
.child(VpnMap.class, new VpnMapKey(vpnId)).build();
- Optional<VpnMap> optionalVpnMap = read(LogicalDatastoreType.CONFIGURATION, vpnMapIdentifier);
+ Optional<VpnMap> optionalVpnMap = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION,
+ vpnMapIdentifier);
if (optionalVpnMap.isPresent()) {
builder = new VpnMapBuilder(optionalVpnMap.get());
} else {
private void clearFromVpnMaps(Uuid id, Uuid router, List<Uuid> networks) {
InstanceIdentifier<VpnMap> vpnMapIdentifier = InstanceIdentifier.builder(VpnMaps.class)
.child(VpnMap.class, new VpnMapKey(id)).build();
- Optional<VpnMap> optionalVpnMap = read(LogicalDatastoreType.CONFIGURATION, vpnMapIdentifier);
+ Optional<VpnMap> optionalVpnMap = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION,
+ vpnMapIdentifier);
if (optionalVpnMap.isPresent()) {
VpnMap vpnMap = optionalVpnMap.get();
VpnMapBuilder vpnMapBuilder = new VpnMapBuilder(vpnMap);
logger.debug("VPNMaps DS clear success for VPN {} ", id.getValue());
}
- private void createOfPortInterface(Port port, int portVlanId) {
- String name = NeutronvpnUtils.uuidToTapPortName(port.getUuid());
- //String ifname = new StringBuilder(name).append(":").append(Integer.toString(portVlanId)).toString();
- //Network network = NeutronvpnUtils.getNeutronNetwork(broker, port.getNetworkId());
- //Boolean isVlanTransparent = network.isVlanTransparent();
-
- logger.debug("Creating OFPort Interface {}", name);
- InstanceIdentifier interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(name);
- try {
- Optional<Interface> optionalInf = read(LogicalDatastoreType.CONFIGURATION, interfaceIdentifier);
- if (!optionalInf.isPresent()) {
- // handle these for trunkport extensions : portVlanId, isVlanTransparent
- Interface inf = new InterfaceBuilder().setEnabled(true).setName(name).setType(L2vlan.class).build();
- MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, interfaceIdentifier, inf);
- } else {
- logger.error("Interface {} is already present", name);
- }
- } catch (Exception e) {
- logger.error("failed to create interface {} due to the exception {} ", name, e.getMessage());
- }
-
- InstanceIdentifier portIdentifier = NeutronvpnUtils.buildPortNameToPortUuidIdentifier(name);
- PortNameToPortUuidBuilder builder = new PortNameToPortUuidBuilder().setPortName(name).setPortId(port.getUuid());
- MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, portIdentifier, builder.build());
- logger.debug("name-uuid map for port with name: {}, uuid: {} added to NeutronPortData DS", name, port.getUuid
- ());
- }
-
- private void deleteOfPortInterface(Port port, int portVlanId) {
- String name = NeutronvpnUtils.uuidToTapPortName(port.getUuid());
- //String ifname = new StringBuilder(name).append(":").append(Integer.toString(portVlanId)).toString();
- logger.debug("Removing OFPort Interface {}", name);
- InstanceIdentifier interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(name);
- try {
- Optional<Interface> optionalInf = read(LogicalDatastoreType.CONFIGURATION, interfaceIdentifier);
- if (optionalInf.isPresent()) {
- MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, interfaceIdentifier);
- } else {
- logger.error("Interface {} is not present", name);
- }
- } catch (Exception e) {
- logger.error("Failed to delete interface {} due to the exception {}", name, e.getMessage());
- }
-
- InstanceIdentifier portIdentifier = NeutronvpnUtils.buildPortNameToPortUuidIdentifier(name);
- MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, portIdentifier);
- logger.debug("name-uuid map for port with name: {}, uuid: {} deleted from NeutronPortData DS", name, port
- .getUuid());
- }
-
private void deleteVpnInstance(Uuid vpnId) {
InstanceIdentifier<VpnInstance> vpnIdentifier = InstanceIdentifier.builder(VpnInstances.class).
}
- private void createVpnInterface(Uuid vpnId, Port port) {
+ protected void createVpnInterface(Uuid vpnId, Port port) {
if (vpnId == null || port == null) {
return;
}
}
- private void deleteVpnInterface(Port port) {
+ protected void deleteVpnInterface(Port port) {
if (port != null) {
String pname = NeutronvpnUtils.uuidToTapPortName(port.getUuid());
}
}
- // adds port to subnet list and creates vpnInterface
- private Uuid addPortToSubnets(Port port) {
- Uuid subnetId = null;
- Uuid vpnId = null;
- String name = NeutronvpnUtils.uuidToTapPortName(port.getUuid());
-
- // find all subnets to which this port is associated
- List<FixedIps> ips = port.getFixedIps();
- for (FixedIps ip : ips) {
- String ipValue = ip.getIpAddress().getIpv4Address().getValue();
-
- InstanceIdentifier id = NeutronvpnUtils.buildFixedIpToPortNameIdentifier(ipValue);
- PortFixedipToPortNameBuilder builder = new PortFixedipToPortNameBuilder().setPortFixedip(ipValue)
- .setPortName(name);
- MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, id, builder.build());
- logger.debug("fixedIp-name map for neutron port with fixedIp: {}, name: {} added to NeutronPortData DS",
- ipValue, name);
-
- subnetId = ip.getSubnetId();
- Subnetmap subnetmap = updateSubnetNode(subnetId, null, null, null, null, port.getUuid());
- if (vpnId == null && subnetmap != null) {
- vpnId = subnetmap.getVpnId();
- }
- }
- return vpnId;
- }
-
- private Uuid removePortFromSubnets(Port port) {
- Uuid subnetId = null;
- Uuid vpnId = null;
-
- // find all Subnets to which this port is associated
- List<FixedIps> ips = port.getFixedIps();
- for (FixedIps ip : ips) {
- String ipValue = ip.getIpAddress().getIpv4Address().getValue();
-
- InstanceIdentifier id = NeutronvpnUtils.buildFixedIpToPortNameIdentifier(ipValue);
- MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, id);
- logger.debug("fixedIp-name map for neutron port with fixedIp: {} deleted from NeutronPortData DS",
- ipValue);
-
- subnetId = ip.getSubnetId();
- Subnetmap subnetmap = removeFromSubnetNode(subnetId, null, null, null, port.getUuid());
- if (vpnId == null && subnetmap != null) {
- vpnId = subnetmap.getVpnId();
- }
- }
- return vpnId;
- }
-
- protected void handleNeutronSubnetCreated(Uuid subnetId, Uuid networkId, Uuid tenantId) {
- updateSubnetNode(subnetId, tenantId, networkId, null, null, null);
- if (networkId != null && NeutronvpnUtils.getNeutronNetwork(broker, networkId) != null) {
- createSubnetToNetworkMapping(subnetId, networkId);
- }
- }
-
- protected void handleNeutronSubnetDeleted(Uuid subnetId, Uuid networkId, Uuid tenantId) {
- Uuid vpnId = NeutronvpnUtils.getVpnForNetwork(broker, networkId);
- if (vpnId != null) {
- removeSubnetFromVpn(vpnId, subnetId);
- }
- if (networkId != null) {
- deleteSubnetToNetworkMapping(subnetId, networkId);
- }
- }
-
- protected void handleNeutronSubnetUpdated(Uuid subnetId, Uuid networkId, Uuid tenantId) {
- Uuid oldNetworkId = NeutronvpnUtils.getSubnetmap(broker, subnetId).getNetworkId();
- if (oldNetworkId != null && !oldNetworkId.equals(networkId)) {
- deleteSubnetToNetworkMapping(subnetId, oldNetworkId);
- }
- if (networkId != null && !networkId.equals(oldNetworkId)) {
- createSubnetToNetworkMapping(subnetId, networkId);
- }
- updateSubnetNode(subnetId, tenantId, networkId, null, null, null);
- }
-
- protected void handleNeutronPortCreated(Port port) {
- logger.info("Of-port-interface creation");
- int portVlanId = NeutronvpnUtils.getVlanFromNeutronPort(port);
- // Create of-port interface for this neutron port
- createOfPortInterface(port, portVlanId);
- logger.debug("Add port to subnet");
- // add port to local Subnets DS
- Uuid vpnId = addPortToSubnets(port);
-
- if (vpnId != null) {
- // create vpn-interface on this neutron port
- logger.debug("Adding VPN Interface");
- createVpnInterface(vpnId, port);
- }
- }
-
- protected void handleNeutronPortDeleted(Port port) {
- logger.debug("Of-port-interface removal");
- logger.debug("Remove port from subnet");
- // remove port from local Subnets DS
- Uuid vpnId = removePortFromSubnets(port);
-
- if (vpnId != null) {
- // remove vpn-interface for this neutron port
- logger.debug("removing VPN Interface");
- deleteVpnInterface(port);
- }
- int portVlanId = NeutronvpnUtils.getVlanFromNeutronPort(port);
- // Remove of-port interface for this neutron port
- deleteOfPortInterface(port, portVlanId);
-
- }
-
- protected void handleNeutronPortUpdated(Port portoriginal, Port portupdate) {
- logger.debug("Add port to subnet");
- // add port FixedIPs to local Subnets DS
- Uuid vpnIdup = addPortToSubnets(portupdate);
-
- if (vpnIdup != null) {
- createVpnInterface(vpnIdup, portupdate);
- }
-
- // remove port FixedIPs from local Subnets DS
- Uuid vpnIdor = removePortFromSubnets(portoriginal);
-
- if (vpnIdor != null) {
- deleteVpnInterface(portoriginal);
- }
- }
-
public void createL3Vpn(Uuid vpn, String name, Uuid tenant, List<String> rd, List<String> irt, List<String> ert,
Uuid router, List<Uuid> networks) {
// get all vpns
InstanceIdentifier<VpnInstances> vpnsIdentifier =
InstanceIdentifier.builder(VpnInstances.class).build();
- Optional<VpnInstances> optionalVpns = read(LogicalDatastoreType.CONFIGURATION, vpnsIdentifier);
+ Optional<VpnInstances> optionalVpns = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION,
+ vpnsIdentifier);
if (optionalVpns.isPresent()) {
for (VpnInstance vpn : optionalVpns.get().getVpnInstance()) {
vpns.add(vpn);
InstanceIdentifier.builder(VpnInstances.class)
.child(VpnInstance.class, new VpnInstanceKey(name)).build();
// read VpnInstance Info
- Optional<VpnInstance> optionalVpn = read(LogicalDatastoreType.CONFIGURATION, vpnIdentifier);
+ Optional<VpnInstance> optionalVpn = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION,
+ vpnIdentifier);
if (optionalVpn.isPresent()) {
vpns.add(optionalVpn.get());
} else {
}
l3vpn.setId(vpnId).setRouteDistinguisher(rd).setImportRT(irtList).setExportRT(ertList);
- Optional<VpnMap> optionalVpnMap =
- read(LogicalDatastoreType.CONFIGURATION, vpnMapIdentifier);
+ Optional<VpnMap> optionalVpnMap = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION,
+ vpnMapIdentifier);
if (optionalVpnMap.isPresent()) {
VpnMap vpnMap = optionalVpnMap.get();
l3vpn.setRouterId(vpnMap.getRouterId()).setNetworkIds(vpnMap.getNetworkIds())
InstanceIdentifier<VpnInstance> vpnIdentifier =
InstanceIdentifier.builder(VpnInstances.class)
.child(VpnInstance.class, new VpnInstanceKey(vpn.getValue())).build();
- Optional<VpnInstance> optionalVpn = read(LogicalDatastoreType.CONFIGURATION, vpnIdentifier);
+ Optional<VpnInstance> optionalVpn = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION,
+ vpnIdentifier);
if (optionalVpn.isPresent()) {
removeL3Vpn(vpn);
} else {
}
InstanceIdentifier<VpnInterface> vpnIfIdentifier = InstanceIdentifier.builder(VpnInterfaces.class).
child(VpnInterface.class, new VpnInterfaceKey(ifname)).build();
- Optional<VpnInterface> optionalVpnInterface = read(LogicalDatastoreType.CONFIGURATION,
- vpnIfIdentifier);
+ Optional<VpnInterface> optionalVpnInterface = NeutronvpnUtils.read(broker, LogicalDatastoreType
+ .CONFIGURATION, vpnIfIdentifier);
if (optionalVpnInterface.isPresent()) {
Adjacencies erAdjs = new AdjacenciesBuilder().setAdjacency(Arrays.asList(erAdj)).build();
VpnInterface vpnIf = new VpnInterfaceBuilder().setKey(new VpnInterfaceKey(ifname))
return result;
}
- private <T extends DataObject> Optional<T> read(LogicalDatastoreType datastoreType, InstanceIdentifier<T> path) {
-
- ReadOnlyTransaction tx = broker.newReadOnlyTransaction();
-
- Optional<T> result = Optional.absent();
- try {
- result = tx.read(datastoreType, path).get();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
- return result;
- }
-
protected Subnet getNeutronSubnet(Uuid subnetId) {
InstanceIdentifier<Subnet> inst = InstanceIdentifier.create(Neutron.class).
child(Subnets.class).child(Subnet.class, new SubnetKey(subnetId));
- Optional<Subnet> sn = read(LogicalDatastoreType.CONFIGURATION, inst);
+ Optional<Subnet> sn = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION, inst);
if (sn.isPresent()) {
return sn.get();
if (portId != null) {
InstanceIdentifier<Port> pid = InstanceIdentifier.create(Neutron.class).
child(Ports.class).child(Port.class, new PortKey(portId));
- Optional<Port> optPort = read(LogicalDatastoreType.CONFIGURATION, pid);
+ Optional<Port> optPort = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION, pid);
if (optPort.isPresent()) {
return optPort.get();
}
protected Port getNeutronPort(Uuid portId) {
InstanceIdentifier<Port> pid = InstanceIdentifier.create(Neutron.class).
child(Ports.class).child(Port.class, new PortKey(portId));
- Optional<Port> optPort = read(LogicalDatastoreType.CONFIGURATION, pid);
+ Optional<Port> optPort = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION, pid);
if (optPort.isPresent()) {
return optPort.get();
}
List<Uuid> subnets = new ArrayList<Uuid>();
//read subnetmaps
InstanceIdentifier<Subnetmaps> subnetmapsid = InstanceIdentifier.builder(Subnetmaps.class).build();
- Optional<Subnetmaps> subnetmaps = read(LogicalDatastoreType.CONFIGURATION, subnetmapsid);
+ Optional<Subnetmaps> subnetmaps = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION,
+ subnetmapsid);
if (subnetmaps.isPresent()) {
Subnetmaps smaps = subnetmaps.get();
List<Subnetmap> subnetMapList = smaps.getSubnetmap();
result.add("---------------------------------------------------------------------------------------");
InstanceIdentifier<Ports> portidentifier = InstanceIdentifier.create(Neutron.class).child(Ports.class);
try {
- Optional<Ports> ports = read(LogicalDatastoreType.CONFIGURATION, portidentifier);
+ Optional<Ports> ports = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION, portidentifier);
if (ports.isPresent()) {
List<Port> portList = ports.get().getPort();
for (Port port : portList) {
result.add(String.format(" %-22s %-22s %-22s %-6s ", NeutronvpnUtils.uuidToTapPortName(port
.getUuid()), port.getMacAddress(), port.getFixedIps().get(0).getIpAddress().getIpv4Address()
- .getValue(), getIPPrefixFromPort(port)));
+ .getValue(), NeutronvpnUtils.getIPPrefixFromPort(broker, port)));
}
}
} catch (Exception e) {
return result;
}
- private Short getIPPrefixFromPort(Port port) {
- Short prefix = new Short((short) 0);
- String cidr = "";
- try {
- Uuid subnetUUID = port.getFixedIps().get(0).getSubnetId();
-
- org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets
- .SubnetKey subnetkey = new org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets
- .rev150712.subnets.attributes.subnets.SubnetKey(subnetUUID);
- InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets
- .attributes.subnets.Subnet> subnetidentifier = InstanceIdentifier.create(Neutron.class).child(org
- .opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets
- .class).child(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets
- .attributes.subnets.Subnet.class, subnetkey);
- Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes
- .subnets.Subnet> subnet = read(LogicalDatastoreType.CONFIGURATION, subnetidentifier);
-
- if (subnet.isPresent()) {
- cidr = subnet.get().getCidr();
- // Extract the prefix length from cidr
- String[] parts = cidr.split("/");
- if ((parts.length == 2)) {
- prefix = Short.valueOf(parts[1]);
- return prefix;
- } else {
- logger.trace("Could not retrieve prefix from subnet CIDR");
- System.out.println("Could not retrieve prefix from subnet CIDR");
- }
- } else {
- logger.trace("Unable to read on subnet datastore");
- }
- } catch (Exception e) {
- logger.trace("Failed to retrieve IP prefix from port : ", e);
- System.out.println("Failed to retrieve IP prefix from port : " + e.getMessage());
- }
- return null;
- }
-
public List<String> showVpnConfigCLI(Uuid vpnuuid) {
List<String> result = new ArrayList<String>();
if (vpnuuid == null) {
/*
- * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
/*
- * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.VpnMaps;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.networkmaps.NetworkMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.networkmaps.NetworkMapKey;
-
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.neutron.port.data
.PortFixedipToPortName;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.neutron.port.data
}
protected static VpnMap getVpnMap(DataBroker broker, Uuid id) {
- InstanceIdentifier<VpnMap> vpnMapIdentifier = InstanceIdentifier.builder(VpnMaps.class)
- .child(VpnMap.class, new VpnMapKey(id)).build();
- Optional<VpnMap> optionalVpnMap = read(broker, LogicalDatastoreType.CONFIGURATION,
- vpnMapIdentifier);
+ InstanceIdentifier<VpnMap> vpnMapIdentifier = InstanceIdentifier.builder(VpnMaps.class).child(VpnMap.class,
+ new VpnMapKey(id)).build();
+ Optional<VpnMap> optionalVpnMap = read(broker, LogicalDatastoreType.CONFIGURATION, vpnMapIdentifier);
if (optionalVpnMap.isPresent()) {
return optionalVpnMap.get();
}
protected static Uuid getVpnForNetwork(DataBroker broker, Uuid network) {
InstanceIdentifier<VpnMaps> vpnMapsIdentifier = InstanceIdentifier.builder(VpnMaps.class).build();
- Optional<VpnMaps> optionalVpnMaps = read(broker, LogicalDatastoreType.CONFIGURATION,
- vpnMapsIdentifier);
+ Optional<VpnMaps> optionalVpnMaps = read(broker, LogicalDatastoreType.CONFIGURATION, vpnMapsIdentifier);
if (optionalVpnMaps.isPresent()) {
VpnMaps vpnMaps = optionalVpnMaps.get();
List<VpnMap> allMaps = vpnMaps.getVpnMap();
protected static Uuid getVpnForRouter(DataBroker broker, Uuid router) {
InstanceIdentifier<VpnMaps> vpnMapsIdentifier = InstanceIdentifier.builder(VpnMaps.class).build();
- Optional<VpnMaps> optionalVpnMaps = read(broker, LogicalDatastoreType.CONFIGURATION,
- vpnMapsIdentifier);
+ Optional<VpnMaps> optionalVpnMaps = read(broker, LogicalDatastoreType.CONFIGURATION, vpnMapsIdentifier);
if (optionalVpnMaps.isPresent()) {
VpnMaps vpnNets = optionalVpnMaps.get();
List<VpnMap> allMaps = vpnNets.getVpnMap();
protected static Uuid getRouterforVpn(DataBroker broker, Uuid vpnId) {
InstanceIdentifier<VpnMap> vpnMapIdentifier = InstanceIdentifier.builder(VpnMaps.class)
.child(VpnMap.class, new VpnMapKey(vpnId)).build();
- Optional<VpnMap> optionalVpnMap = read(broker, LogicalDatastoreType.CONFIGURATION,
- vpnMapIdentifier);
+ Optional<VpnMap> optionalVpnMap = read(broker, LogicalDatastoreType.CONFIGURATION, vpnMapIdentifier);
if (optionalVpnMap.isPresent()) {
VpnMap vpnMap = optionalVpnMap.get();
return vpnMap.getRouterId();
protected static List<Uuid> getSubnetIdsFromNetworkId(DataBroker broker, Uuid networkId) {
InstanceIdentifier id = buildNetworkMapIdentifier(networkId);
- Optional<NetworkMap> optionalNetworkMap = read(broker, LogicalDatastoreType.CONFIGURATION,
- id);
+ Optional<NetworkMap> optionalNetworkMap = read(broker, LogicalDatastoreType.CONFIGURATION, id);
if (optionalNetworkMap.isPresent()) {
return optionalNetworkMap.get().getSubnetIdList();
}
protected static Router getNeutronRouter(DataBroker broker, Uuid routerId) {
- InstanceIdentifier<Router> inst = InstanceIdentifier.create(Neutron.class).
- child(Routers.class).child(Router.class, new RouterKey(routerId));
-
+ InstanceIdentifier<Router> inst = InstanceIdentifier.create(Neutron.class).child(Routers.class).child(Router
+ .class, new RouterKey(routerId));
Optional<Router> rtr = read(broker, LogicalDatastoreType.CONFIGURATION, inst);
if (rtr.isPresent()) {
return rtr.get();
protected static Network getNeutronNetwork(DataBroker broker, Uuid networkId) {
logger.debug("getNeutronNetwork for {}", networkId.getValue());
- InstanceIdentifier<Network> inst = InstanceIdentifier.create(Neutron.class).
- child(Networks.class).child(Network.class, new NetworkKey(networkId));
-
+ InstanceIdentifier<Network> inst = InstanceIdentifier.create(Neutron.class).child(Networks.class).child
+ (Network.class, new NetworkKey(networkId));
Optional<Network> net = read(broker, LogicalDatastoreType.CONFIGURATION, inst);
if (net.isPresent()) {
return net.get();
}
}
+ protected static Short getIPPrefixFromPort(DataBroker broker, Port port) {
+ Short prefix = new Short((short) 0);
+ String cidr = "";
+ try {
+ Uuid subnetUUID = port.getFixedIps().get(0).getSubnetId();
+
+ org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets
+ .SubnetKey subnetkey = new org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets
+ .rev150712.subnets.attributes.subnets.SubnetKey(subnetUUID);
+ InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets
+ .attributes.subnets.Subnet> subnetidentifier = InstanceIdentifier.create(Neutron.class).child(org
+ .opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets
+ .class).child(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets
+ .attributes.subnets.Subnet.class, subnetkey);
+ Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes
+ .subnets.Subnet> subnet = read(broker, LogicalDatastoreType.CONFIGURATION, subnetidentifier);
+
+ if (subnet.isPresent()) {
+ cidr = subnet.get().getCidr();
+ // Extract the prefix length from cidr
+ String[] parts = cidr.split("/");
+ if ((parts.length == 2)) {
+ prefix = Short.valueOf(parts[1]);
+ return prefix;
+ } else {
+ logger.trace("Could not retrieve prefix from subnet CIDR");
+ System.out.println("Could not retrieve prefix from subnet CIDR");
+ }
+ } else {
+ logger.trace("Unable to read on subnet datastore");
+ }
+ } catch (Exception e) {
+ logger.trace("Failed to retrieve IP prefix from port : ", e);
+ System.out.println("Failed to retrieve IP prefix from port : " + e.getMessage());
+ }
+ return null;
+ }
+
static InstanceIdentifier<PortNameToPortUuid> buildPortNameToPortUuidIdentifier(String portname) {
InstanceIdentifier<PortNameToPortUuid> id = InstanceIdentifier.builder(NeutronPortData.class).child
(PortNameToPortUuid.class, new PortNameToPortUuidKey(portname)).build();
/*
- * Copyright (c) 2015-2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
*
* Generated from: yang module name: neutronvpn-impl yang module local name: neutronvpn-impl
* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Thu Jan 06 10:51:12 IST 2015
+* Generated at: Thu Jan 06 10:51:12 IST 2016
*
* Do not modify this file unless it is present under src/main directory
*/
<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: --><!--
-Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+<!--
+Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v1.0 which accompanies this distribution,
/*
- * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
/*
- * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
/*
- * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
-<!-- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<?xml version="1.0" encoding="UTF-8"?>
<!--
-Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v1.0 which accompanies this distribution,
-and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
+and is available at http://www.eclipse.org/legal/epl-v10.html
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
public static final String VPN_IDPOOL_NAME = "vpnservices";
public static final long VPN_IDPOOL_START = 100L;
public static final String VPN_IDPOOL_SIZE = "100000";
- public static final short LPORT_INGRESS_TABLE = 0;
- public static final short LFIB_TABLE = 20;
- public static final short FIB_TABLE = 21;
- public static final short L3_INTERFACE_TABLE = 80;
public static final short DEFAULT_FLOW_PRIORITY = 10;
public static final short L3VPN_SERVICE_IDENTIFIER = 2;
public static final long INVALID_ID = -1;
List<Instruction> instructions = new ArrayList<Instruction>();
instructions.add(MDSALUtil.buildAndGetWriteMetadaInstruction(BigInteger.valueOf(vpnId), MetaDataUtil.METADATA_MASK_VRFID, ++instructionKey));
- instructions.add(MDSALUtil.buildAndGetGotoTableInstruction(VpnConstants.FIB_TABLE, ++instructionKey));
+ instructions.add(MDSALUtil.buildAndGetGotoTableInstruction(NwConstants.L3_FIB_TABLE, ++instructionKey));
BoundServices
serviceInfo =
// Install the flow entry in L3_INTERFACE_TABLE
BigInteger dpId = InterfaceUtils.getDpnForInterface(interfaceManager, vpnInterfaceName);
- String flowRef = VpnUtil.getFlowRef(dpId, VpnConstants.L3_INTERFACE_TABLE,
+ String flowRef = VpnUtil.getFlowRef(dpId, NwConstants.L3_INTERFACE_TABLE,
NwConstants.ETHTYPE_ARP, lPortTag, replyOrRequest.getArpOperation());
FlowEntity flowEntity;
- flowEntity = MDSALUtil.buildFlowEntity(dpId, VpnConstants.L3_INTERFACE_TABLE, flowRef,
+ flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.L3_INTERFACE_TABLE, flowRef,
NwConstants.DEFAULT_ARP_FLOW_PRIORITY, replyOrRequest.getName(), 0, 0,
VpnUtil.getCookieArpFlow(lPortTag), matches, instructions);