Commit 9941bda5 authored by Michele Santuari's avatar Michele Santuari
Browse files

Point Intent installation

parent 38a7af64
......@@ -15,10 +15,26 @@
*/
package org.geant;
import java.net.URI;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onlab.packet.MacAddress;
import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.ElementId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.flow.DefaultTrafficSelector;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.intent.PointToPointIntent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -30,9 +46,49 @@ public class AppComponent {
private final Logger log = LoggerFactory.getLogger(getClass());
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected IntentService intentService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CoreService coreService;
private ApplicationId appId;
@Activate
protected void activate() {
log.info("Started");
appId = coreService.registerApplication("org.onosproject.tutorial");
TrafficSelector selecAlice = DefaultTrafficSelector.builder()
.matchEthSrc(MacAddress.valueOf(1)).build();
TrafficSelector selecBob = DefaultTrafficSelector.builder()
.matchEthSrc(MacAddress.valueOf(2)).build();
PointToPointIntent ptpIntentFromAlice = PointToPointIntent
.builder()
.appId(appId)
.ingressPoint(new ConnectPoint(DeviceId
.deviceId("of:000000000000000B"), PortNumber
.portNumber(1)))
.egressPoint(new ConnectPoint(DeviceId
.deviceId("of:0000000000000016"), PortNumber
.portNumber(1))).selector(selecAlice)
.build();
PointToPointIntent ptpIntentFromBob = PointToPointIntent
.builder()
.appId(appId)
.ingressPoint(new ConnectPoint(DeviceId
.deviceId("of:0000000000000016"), PortNumber
.portNumber(1)))
.egressPoint(new ConnectPoint(DeviceId
.deviceId("of:000000000000000B"), PortNumber
.portNumber(1))).selector(selecBob)
.build();
intentService.submit(ptpIntentFromAlice);
intentService.submit(ptpIntentFromBob);
}
@Deactivate
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment