You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ra...@apache.org on 2014/12/08 11:09:06 UTC
[18/50] [abbrv] git commit: updated refs/heads/master to b61733d
CLOUDSTACK-7994: Network rules are not configured in VR after out-of-band movement due to host crash
Ensure that VR is re-booted when it is moved to another host out-of-band. This is necessary to re-program all network rules
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/513adab5
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/513adab5
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/513adab5
Branch: refs/heads/master
Commit: 513adab51b53ba1acdea908225cfffab90ca1595
Parents: 21b0ad4
Author: Koushik Das <ko...@apache.org>
Authored: Mon Dec 1 16:18:06 2014 +0530
Committer: Koushik Das <ko...@apache.org>
Committed: Mon Dec 1 18:09:58 2014 +0530
----------------------------------------------------------------------
.../VirtualNetworkApplianceManagerImpl.java | 20 +++++++++++++++++---
.../VpcVirtualNetworkApplianceManagerImpl.java | 7 +++++++
2 files changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/513adab5/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index fcaf3bc..df8d179 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -244,6 +244,7 @@ import com.cloud.vm.dao.NicIpAliasVO;
import com.cloud.vm.dao.UserVmDao;
import com.cloud.vm.dao.UserVmDetailsDao;
import com.cloud.vm.dao.VMInstanceDao;
+
import org.apache.cloudstack.alert.AlertService;
import org.apache.cloudstack.alert.AlertService.AlertType;
import org.apache.cloudstack.api.command.admin.router.RebootRouterCmd;
@@ -266,6 +267,7 @@ import org.apache.log4j.Logger;
import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
+
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -4459,10 +4461,22 @@ VirtualMachineGuru, Listener, Configurable, StateListener<State, VirtualMachine.
@Override
public boolean postStateTransitionEvent(State oldState, VirtualMachine.Event event, State newState, VirtualMachine vo, boolean status, Object opaque) {
- if (oldState == State.Stopped && event == VirtualMachine.Event.FollowAgentPowerOnReport && newState == State.Running) {
+ if (event == VirtualMachine.Event.FollowAgentPowerOnReport && newState == State.Running) {
if (vo.getType() == VirtualMachine.Type.DomainRouter) {
- 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");
- _executor.schedule(new RebootTask(vo.getId()), 1000, TimeUnit.MICROSECONDS);
+ if (opaque != null && opaque instanceof Pair<?, ?>) {
+ Pair<?, ?> pair = (Pair<?, ?>)opaque;
+ Object first = pair.first();
+ Object second = pair.second();
+ if (first != null && second != null && first instanceof Long && second instanceof Long) {
+ Long hostId = (Long)first;
+ Long powerHostId = (Long)second;
+ // If VM host known to CS is different from 'PowerOn' report host, then it is out-of-band movement
+ if (hostId.longValue() != powerHostId.longValue()) {
+ 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");
+ _executor.schedule(new RebootTask(vo.getId()), 1000, TimeUnit.MICROSECONDS);
+ }
+ }
+ }
}
}
return true;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/513adab5/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
index cc673d9..15c4f08 100644
--- a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
@@ -1481,4 +1481,11 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
return true;
}
+
+ @Override
+ public boolean postStateTransitionEvent(State oldState, VirtualMachine.Event event, State newState, VirtualMachine vo, boolean status, Object opaque) {
+ // Without this VirtualNetworkApplianceManagerImpl.postStateTransitionEvent() gets called twice as part of listeners -
+ // once from VpcVirtualNetworkApplianceManagerImpl and once from VirtualNetworkApplianceManagerImpl itself
+ return true;
+ }
}