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; ...@@ -20,6 +20,7 @@ import java.util.Iterator;
20 import org.onlab.packet.MacAddress; 20 import org.onlab.packet.MacAddress;
21 import org.onosproject.net.Device; 21 import org.onosproject.net.Device;
22 import org.onosproject.net.DeviceId; 22 import org.onosproject.net.DeviceId;
23 +import org.onosproject.net.Host;
23 import org.onosproject.net.HostId; 24 import org.onosproject.net.HostId;
24 import org.onosproject.vtnrsc.SegmentationId; 25 import org.onosproject.vtnrsc.SegmentationId;
25 import org.onosproject.vtnrsc.TenantId; 26 import org.onosproject.vtnrsc.TenantId;
...@@ -69,4 +70,14 @@ public class VtnRscManagerTestImpl implements VtnRscService { ...@@ -69,4 +70,14 @@ public class VtnRscManagerTestImpl implements VtnRscService {
69 public DeviceId getSFToSFFMaping(VirtualPortId portId) { 70 public DeviceId getSFToSFFMaping(VirtualPortId portId) {
70 return DeviceId.deviceId("www.google.com"); 71 return DeviceId.deviceId("www.google.com");
71 } 72 }
73 +
74 + @Override
75 + public void addDeviceIdOfOvsMap(VirtualPortId virtualPortId,
76 + TenantId tenantId, DeviceId deviceId) {
77 + }
78 +
79 + @Override
80 + public void removeDeviceIdOfOvsMap(Host host, TenantId tenantId,
81 + DeviceId deviceId) {
82 + }
72 } 83 }
......
...@@ -372,6 +372,7 @@ public class VTNManager implements VTNService { ...@@ -372,6 +372,7 @@ public class VTNManager implements VTNService {
372 log.error("The ifaceId of Host is null"); 372 log.error("The ifaceId of Host is null");
373 return; 373 return;
374 } 374 }
375 + programSffAndClassifierHost(host, Objective.Operation.ADD);
375 // apply L2 openflow rules 376 // apply L2 openflow rules
376 applyHostMonitoredL2Rules(host, Objective.Operation.ADD); 377 applyHostMonitoredL2Rules(host, Objective.Operation.ADD);
377 // apply L3 openflow rules 378 // apply L3 openflow rules
...@@ -389,6 +390,7 @@ public class VTNManager implements VTNService { ...@@ -389,6 +390,7 @@ public class VTNManager implements VTNService {
389 log.error("The ifaceId of Host is null"); 390 log.error("The ifaceId of Host is null");
390 return; 391 return;
391 } 392 }
393 + programSffAndClassifierHost(host, Objective.Operation.REMOVE);
392 // apply L2 openflow rules 394 // apply L2 openflow rules
393 applyHostMonitoredL2Rules(host, Objective.Operation.REMOVE); 395 applyHostMonitoredL2Rules(host, Objective.Operation.REMOVE);
394 // apply L3 openflow rules 396 // apply L3 openflow rules
...@@ -478,6 +480,22 @@ public class VTNManager implements VTNService { ...@@ -478,6 +480,22 @@ public class VTNManager implements VTNService {
478 } 480 }
479 } 481 }
480 482
483 + private void programSffAndClassifierHost(Host host, Objective.Operation type) {
484 + DeviceId deviceId = host.location().deviceId();
485 + String ifaceId = host.annotations().value(IFACEID);
486 + VirtualPortId virtualPortId = VirtualPortId.portId(ifaceId);
487 + VirtualPort virtualPort = virtualPortService.getPort(virtualPortId);
488 + if (virtualPort == null) {
489 + virtualPort = VtnData.getPort(vPortStore, virtualPortId);
490 + }
491 + TenantId tenantId = virtualPort.tenantId();
492 + if (Objective.Operation.ADD == type) {
493 + vtnRscService.addDeviceIdOfOvsMap(virtualPortId, tenantId, deviceId);
494 + } else if (Objective.Operation.REMOVE == type) {
495 + vtnRscService.removeDeviceIdOfOvsMap(host, tenantId, deviceId);
496 + }
497 + }
498 +
481 private void applyHostMonitoredL2Rules(Host host, Objective.Operation type) { 499 private void applyHostMonitoredL2Rules(Host host, Objective.Operation type) {
482 DeviceId deviceId = host.location().deviceId(); 500 DeviceId deviceId = host.location().deviceId();
483 if (!mastershipService.isLocalMaster(deviceId)) { 501 if (!mastershipService.isLocalMaster(deviceId)) {
......
...@@ -21,6 +21,7 @@ import org.onlab.packet.MacAddress; ...@@ -21,6 +21,7 @@ import org.onlab.packet.MacAddress;
21 import org.onosproject.event.ListenerService; 21 import org.onosproject.event.ListenerService;
22 import org.onosproject.net.Device; 22 import org.onosproject.net.Device;
23 import org.onosproject.net.DeviceId; 23 import org.onosproject.net.DeviceId;
24 +import org.onosproject.net.Host;
24 import org.onosproject.net.HostId; 25 import org.onosproject.net.HostId;
25 import org.onosproject.vtnrsc.SegmentationId; 26 import org.onosproject.vtnrsc.SegmentationId;
26 import org.onosproject.vtnrsc.TenantId; 27 import org.onosproject.vtnrsc.TenantId;
...@@ -79,4 +80,24 @@ public interface VtnRscService extends ListenerService<VtnRscEvent, VtnRscListen ...@@ -79,4 +80,24 @@ public interface VtnRscService extends ListenerService<VtnRscEvent, VtnRscListen
79 * @return device identifier 80 * @return device identifier
80 */ 81 */
81 DeviceId getSFToSFFMaping(VirtualPortId portId); 82 DeviceId getSFToSFFMaping(VirtualPortId portId);
83 +
84 + /**
85 + * Adds specify Device identifier to Service Function Forward OvsMap
86 + * or Classifier OvsMap.
87 + *
88 + * @param virtualPortId the VirtualPort identifier
89 + * @param tenantId the tenant identifier
90 + * @param deviceId the device identifier
91 + */
92 + void addDeviceIdOfOvsMap(VirtualPortId virtualPortId, TenantId tenantId, DeviceId deviceId);
93 +
94 + /**
95 + * Removes specify Device identifier from Service Function Forward OvsMap
96 + * or Classifier OvsMap.
97 + *
98 + * @param host Host
99 + * @param tenantId the tenant identifier
100 + * @param deviceId the device identifier
101 + */
102 + void removeDeviceIdOfOvsMap(Host host, TenantId tenantId, DeviceId deviceId);
82 } 103 }
......