[ONOS-6551] Tunnel implementation for L3VPN service.
Change-Id: I3171a83305cb7391d80fda94ddf567629a10675e
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/DeviceInfo.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/DeviceInfo.java
index 20cf1c5..9a2c49a 100644
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/DeviceInfo.java
+++ b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/DeviceInfo.java
@@ -17,7 +17,6 @@
package org.onosproject.l3vpn.netl3vpn;
import org.onosproject.net.DeviceId;
-import org.onosproject.net.behaviour.L3VpnConfig;
import org.onosproject.net.driver.DriverHandler;
import org.onosproject.net.driver.DriverService;
import org.onosproject.yang.model.ModelObjectData;
@@ -37,6 +36,11 @@
private final DeviceId deviceId;
/**
+ * Type of the VPN.
+ */
+ private final VpnType type;
+
+ /**
* BGP information of the device.
*/
private BgpInfo bgpInfo;
@@ -52,12 +56,24 @@
private List<AccessInfo> accesses;
/**
- * Constructs device info with a device id.
+ * List of tunnel names belonging to the device.
+ */
+ private List<String> tnlNames;
+
+ /**
+ * Status of tunnel policy being created for this device in this VPN.
+ */
+ private boolean isTnlPolCreated;
+
+ /**
+ * Constructs device info with a device id and VPN type.
*
* @param d device id
+ * @param t VPN type
*/
- public DeviceInfo(DeviceId d) {
+ public DeviceInfo(DeviceId d, VpnType t) {
deviceId = d;
+ type = t;
}
/**
@@ -70,6 +86,15 @@
}
/**
+ * Returns the type of the VPN instance.
+ *
+ * @return VPN type
+ */
+ public VpnType type() {
+ return type;
+ }
+
+ /**
* Adds a interface name to the list.
*
* @param ifName interface name
@@ -99,6 +124,56 @@
this.ifNames = ifNames;
}
+ /***
+ * Returns the list of tunnel names.
+ *
+ * @return tunnel names
+ */
+ public List<String> tnlNames() {
+ return tnlNames;
+ }
+
+ /**
+ * Sets the list of tunnel names.
+ *
+ * @param tnlNames tunnel names
+ */
+ public void tnlNames(List<String> tnlNames) {
+ this.tnlNames = tnlNames;
+ }
+
+ /**
+ * Adds a tunnel name to the list.
+ *
+ * @param tnlName tunnel name
+ */
+ public void addTnlName(String tnlName) {
+ if (tnlNames == null) {
+ tnlNames = new LinkedList<>();
+ }
+ tnlNames.add(tnlName);
+ }
+
+ /**
+ * Returns true if tunnel policy is created for this device in this VPN;
+ * false otherwise.
+ *
+ * @return true if tunnel policy is created; false otherwise
+ */
+ public boolean isTnlPolCreated() {
+ return isTnlPolCreated;
+ }
+
+ /**
+ * Sets true if tunnel policy is created for this device in this VPN;
+ * false otherwise.
+ *
+ * @param tnlPolCreated status of tunnel policy creation
+ */
+ public void setTnlPolCreated(boolean tnlPolCreated) {
+ isTnlPolCreated = tnlPolCreated;
+ }
+
/**
* Returns the BGP information.
*
@@ -159,7 +234,7 @@
public ModelObjectData processCreateInstance(DriverService driverSvc,
ModelObjectData modelData) {
L3VpnConfig config = getL3VpnConfig(driverSvc);
- return (ModelObjectData) config.createInstance(modelData);
+ return config.createInstance(modelData);
}
/**
@@ -174,7 +249,7 @@
public ModelObjectData processCreateInterface(DriverService driverSvc,
ModelObjectData modData) {
L3VpnConfig config = getL3VpnConfig(driverSvc);
- return (ModelObjectData) config.bindInterface(modData);
+ return config.bindInterface(modData);
}
/**
@@ -191,7 +266,67 @@
BgpInfo bgpInfo,
BgpDriverInfo driverInfo) {
L3VpnConfig config = getL3VpnConfig(driverSvc);
- return (ModelObjectData) config.createBgpInfo(bgpInfo, driverInfo);
+ return config.createBgpInfo(bgpInfo, driverInfo);
+ }
+
+ /**
+ * Processes the creation of tunnel tree from the devices and device
+ * level. It returns the tunnel info with devices and device of driver
+ * constructed model object data.
+ *
+ * @param driverSvc driver service
+ * @param tnlInfo tunnel info
+ * @return driver model object data of tunnel info with devices and device
+ */
+ public ModelObjectData processCreateTnlDev(DriverService driverSvc,
+ TunnelInfo tnlInfo) {
+ L3VpnConfig config = getL3VpnConfig(driverSvc);
+ return config.createTnlDev(tnlInfo);
+ }
+
+ /**
+ * Processes the creation of tunnel policy in the tree from the tunnel
+ * manager or tunnel policy level. It returns the tunnel info with
+ * tunnel policy level of driver constructed model object data.
+ *
+ * @param driverSvc driver service
+ * @param tnlInfo tunnel info
+ * @return driver model object data of tunnel info with tunnel policy
+ */
+ public ModelObjectData processCreateTnlPol(DriverService driverSvc,
+ TunnelInfo tnlInfo) {
+ L3VpnConfig config = getL3VpnConfig(driverSvc);
+ return config.createTnlPol(tnlInfo);
+ }
+
+ /**
+ * Processes the creation of tunnel in the tree from the tunnel next hops
+ * or only tunnel next hop. It returns the tunnel info with tunnel level
+ * of driver constructed model object data
+ *
+ * @param driverSvc driver service
+ * @param tnlInfo tunnel info
+ * @return driver model object data of tunnel info with tunnel
+ */
+ public ModelObjectData processCreateTnl(DriverService driverSvc,
+ TunnelInfo tnlInfo) {
+ L3VpnConfig config = getL3VpnConfig(driverSvc);
+ return config.createTnl(tnlInfo);
+ }
+
+ /**
+ * Processes the binding of tunnel policy to the VPN instance. It returns
+ * the VPN instance with tunnel policy of driver constructed model object
+ * data.
+ *
+ * @param driverSvc driver service
+ * @param tnlInfo tunnel info
+ * @return driver model object data of VPN instance with tunnel
+ */
+ public ModelObjectData processBindTnl(DriverService driverSvc,
+ TunnelInfo tnlInfo) {
+ L3VpnConfig config = getL3VpnConfig(driverSvc);
+ return config.bindTnl(tnlInfo);
}
/**
@@ -206,7 +341,7 @@
public ModelObjectData processDeleteInstance(DriverService driverSvc,
ModelObjectData modData) {
L3VpnConfig config = getL3VpnConfig(driverSvc);
- return (ModelObjectData) config.deleteInstance(modData);
+ return config.deleteInstance(modData);
}
/**
@@ -238,7 +373,22 @@
BgpInfo bgpInfo,
BgpDriverInfo driverInfo) {
L3VpnConfig config = getL3VpnConfig(driverSvc);
- return (ModelObjectData) config.deleteBgpInfo(bgpInfo, driverInfo);
+ return config.deleteBgpInfo(bgpInfo, driverInfo);
+ }
+
+ /**
+ * Processes the deletion of tunnel info according to the levels it has
+ * to be deleted. It returns the tunnel info of driver constructed model
+ * object data.
+ *
+ * @param driverSvc driver service
+ * @param tnlInfo tunnel info
+ * @return driver tunnel info model object data
+ */
+ public ModelObjectData processDeleteTnl(DriverService driverSvc,
+ TunnelInfo tnlInfo) {
+ L3VpnConfig config = getL3VpnConfig(driverSvc);
+ return config.deleteTnl(tnlInfo);
}
/**