alshabib
Committed by Gerrit Code Review

adding iptv provisioning

Change-Id: I11fcc788402793d0bf3ac9d9f03ed77e093d98ad
......@@ -168,6 +168,8 @@ public class CordFabricManager implements FabricService {
.withTreatment(down)
.add();
flowObjectiveService.forward(fabricDeviceId, upCtrl);
flowObjectiveService.forward(fabricDeviceId, downCtrl);
flowObjectiveService.forward(fabricDeviceId, radiusToController);
......@@ -181,6 +183,10 @@ public class CordFabricManager implements FabricService {
removeVlan(vlan.vlan());
if (vlan.iptv()) {
provisionIPTV();
}
vlan.ports().forEach(cp -> {
if (vlans.put(vlan.vlan(), cp)) {
addForwarding(vlan.vlan(), cp.deviceId(), cp.port(),
......@@ -192,6 +198,46 @@ public class CordFabricManager implements FabricService {
});
}
//FIXME: pass iptv vlan in here.
private void provisionIPTV() {
TrafficSelector ipTvUp = DefaultTrafficSelector.builder()
.matchVlanId(VlanId.vlanId((short) 7))
.matchInPort(PortNumber.portNumber(2))
.build();
TrafficTreatment ipTvActUp = DefaultTrafficTreatment.builder()
.setOutput(PortNumber.portNumber(7)).build();
TrafficSelector ipTvDown = DefaultTrafficSelector.builder()
.matchVlanId(VlanId.vlanId((short) 7))
.matchInPort(PortNumber.portNumber(7))
.build();
TrafficTreatment ipTvActDown = DefaultTrafficTreatment.builder()
.setOutput(PortNumber.portNumber(2)).build();
ForwardingObjective ipTvUpstream = DefaultForwardingObjective.builder()
.fromApp(appId)
.makePermanent()
.withFlag(ForwardingObjective.Flag.VERSATILE)
.withPriority(PRIORITY)
.withSelector(ipTvUp)
.withTreatment(ipTvActUp)
.add();
ForwardingObjective ipTvDownstream = DefaultForwardingObjective.builder()
.fromApp(appId)
.makePermanent()
.withFlag(ForwardingObjective.Flag.VERSATILE)
.withPriority(PRIORITY)
.withSelector(ipTvDown)
.withTreatment(ipTvActDown)
.add();
flowObjectiveService.forward(fabricDeviceId, ipTvUpstream);
flowObjectiveService.forward(fabricDeviceId, ipTvDownstream);
}
@Override
public void removeVlan(VlanId vlanId) {
vlans.removeAll(vlanId)
......@@ -202,7 +248,9 @@ public class CordFabricManager implements FabricService {
public List<FabricVlan> getVlans() {
List<FabricVlan> fVlans = new ArrayList<>();
vlans.keySet().forEach(vlan -> fVlans.add(
new FabricVlan(vlan, vlans.get(vlan))));
//FIXME: Very aweful but will fo for now
new FabricVlan(vlan, vlans.get(vlan),
vlan.toShort() == 201 ? true : false)));
return fVlans;
}
......@@ -217,6 +265,7 @@ public class CordFabricManager implements FabricService {
private void addForwarding(VlanId vlanId, DeviceId deviceId, PortNumber inPort,
List<PortNumber> outPorts) {
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchVlanId(vlanId)
.matchInPort(inPort)
......
......@@ -33,12 +33,14 @@ public class FabricVlan {
private final VlanId vlan;
private final List<ConnectPoint> ports;
private final boolean iptv;
public FabricVlan(VlanId vlan, Collection<ConnectPoint> ports) {
public FabricVlan(VlanId vlan, Collection<ConnectPoint> ports, boolean iptv) {
checkNotNull(vlan);
checkNotNull(ports);
this.vlan = vlan;
this.ports = ImmutableList.copyOf(ports);
this.iptv = iptv;
}
public VlanId vlan() {
......@@ -48,4 +50,8 @@ public class FabricVlan {
public List<ConnectPoint> ports() {
return ports;
}
public boolean iptv() {
return iptv;
}
}
......
......@@ -37,6 +37,7 @@ public final class FabricVlanCodec extends JsonCodec<FabricVlan> {
// JSON field names
private static final String VLAN = "vlan";
private static final String PORTS = "ports";
private static final String IPTV = "iptv";
@Override
public ObjectNode encode(FabricVlan vlan, CodecContext context) {
......@@ -54,6 +55,7 @@ public final class FabricVlanCodec extends JsonCodec<FabricVlan> {
@Override
public FabricVlan decode(ObjectNode json, CodecContext context) {
short vlan = json.path(VLAN).shortValue();
boolean iptv = json.path(IPTV).booleanValue();
List<ConnectPoint> ports = new ArrayList<>();
ArrayNode portArray = (ArrayNode) json.path(PORTS);
......@@ -61,6 +63,6 @@ public final class FabricVlanCodec extends JsonCodec<FabricVlan> {
ports.add(context.codec(ConnectPoint.class).decode((ObjectNode) o, context));
}
return new FabricVlan(VlanId.vlanId(vlan), ports);
return new FabricVlan(VlanId.vlanId(vlan), ports, iptv);
}
}
......
......@@ -59,6 +59,6 @@ public class FabricAddCommand extends AbstractShellCommand {
ports.add(ConnectPoint.deviceConnectPoint(portString));
}
service.addVlan(new FabricVlan(vlan, ports));
service.addVlan(new FabricVlan(vlan, ports, false));
}
}
......
......@@ -415,8 +415,16 @@ public class OnosXOSIntegrationManager implements VoltTenantService {
// + FABRIC_VCPE_CONNECT_POINT.toString() + "\"}";
//json += "]}";
long vlan = portToVlan.get(fromPoint.port().toLong());
JsonObject node = new JsonObject();
node.add("vlan", portToVlan.get(fromPoint.port().toLong()));
node.add("vlan", vlan);
if (vlan == 201) {
node.add("iptv", true);
} else {
node.add("iptv", false);
}
JsonArray array = new JsonArray();
JsonObject cp1 = new JsonObject();
JsonObject cp2 = new JsonObject();
......
......@@ -16,15 +16,12 @@
package org.onosproject.driver.pipeline;
import org.onlab.osgi.ServiceDirectory;
import org.onlab.packet.Ethernet;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.behaviour.Pipeliner;
import org.onosproject.net.behaviour.PipelinerContext;
import org.onosproject.net.driver.AbstractHandlerBehaviour;
import org.onosproject.net.flow.DefaultFlowRule;
import org.onosproject.net.flow.DefaultTrafficSelector;
import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.FlowRule;
import org.onosproject.net.flow.FlowRuleOperations;
......@@ -52,7 +49,6 @@ public class OLTPipeline extends AbstractHandlerBehaviour implements Pipeliner {
private FlowRuleService flowRuleService;
private DeviceId deviceId;
private boolean done = false;
@Override
public void init(DeviceId deviceId, PipelinerContext context) {
......@@ -63,34 +59,7 @@ public class OLTPipeline extends AbstractHandlerBehaviour implements Pipeliner {
}
private boolean installIGMPRule(ApplicationId appId, boolean done) {
if (done) {
return done;
}
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchInPort(PortNumber.portNumber(1))
.matchEthType(Ethernet.TYPE_IPV4)
.matchIPProtocol((byte) 2).build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
.punt().build();
FlowRule rule = DefaultFlowRule.builder()
.forDevice(deviceId)
.fromApp(appId)
.withTreatment(treatment)
.withSelector(selector)
.makePermanent()
.withPriority(0)
.build();
FlowRuleOperations.Builder flowBuilder = FlowRuleOperations.builder();
flowRuleService.apply(flowBuilder.add(rule).build());
return true;
}
@Override
public void filter(FilteringObjective filter) {
......@@ -99,7 +68,6 @@ public class OLTPipeline extends AbstractHandlerBehaviour implements Pipeliner {
@Override
public void forward(ForwardingObjective fwd) {
done = installIGMPRule(fwd.appId(), done);
FlowRuleOperations.Builder flowBuilder = FlowRuleOperations.builder();
if (fwd.flag() != ForwardingObjective.Flag.VERSATILE) {
......