bug 11122: Fix router startup

The new created router got hostId = 0.

status 11122: resolved fixed
This commit is contained in:
Sheng Yang 2011-08-13 00:08:21 -07:00
parent b9217f85e4
commit d4990c82ca
2 changed files with 11 additions and 2 deletions

View File

@ -123,6 +123,9 @@ public class VirtualRouterElement extends DhcpElement implements NetworkElement,
@SuppressWarnings("unchecked")
VirtualMachineProfile<UserVm> uservm = (VirtualMachineProfile<UserVm>)vm;
List<DomainRouterVO> routers = _routerMgr.deployVirtualRouter(network, dest, _accountMgr.getAccount(network.getAccountId()), uservm.getParameters(), isRedundant);
if ((routers == null) || (routers.size() == 0)) {
throw new ResourceUnavailableException("Can't find at least one running router!", this.getClass(), 0);
}
List<VirtualRouter> rets = _routerMgr.addVirtualMachineIntoNetwork(network, nic, uservm, dest, context, routers);
return (rets != null) && (!rets.isEmpty());
} else {

View File

@ -1053,8 +1053,14 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
}
for (DomainRouterVO router : routers) {
HostVO host = _hostDao.findById(router.getHostId());
if (host != null && host.getStatus() == Status.Up) {
boolean skip = false;
if (router.getHostId() != null) {
HostVO host = _hostDao.findById(router.getHostId());
if (host == null || host.getStatus() != Status.Up) {
skip = true;
}
}
if (!skip) {
State state = router.getState();
if (state != State.Running) {
router = startVirtualRouter(router, _accountService.getSystemUser(), _accountService.getSystemAccount(), params);