bug 8795: start domR after corresponding network is shutdown - implement network before starting the domR

status 8795: resolved fixed

Conflicts:

	api/src/com/cloud/deploy/DeployDestination.java
This commit is contained in:
alena 2011-03-02 13:03:53 -08:00
parent e772bfa00b
commit b3ff533244
5 changed files with 71 additions and 7 deletions

View File

@ -89,11 +89,33 @@ public class DeployDestination {
@Override
public String toString() {
Long dcId = null;
Long podId = null;
Long clusterId = null;
Long hostId = null;
if (_dc != null) {
dcId = _dc.getId();
}
if (_pod != null) {
podId = _pod.getId();
}
if (_cluster != null) {
clusterId = _cluster.getId();
}
if (_host != null) {
hostId = _host.getId();
}
StringBuilder destination = new StringBuilder("Dest[Zone(Id)-Pod(Id)-Cluster(Id)-Host(Id)-Storage(Volume(Id|Type-->Pool(Id))] : Dest[");
destination.append("Zone(").append(_dc.getId()).append(")").append("-");
destination.append("Pod(").append(_pod.getId()).append(")").append("-");
destination.append("Cluster(").append(_cluster.getId()).append(")").append("-");
destination.append("Host(").append(_host.getId()).append(")").append("-");
destination.append("Zone(").append(dcId).append(")").append("-");
destination.append("Pod(").append(podId).append(")").append("-");
destination.append("Cluster(").append(clusterId).append(")").append("-");
destination.append("Host(").append(hostId).append(")").append("-");
destination.append("Storage(");
if(_storage != null){
String storageStr = "";

View File

@ -25,6 +25,7 @@ import com.cloud.api.commands.CreateNetworkCmd;
import com.cloud.api.commands.DisassociateIPAddrCmd;
import com.cloud.api.commands.ListNetworksCmd;
import com.cloud.api.commands.RestartNetworkCmd;
import com.cloud.deploy.DeployDestination;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
@ -35,6 +36,7 @@ import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.Network.Capability;
import com.cloud.network.Network.Service;
import com.cloud.offering.NetworkOffering;
import com.cloud.vm.ReservationContext;
public interface NetworkService {

View File

@ -20,7 +20,6 @@ package com.cloud.network;
import java.util.List;
import java.util.Map;
import com.cloud.api.commands.RestartNetworkCmd;
import com.cloud.dc.Vlan;
import com.cloud.dc.Vlan.VlanType;
import com.cloud.deploy.DeployDestination;
@ -182,4 +181,6 @@ public interface NetworkManager extends NetworkService {
Network getNetworkWithSecurityGroupEnabled(Long zoneId);
boolean startNetwork(long networkId, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
}

View File

@ -2141,8 +2141,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
User caller = _accountMgr.getActiveUser(UserContext.current().getCallerUserId());
Account callerAccount = _accountMgr.getActiveAccount(caller.getAccountId());
//Check if network exists
NetworkVO network = _networksDao.findById(networkId);
if (network == null) {
@ -2173,6 +2171,26 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
return success;
}
@Override
public boolean startNetwork(long networkId, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
//Check if network exists
NetworkVO network = _networksDao.findById(networkId);
if (network == null) {
throw new InvalidParameterValueException("Network with id=" + networkId + " doesn't exist");
}
//implement the network
s_logger.debug("Starting network " + network + "...");
Pair<NetworkGuru, NetworkVO> implementedNetwork = implementNetwork(networkId, dest, context);
if (implementedNetwork.first() == null) {
s_logger.warn("Failed to start the network " + network);
return false;
} else {
return true;
}
}
private boolean restartNetwork(long networkId, boolean restartElements, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
boolean success = true;

View File

@ -67,6 +67,7 @@ import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.configuration.dao.ResourceLimitDao;
import com.cloud.dc.DataCenter;
import com.cloud.dc.DataCenter.NetworkType;
import com.cloud.dc.HostPodVO;
import com.cloud.dc.dao.AccountVlanMapDao;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.HostPodDao;
@ -155,6 +156,7 @@ import com.cloud.vm.DomainRouterVO;
import com.cloud.vm.NicProfile;
import com.cloud.vm.NicVO;
import com.cloud.vm.ReservationContext;
import com.cloud.vm.ReservationContextImpl;
import com.cloud.vm.UserVmVO;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
@ -1322,6 +1324,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
@Override
public VirtualRouter startRouter(long routerId, boolean restartNetwork) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException {
Account account = UserContext.current().getCaller();
User caller = _accountMgr.getActiveUser(UserContext.current().getCallerUserId());
// verify parameters
DomainRouterVO router = _routerDao.findById(routerId);
@ -1330,6 +1333,24 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
}
_accountMgr.checkAccess(account, router);
Account owner = _accountMgr.getAccount(router.getAccountId());
//Check if all networks are implemented for the domR; if not - implement them
DataCenter dc = _dcDao.findById(router.getDataCenterId());
HostPodVO pod = _podDao.findById(router.getPodId());
DeployDestination dest = new DeployDestination(dc, pod, null, null);
ReservationContext context = new ReservationContextImpl(null, null, caller, owner);
List<NicVO> nics = _nicDao.listByVmId(routerId);
for (NicVO nic : nics) {
if (!_networkMgr.startNetwork(nic.getNetworkId(), dest, context)) {
s_logger.warn("Failed to start network id=" + nic.getNetworkId() + " as a part of domR start");
throw new CloudRuntimeException("Failed to start network id=" + nic.getNetworkId() + " as a part of domR start");
}
}
UserVO user = _userDao.findById(UserContext.current().getCallerUserId());
Map<Param, Object> params = new HashMap<Param, Object>();
if (restartNetwork) {