Phaneendra Manda
Committed by Gerrit Code Review

[ONOS-3835] Install load balanced classifier rules

Change-Id: I585a83021dbf2aff6a65dd43944a1f6979b33ead
Showing 16 changed files with 324 additions and 29 deletions
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.sfc.installer;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.NshServicePathId;
import org.onosproject.net.flowobjective.Objective.Operation;
import org.onosproject.vtnrsc.FlowClassifier;
import org.onosproject.vtnrsc.FiveTuple;
import org.onosproject.vtnrsc.PortChain;
import org.onosproject.vtnrsc.PortPair;
/**
* Abstraction of an entity which installs flow classification rules in ovs.
......@@ -12,29 +26,38 @@ import org.onosproject.vtnrsc.PortPair;
public interface FlowClassifierInstallerService {
/**
* Install Flow-Classifier.
* Install flow classifier.
*
* @param portChain port-chain
* @param nshSpiId nsh spi-id
* @param nshSpiId service path index identifier
*/
void installFlowClassifier(PortChain portChain, NshServicePathId nshSpiId);
ConnectPoint installFlowClassifier(PortChain portChain, NshServicePathId nshSpiId);
/**
* Uninstall Flow-Classifier.
* Uninstall flow classifier.
*
* @param portChain port-chain
* @param nshSpiId nsh spi-id
* @param nshSpiId service path index identifier
*/
void unInstallFlowClassifier(PortChain portChain, NshServicePathId nshSpiId);
ConnectPoint unInstallFlowClassifier(PortChain portChain, NshServicePathId nshSpiId);
/**
* Prepare forwarding object for flow classifier.
* Install load balanced flow classifier.
*
* @param flowClassifier flow classifier
* @param portPair port pair
* @param nshSpiId nsh spi id
* @param type forwarding objective operation type
* @param portChain port-chain
* @param fiveTuple five tuple packet information
* @param nshSpiId service path index identifier
*/
ConnectPoint installLoadBalancedFlowClassifier(PortChain portChain, FiveTuple fiveTuple,
NshServicePathId nshSpiId);
/**
* Uninstall load balanced flow classifier.
*
* @param portChain port-chain
* @param fiveTuple five tuple packet information
* @param nshSpiId service path index identifier
*/
void prepareFlowClassification(FlowClassifier flowClassifier, PortPair portPair, NshServicePathId nshSpiId,
Operation type);
ConnectPoint unInstallLoadBalancedFlowClassifier(PortChain portChain, FiveTuple fiveTuple,
NshServicePathId nshSpiId);
}
......
......@@ -28,7 +28,7 @@ import com.google.common.collect.ImmutableList;
/**
* Provides implementation of the Flow Classifier Service.
*/
public class FlowClassifierManagerTestImpl implements FlowClassifierService {
public class FlowClassifierAdapter implements FlowClassifierService {
private final ConcurrentMap<FlowClassifierId, FlowClassifier> flowClassifierStore = new ConcurrentHashMap<>();
......
......@@ -16,16 +16,17 @@
package org.onosproject.sfc.util;
import org.onosproject.net.DeviceId;
import org.onosproject.net.flowobjective.FlowObjectiveService;
import org.onosproject.net.flowobjective.FilteringObjective;
import org.onosproject.net.flowobjective.FlowObjectiveService;
import org.onosproject.net.flowobjective.ForwardingObjective;
import org.onosproject.net.flowobjective.NextObjective;
/**
* Testing version of implementation on FlowObjectiveService.
*/
public class FlowObjectiveServiceTestImpl implements FlowObjectiveService {
public class FlowObjectiveAdapter implements FlowObjectiveService {
private ForwardingObjective forwardingObjective;
@Override
public void filter(DeviceId deviceId, FilteringObjective filteringObjective) {
......@@ -33,7 +34,7 @@ public class FlowObjectiveServiceTestImpl implements FlowObjectiveService {
@Override
public void forward(DeviceId deviceId, ForwardingObjective forwardingObjective) {
this.forwardingObjective = forwardingObjective;
}
@Override
......@@ -50,4 +51,8 @@ public class FlowObjectiveServiceTestImpl implements FlowObjectiveService {
public void initPolicy(String policy) {
}
public ForwardingObjective forwardingObjective() {
return forwardingObjective;
}
}
......
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.sfc.util;
import org.onosproject.net.behaviour.ExtensionSelectorResolver;
import org.onosproject.net.behaviour.ExtensionTreatmentResolver;
import org.onosproject.net.driver.Behaviour;
import org.onosproject.net.driver.Driver;
import org.onosproject.net.driver.DriverData;
import org.onosproject.net.driver.DriverHandler;
public class MockDriverHandler implements DriverHandler {
@Override
public Driver driver() {
return null;
}
@Override
public DriverData data() {
return null;
}
@Override
public <T extends Behaviour> T behaviour(Class<T> behaviourClass) {
if (behaviourClass == ExtensionSelectorResolver.class) {
return (T) new MockExtensionSelectorResolver();
} else if (behaviourClass == ExtensionTreatmentResolver.class) {
return (T) new MockExtensionTreatmentResolver();
}
return null;
}
@Override
public <T> T get(Class<T> serviceClass) {
return null;
}
}
\ No newline at end of file
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.sfc.util;
import java.util.List;
import org.onosproject.net.flow.criteria.ExtensionSelector;
import org.onosproject.net.flow.criteria.ExtensionSelectorType;
import org.onosproject.net.flow.instructions.ExtensionPropertyException;
public class MockExtensionSelector implements ExtensionSelector {
@Override
public <T> void setPropertyValue(String key, T value) throws ExtensionPropertyException {
}
@Override
public <T> T getPropertyValue(String key) throws ExtensionPropertyException {
return null;
}
@Override
public List<String> getProperties() {
return null;
}
@Override
public byte[] serialize() {
return null;
}
@Override
public void deserialize(byte[] data) {
}
@Override
public ExtensionSelectorType type() {
return null;
}
}
\ No newline at end of file
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.sfc.util;
import org.onosproject.net.behaviour.ExtensionSelectorResolver;
import org.onosproject.net.driver.DriverData;
import org.onosproject.net.driver.DriverHandler;
import org.onosproject.net.flow.criteria.ExtensionSelector;
import org.onosproject.net.flow.criteria.ExtensionSelectorType;
public class MockExtensionSelectorResolver implements ExtensionSelectorResolver {
@Override
public DriverHandler handler() {
return null;
}
@Override
public void setHandler(DriverHandler handler) {
}
@Override
public DriverData data() {
return null;
}
@Override
public void setData(DriverData data) {
}
@Override
public ExtensionSelector getExtensionSelector(ExtensionSelectorType type) {
return new MockExtensionSelector();
}
}
\ No newline at end of file
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.sfc.util;
import java.util.List;
import org.onosproject.net.flow.instructions.ExtensionPropertyException;
import org.onosproject.net.flow.instructions.ExtensionTreatment;
import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
public class MockExtensionTreatment implements ExtensionTreatment {
@Override
public <T> void setPropertyValue(String key, T value) throws ExtensionPropertyException {
}
@Override
public <T> T getPropertyValue(String key) throws ExtensionPropertyException {
return null;
}
@Override
public List<String> getProperties() {
return null;
}
@Override
public byte[] serialize() {
return null;
}
@Override
public void deserialize(byte[] data) {
}
@Override
public ExtensionTreatmentType type() {
return null;
}
}
\ No newline at end of file
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.sfc.util;
import org.onosproject.net.behaviour.ExtensionTreatmentResolver;
import org.onosproject.net.driver.DriverData;
import org.onosproject.net.driver.DriverHandler;
import org.onosproject.net.flow.instructions.ExtensionTreatment;
import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
public class MockExtensionTreatmentResolver implements ExtensionTreatmentResolver {
@Override
public DriverHandler handler() {
return null;
}
@Override
public void setHandler(DriverHandler handler) {
}
@Override
public DriverData data() {
return null;
}
@Override
public void setData(DriverData data) {
}
@Override
public ExtensionTreatment getExtensionInstruction(ExtensionTreatmentType type) {
return new MockExtensionTreatment();
}
}
\ No newline at end of file
......@@ -29,7 +29,7 @@ import org.onosproject.event.AbstractListenerManager;
/**
* Provides implementation of the portChainService.
*/
public class PortChainManagerTestImpl
public class PortChainAdapter
extends AbstractListenerManager<PortChainEvent, PortChainListener>
implements PortChainService {
......
......@@ -27,7 +27,7 @@ import org.onosproject.vtnrsc.portpair.PortPairService;
/**
* Provides implementation of the portPairService.
*/
public class PortPairManagerTestImpl implements PortPairService {
public class PortPairAdapter implements PortPairService {
private ConcurrentMap<PortPairId, PortPair> portPairStore = new ConcurrentHashMap<>();
......
......@@ -27,7 +27,7 @@ import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService;
/**
* Provides implementation of the portPairGroupService.
*/
public class PortPairGroupManagerTestImpl implements PortPairGroupService {
public class PortPairGroupAdapter implements PortPairGroupService {
private ConcurrentMap<PortPairGroupId, PortPairGroup> portPairGroupStore = new ConcurrentHashMap<>();
......
......@@ -31,7 +31,7 @@ import org.onosproject.vtnrsc.virtualport.VirtualPortService;
/**
* Provides implementation of the VirtualPort APIs.
*/
public class VirtualPortManagerTestImpl implements VirtualPortService {
public class VirtualPortAdapter implements VirtualPortService {
protected ConcurrentMap<VirtualPortId, VirtualPort> vPortStore = new ConcurrentHashMap<>();
......
......@@ -31,7 +31,7 @@ import org.onosproject.vtnrsc.service.VtnRscService;
/**
* Provides implementation of the VtnRsc service.
*/
public class VtnRscManagerTestImpl implements VtnRscService {
public class VtnRscAdapter implements VtnRscService {
@Override
public void addListener(VtnRscListener listener) {
}
......@@ -62,13 +62,12 @@ public class VtnRscManagerTestImpl implements VtnRscService {
@Override
public boolean isServiceFunction(VirtualPortId portId) {
// TODO Auto-generated method stub
return false;
}
@Override
public DeviceId getSfToSffMaping(VirtualPortId portId) {
return DeviceId.deviceId("www.google.com");
return DeviceId.deviceId("of:000000000000001");
}
@Override
......
......@@ -15,15 +15,21 @@
*/
package org.onosproject.net.host;
import java.util.Set;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import org.onosproject.net.Annotations;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultHost;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Host;
import org.onosproject.net.HostId;
import org.onosproject.net.HostLocation;
import org.onosproject.net.provider.ProviderId;
import java.util.Set;
import com.google.common.collect.Sets;
/**
* Test adapter for host service.
......@@ -41,7 +47,13 @@ public class HostServiceAdapter implements HostService {
@Override
public Host getHost(HostId hostId) {
return null;
ProviderId providerId = ProviderId.NONE;
MacAddress mac = MacAddress.valueOf("fa:12:3e:56:ee:a2");
VlanId vlan = VlanId.NONE;
HostLocation location = HostLocation.NONE;
Set<IpAddress> ips = Sets.newHashSet();
Annotations annotations = null;
return new DefaultHost(providerId, hostId, mac, vlan, location, ips, annotations);
}
@Override
......