Skip to content

Commit 72d333b

Browse files
Andrea-Campanellatomikazi
authored andcommitted
Adding EVC rest enpoint for CarrierEthernet app
Change-Id: Ie6a1c0e5ab1fe1cd17d0fefb892f51cf540ead3e
1 parent 7251cae commit 72d333b

File tree

10 files changed

+598
-148
lines changed

10 files changed

+598
-148
lines changed

carrierethernet/pom.xml

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,37 @@
1313
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
~ See the License for the specific language governing permissions and
1515
~ limitations under the License.
16-
-->
17-
<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">
16+
--><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">
1817
<modelVersion>4.0.0</modelVersion>
1918

2019
<parent>
2120
<groupId>org.onosproject</groupId>
2221
<artifactId>onos-dependencies</artifactId>
23-
<version>1.8.0</version>
22+
<version>1.9.0</version>
2423
<relativePath/><!-- parent is remote -->
2524
</parent>
2625

2726
<groupId>org.onosproject</groupId>
2827
<artifactId>onos-app-carrierethernet</artifactId>
29-
<version>1.8.0-SNAPSHOT</version>
28+
<version>04.2017</version>
3029
<packaging>bundle</packaging>
3130

3231
<description>Application for installing MEF services in ONOS</description>
3332
<url>http://onosproject.org</url>
3433

3534
<properties>
3635
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
37-
<onos.version>1.8.0</onos.version>
36+
<onos.version>1.9.0</onos.version>
37+
<api.version>1.0.0</api.version>
3838
<onos.app.name>org.onosproject.ecord.carrierethernet</onos.app.name>
3939
<onos.app.origin>ON.Lab</onos.app.origin>
4040
<onos.app.requires>org.onosproject.newoptical</onos.app.requires>
41+
<api.description>Carrier Ethernet REST APIs</api.description>
4142
<onos.app.category>Traffic Steering</onos.app.category>
43+
<web.context>/onos</web.context>
44+
<api.title>Carrier Ethernet REST APIs</api.title>
4245
<onos.app.title>Carrier Ethernet</onos.app.title>
46+
<api.package>org.onosproject.ecord.carrierethernet.rest</api.package>
4347
<onos.app.url>https://wiki.onosproject.org/display/ONOS/Carrier+Ethernet+Application</onos.app.url>
4448
</properties>
4549

@@ -64,7 +68,7 @@
6468
<dependency>
6569
<groupId>org.onosproject</groupId>
6670
<artifactId>onos-apps-newoptical</artifactId>
67-
<version>${onos.version}</version>
71+
<version>1.10.0-SNAPSHOT</version>
6872
</dependency>
6973

7074
<dependency>
@@ -109,6 +113,48 @@
109113
<version>5.0.0</version>
110114
<scope>provided</scope>
111115
</dependency>
116+
<dependency>
117+
<groupId>javax.ws.rs</groupId>
118+
<artifactId>javax.ws.rs-api</artifactId>
119+
<version>2.0.1</version>
120+
<scope>provided</scope>
121+
</dependency>
122+
<dependency>
123+
<groupId>com.fasterxml.jackson.core</groupId>
124+
<artifactId>jackson-databind</artifactId>
125+
<version>2.8.6</version>
126+
<scope>provided</scope>
127+
</dependency>
128+
<dependency>
129+
<groupId>org.onosproject</groupId>
130+
<artifactId>onos-rest</artifactId>
131+
<version>${onos.version}</version>
132+
<scope>provided</scope>
133+
</dependency>
134+
<dependency>
135+
<groupId>com.fasterxml.jackson.core</groupId>
136+
<artifactId>jackson-annotations</artifactId>
137+
<version>2.8.6</version>
138+
<scope>provided</scope>
139+
</dependency>
140+
<dependency>
141+
<groupId>org.glassfish.jersey.containers</groupId>
142+
<artifactId>jersey-container-servlet</artifactId>
143+
<version>2.25</version>
144+
<scope>provided</scope>
145+
</dependency>
146+
<dependency>
147+
<groupId>org.osgi</groupId>
148+
<artifactId>org.osgi.core</artifactId>
149+
<version>5.0.0</version>
150+
<scope>provided</scope>
151+
</dependency>
152+
<dependency>
153+
<groupId>org.onosproject</groupId>
154+
<artifactId>onlab-rest</artifactId>
155+
<version>${onos.version}</version>
156+
<scope>provided</scope>
157+
</dependency>
112158
</dependencies>
113159

114160
<build>
@@ -128,6 +174,16 @@
128174
<artifactId>maven-bundle-plugin</artifactId>
129175
<version>2.5.3</version>
130176
<extensions>true</extensions>
177+
<configuration>
178+
<instructions>
179+
<_wab>src/main/webapp/</_wab>
180+
<Include-Resource>WEB-INF/classes/apidoc/swagger.json=target/swagger.json,
181+
{maven-resources}</Include-Resource>
182+
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
183+
<Import-Package>*,org.glassfish.jersey.servlet</Import-Package>
184+
<Web-ContextPath>${web.context}</Web-ContextPath>
185+
</instructions>
186+
</configuration>
131187
</plugin>
132188
<plugin>
133189
<groupId>org.apache.maven.plugins</groupId>
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
package org.onosproject.ecord.carrierethernet.app;
2+
3+
import org.onlab.packet.VlanId;
4+
import org.onlab.util.Bandwidth;
5+
import org.onosproject.net.ConnectPoint;
6+
7+
import java.util.HashSet;
8+
import java.util.List;
9+
import java.util.Set;
10+
11+
import static org.onosproject.ecord.carrierethernet.app.CarrierEthernetVirtualConnection.MAX_NUM_UNI;
12+
13+
/**
14+
* Utilities to build EthernetVirtualConnections.
15+
*/
16+
public final class CarrierEthernetEvcUtils {
17+
18+
// no instantiation
19+
private CarrierEthernetEvcUtils() {
20+
}
21+
22+
/**
23+
* Return the CE-VLAN ID for the CE evc based on the CLI-supplied argument.
24+
*
25+
* @param argCeVlanId vlanID
26+
* @return CE-VLAN ID for the CE evc
27+
*/
28+
public static VlanId generateCeVlanId(short argCeVlanId) {
29+
return ((argCeVlanId == -1) ? null : VlanId.vlanId(argCeVlanId));
30+
}
31+
32+
/**
33+
* Return the CE evc type based on the CLI-supplied arguments.
34+
*
35+
* @param evcTypeString EVC type
36+
* @param uniList UNIs list
37+
* @return the CE evc type
38+
*/
39+
public static CarrierEthernetConnection.Type generateEvcType(String evcTypeString, List<String> uniList) {
40+
if (evcTypeString == null) {
41+
return ((uniList.size() > 2) ?
42+
CarrierEthernetConnection.Type.MULTIPOINT_TO_MULTIPOINT :
43+
CarrierEthernetConnection.Type.POINT_TO_POINT);
44+
} else {
45+
// TODO: Catch exception
46+
return CarrierEthernetConnection.Type.valueOf(evcTypeString);
47+
}
48+
}
49+
50+
/**
51+
* Return the EVC maxNumUni parameter based on the CLI-supplied arguments.
52+
*
53+
* @param maxNumUni maximum numbers of UNIs
54+
* @param evcTypeString EVC Type
55+
* @param uniList UNIs list
56+
* @return the maxNumUni parameter
57+
*/
58+
public static Integer generateMaxNumUni(int maxNumUni, String evcTypeString, List<String> uniList) {
59+
if (maxNumUni == -1) {
60+
if (evcTypeString == null) {
61+
return ((uniList.size() > 2) ?
62+
MAX_NUM_UNI : 2);
63+
} else {
64+
// TODO: Catch exception
65+
CarrierEthernetConnection.Type evcType =
66+
CarrierEthernetConnection.Type.valueOf(evcTypeString);
67+
return (evcType.equals(CarrierEthernetConnection.Type.POINT_TO_POINT) ? 2 :
68+
MAX_NUM_UNI);
69+
}
70+
} else {
71+
return maxNumUni;
72+
}
73+
}
74+
75+
/**
76+
* Return the BW profile type based on the CLI-supplied arguments.
77+
*
78+
* @param ceVlanId vlanID
79+
* @return the BWP profile type
80+
*/
81+
public static CarrierEthernetBandwidthProfile.Type generateBandwidthProfileType(short ceVlanId) {
82+
// TODO: Add the CoS BW profile case
83+
return ((ceVlanId == -1) ?
84+
CarrierEthernetBandwidthProfile.Type.INTERFACE : CarrierEthernetBandwidthProfile.Type.EVC);
85+
}
86+
87+
/**
88+
* Return the BW profile id based on the CLI-supplied arguments.
89+
*
90+
* @param uniId UNI id
91+
* @param evcCfgId EVC configuration Id
92+
* @param ceVlanId vlanID
93+
* @return the BW profile id
94+
*/
95+
public static String generateBandwidthProfileId(String uniId, String evcCfgId, int ceVlanId) {
96+
// TODO: Add the CoS BW profile case
97+
return ((ceVlanId == -1) ? uniId : evcCfgId);
98+
}
99+
100+
/**
101+
* Return the set of UNIs for the CE EVC based on the CLI-supplied arguments.
102+
*
103+
* @param evcTypeString Type of the UNI
104+
* @param uniList list of remaning UNIs
105+
* @param ceVlanId vlanID
106+
* @param firstUni first UNI id
107+
* @param evcCfgId EVC configuration Id
108+
* @param cir The CIR in Mbps
109+
* @param eir The EIR in Mbps
110+
* @param cbs The CBS in Byte
111+
* @param ebs The EBS in Byte
112+
* @return the set of UNIs for the CE EVC
113+
*/
114+
public static Set<CarrierEthernetUni> generateUniSet(String evcTypeString, List<String> uniList,
115+
short ceVlanId, String firstUni, String evcCfgId,
116+
Double cir, Double eir, Long cbs, Long ebs) {
117+
118+
Set<CarrierEthernetUni> uniSet = new HashSet<>();
119+
120+
CarrierEthernetConnection.Type evcType = generateEvcType(evcTypeString, uniList);
121+
122+
// We assume that first UNI supplied is always root
123+
uniSet.add(CarrierEthernetUni.builder()
124+
.cp(ConnectPoint.deviceConnectPoint(firstUni))
125+
.role(CarrierEthernetUni.Role.ROOT)
126+
.ceVlanId(generateCeVlanId(ceVlanId))
127+
.bwp(CarrierEthernetBandwidthProfile.builder()
128+
.id(generateBandwidthProfileId(firstUni, evcCfgId, ceVlanId))
129+
.type(generateBandwidthProfileType(ceVlanId))
130+
.cir(Bandwidth.mbps(cir))
131+
.eir(Bandwidth.mbps(eir))
132+
.cbs(cbs)
133+
.ebs(ebs)
134+
.build())
135+
.build());
136+
137+
final CarrierEthernetUni.Role role;
138+
// For E-Line and E-LAN all UNIs are roots. For E-Tree all UNIs are leafs except from one
139+
role = ((evcType == CarrierEthernetConnection.Type.ROOT_MULTIPOINT) ?
140+
CarrierEthernetUni.Role.LEAF : CarrierEthernetUni.Role.ROOT);
141+
142+
uniList.forEach(argUni -> uniSet.add(
143+
CarrierEthernetUni.builder()
144+
.cp(ConnectPoint.deviceConnectPoint(argUni))
145+
.role(role)
146+
.ceVlanId(generateCeVlanId(ceVlanId))
147+
.bwp(CarrierEthernetBandwidthProfile.builder()
148+
.id(generateBandwidthProfileId(argUni, evcCfgId, ceVlanId))
149+
.type(generateBandwidthProfileType(ceVlanId))
150+
.cir(Bandwidth.mbps(cir))
151+
.eir(Bandwidth.mbps(eir))
152+
.cbs(cbs)
153+
.ebs(ebs)
154+
.build())
155+
.build()));
156+
157+
return uniSet;
158+
}
159+
}

0 commit comments

Comments
 (0)