|
46 | 46 | import org.apache.log4j.Logger; |
47 | 47 |
|
48 | 48 | import org.apache.cloudstack.alert.AlertService; |
49 | | -import org.apache.cloudstack.alert.AlertService.AlertType; |
50 | 49 | import org.apache.cloudstack.api.command.admin.router.RebootRouterCmd; |
51 | 50 | import org.apache.cloudstack.api.command.admin.router.UpgradeRouterCmd; |
52 | 51 | import org.apache.cloudstack.api.command.admin.router.UpgradeRouterTemplateCmd; |
|
61 | 60 | import org.apache.cloudstack.managed.context.ManagedContextRunnable; |
62 | 61 | import org.apache.cloudstack.utils.identity.ManagementServerNode; |
63 | 62 | import org.apache.cloudstack.utils.usage.UsageUtils; |
64 | | -import org.apache.log4j.Logger; |
65 | 63 |
|
66 | 64 | import com.cloud.agent.AgentManager; |
67 | 65 | import com.cloud.agent.Listener; |
@@ -4312,10 +4310,22 @@ public boolean preStateTransitionEvent(State oldState, VirtualMachine.Event even |
4312 | 4310 |
|
4313 | 4311 | @Override |
4314 | 4312 | public boolean postStateTransitionEvent(State oldState, VirtualMachine.Event event, State newState, VirtualMachine vo, boolean status, Object opaque) { |
4315 | | - if (oldState == State.Stopped && event == VirtualMachine.Event.FollowAgentPowerOnReport && newState == State.Running) { |
| 4313 | + if (event == VirtualMachine.Event.FollowAgentPowerOnReport && newState == State.Running) { |
4316 | 4314 | if (vo.getType() == VirtualMachine.Type.DomainRouter) { |
4317 | | - s_logger.info("Schedule a router reboot task as router " + vo.getId() + " is powered-on out-of-band. we need to reboot to refresh network rules"); |
4318 | | - _executor.schedule(new RebootTask(vo.getId()), 1000, TimeUnit.MICROSECONDS); |
| 4315 | + if (opaque != null && opaque instanceof Pair<?, ?>) { |
| 4316 | + Pair<?, ?> pair = (Pair<?, ?>)opaque; |
| 4317 | + Object first = pair.first(); |
| 4318 | + Object second = pair.second(); |
| 4319 | + if (first != null && second != null && first instanceof Long && second instanceof Long) { |
| 4320 | + Long hostId = (Long)first; |
| 4321 | + Long powerHostId = (Long)second; |
| 4322 | + // If VM host known to CS is different from 'PowerOn' report host, then it is out-of-band movement |
| 4323 | + if (hostId.longValue() != powerHostId.longValue()) { |
| 4324 | + s_logger.info("Schedule a router reboot task as router " + vo.getId() + " is powered-on out-of-band. we need to reboot to refresh network rules"); |
| 4325 | + _executor.schedule(new RebootTask(vo.getId()), 1000, TimeUnit.MICROSECONDS); |
| 4326 | + } |
| 4327 | + } |
| 4328 | + } |
4319 | 4329 | } |
4320 | 4330 | } |
4321 | 4331 | return true; |
|
0 commit comments