lishuai

[ONOS-3643] Update VTNRSC's bug: when delete vm, the sfc'data is error.

Change-Id: Ib9357c2792b51270e935c2f1205c2311e9988793
......@@ -20,6 +20,7 @@ import java.util.Iterator;
import org.onlab.packet.MacAddress;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Host;
import org.onosproject.net.HostId;
import org.onosproject.vtnrsc.SegmentationId;
import org.onosproject.vtnrsc.TenantId;
......@@ -69,4 +70,14 @@ public class VtnRscManagerTestImpl implements VtnRscService {
public DeviceId getSFToSFFMaping(VirtualPortId portId) {
return DeviceId.deviceId("www.google.com");
}
@Override
public void addDeviceIdOfOvsMap(VirtualPortId virtualPortId,
TenantId tenantId, DeviceId deviceId) {
}
@Override
public void removeDeviceIdOfOvsMap(Host host, TenantId tenantId,
DeviceId deviceId) {
}
}
......
......@@ -372,6 +372,7 @@ public class VTNManager implements VTNService {
log.error("The ifaceId of Host is null");
return;
}
programSffAndClassifierHost(host, Objective.Operation.ADD);
// apply L2 openflow rules
applyHostMonitoredL2Rules(host, Objective.Operation.ADD);
// apply L3 openflow rules
......@@ -389,6 +390,7 @@ public class VTNManager implements VTNService {
log.error("The ifaceId of Host is null");
return;
}
programSffAndClassifierHost(host, Objective.Operation.REMOVE);
// apply L2 openflow rules
applyHostMonitoredL2Rules(host, Objective.Operation.REMOVE);
// apply L3 openflow rules
......@@ -478,6 +480,22 @@ public class VTNManager implements VTNService {
}
}
private void programSffAndClassifierHost(Host host, Objective.Operation type) {
DeviceId deviceId = host.location().deviceId();
String ifaceId = host.annotations().value(IFACEID);
VirtualPortId virtualPortId = VirtualPortId.portId(ifaceId);
VirtualPort virtualPort = virtualPortService.getPort(virtualPortId);
if (virtualPort == null) {
virtualPort = VtnData.getPort(vPortStore, virtualPortId);
}
TenantId tenantId = virtualPort.tenantId();
if (Objective.Operation.ADD == type) {
vtnRscService.addDeviceIdOfOvsMap(virtualPortId, tenantId, deviceId);
} else if (Objective.Operation.REMOVE == type) {
vtnRscService.removeDeviceIdOfOvsMap(host, tenantId, deviceId);
}
}
private void applyHostMonitoredL2Rules(Host host, Objective.Operation type) {
DeviceId deviceId = host.location().deviceId();
if (!mastershipService.isLocalMaster(deviceId)) {
......
......@@ -21,6 +21,7 @@ import org.onlab.packet.MacAddress;
import org.onosproject.event.ListenerService;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Host;
import org.onosproject.net.HostId;
import org.onosproject.vtnrsc.SegmentationId;
import org.onosproject.vtnrsc.TenantId;
......@@ -79,4 +80,24 @@ public interface VtnRscService extends ListenerService<VtnRscEvent, VtnRscListen
* @return device identifier
*/
DeviceId getSFToSFFMaping(VirtualPortId portId);
/**
* Adds specify Device identifier to Service Function Forward OvsMap
* or Classifier OvsMap.
*
* @param virtualPortId the VirtualPort identifier
* @param tenantId the tenant identifier
* @param deviceId the device identifier
*/
void addDeviceIdOfOvsMap(VirtualPortId virtualPortId, TenantId tenantId, DeviceId deviceId);
/**
* Removes specify Device identifier from Service Function Forward OvsMap
* or Classifier OvsMap.
*
* @param host Host
* @param tenantId the tenant identifier
* @param deviceId the device identifier
*/
void removeDeviceIdOfOvsMap(Host host, TenantId tenantId, DeviceId deviceId);
}
......