diff --git a/api/src/com/cloud/vm/NicProfile.java b/api/src/com/cloud/vm/NicProfile.java index 1ef08db3710..7a2b5a4b7f9 100644 --- a/api/src/com/cloud/vm/NicProfile.java +++ b/api/src/com/cloud/vm/NicProfile.java @@ -202,6 +202,7 @@ public class NicProfile { this.broadcastUri = broadcastUri; this.isolationUri = isolationUri; this.netmask = nic.getNetmask(); + this.isSecurityGroupEnabled = network.isSecurityGroupEnabled(); if (networkRate != null) { this.networkRate = networkRate; diff --git a/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java b/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java index 9eddec5beac..96685bc4375 100644 --- a/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java +++ b/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java @@ -427,17 +427,25 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG } protected void handleVmMigrated(VMInstanceVO vm) { - if (vm.getType() == VirtualMachine.Type.User || !isVmSecurityGroupEnabled(vm.getId())) + if (!isVmSecurityGroupEnabled(vm.getId())) return; - NetworkRulesSystemVmCommand nrc = new NetworkRulesSystemVmCommand(vm.getInstanceName(), vm.getType()); - Commands cmds = new Commands(nrc); - try { - _agentMgr.send(vm.getHostId(), cmds); - } catch (AgentUnavailableException e) { - s_logger.debug(e.toString()); - } catch (OperationTimedoutException e) { - s_logger.debug(e.toString()); - } + if (vm.getType() != VirtualMachine.Type.User) { + Commands cmds = null; + NetworkRulesSystemVmCommand nrc = new NetworkRulesSystemVmCommand(vm.getInstanceName(), vm.getType()); + cmds = new Commands(nrc); + try { + _agentMgr.send(vm.getHostId(), cmds); + } catch (AgentUnavailableException e) { + s_logger.debug(e.toString()); + } catch (OperationTimedoutException e) { + s_logger.debug(e.toString()); + } + + } else { + Set affectedVms = new HashSet(); + affectedVms.add(vm.getId()); + scheduleRulesetUpdateToHosts(affectedVms, true, null); + } } @Override @DB @SuppressWarnings("rawtypes")