Skip to content

Commit a2f86dd

Browse files
committed
Fix: do not add/remove security group rules if the device is offline
Change-Id: Id209233c1bdc8903bd9da32bfa746d5bf60fd946
1 parent c684ee1 commit a2f86dd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackSecurityGroupHandler.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.onosproject.core.CoreService;
3737
import org.onosproject.mastership.MastershipService;
3838
import org.onosproject.net.DeviceId;
39+
import org.onosproject.net.device.DeviceService;
3940
import org.onosproject.net.driver.DriverService;
4041
import org.onosproject.net.flow.DefaultTrafficSelector;
4142
import org.onosproject.net.flow.DefaultTrafficTreatment;
@@ -175,6 +176,9 @@ public class OpenstackSecurityGroupHandler {
175176
@Reference(cardinality = ReferenceCardinality.MANDATORY)
176177
protected DriverService driverService;
177178

179+
@Reference(cardinality = ReferenceCardinality.MANDATORY)
180+
protected DeviceService deviceService;
181+
178182
@Reference(cardinality = ReferenceCardinality.MANDATORY)
179183
protected LeadershipService leadershipService;
180184

@@ -381,6 +385,11 @@ private void populateSecurityGroupRule(SecurityGroupRule sgRule,
381385
return;
382386
}
383387

388+
// if the device is not available we do not perform any action
389+
if (instPort.deviceId() == null || !deviceService.isAvailable(instPort.deviceId())) {
390+
return;
391+
}
392+
384393
// in case a port is bound to multiple security groups, we do NOT remove
385394
// egress rules unless all security groups bound to the port to be removed
386395
Port osPort = osNetService.port(instPort.portId());

0 commit comments

Comments
 (0)