|
67 | 67 | import com.cloud.configuration.dao.ResourceLimitDao; |
68 | 68 | import com.cloud.dc.DataCenter; |
69 | 69 | import com.cloud.dc.DataCenter.NetworkType; |
| 70 | +import com.cloud.dc.HostPodVO; |
70 | 71 | import com.cloud.dc.dao.AccountVlanMapDao; |
71 | 72 | import com.cloud.dc.dao.DataCenterDao; |
72 | 73 | import com.cloud.dc.dao.HostPodDao; |
|
155 | 156 | import com.cloud.vm.NicProfile; |
156 | 157 | import com.cloud.vm.NicVO; |
157 | 158 | import com.cloud.vm.ReservationContext; |
| 159 | +import com.cloud.vm.ReservationContextImpl; |
158 | 160 | import com.cloud.vm.UserVmVO; |
159 | 161 | import com.cloud.vm.VMInstanceVO; |
160 | 162 | import com.cloud.vm.VirtualMachine; |
@@ -1322,13 +1324,32 @@ public DomainRouterVO findByName(String name) { |
1322 | 1324 | @Override |
1323 | 1325 | public VirtualRouter startRouter(long routerId, boolean restartNetwork) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException { |
1324 | 1326 | Account account = UserContext.current().getCaller(); |
| 1327 | + User caller = _accountMgr.getActiveUser(UserContext.current().getCallerUserId()); |
1325 | 1328 |
|
1326 | 1329 | // verify parameters |
1327 | 1330 | DomainRouterVO router = _routerDao.findById(routerId); |
1328 | 1331 | if (router == null) { |
1329 | 1332 | throw new InvalidParameterValueException("Unable to find router by id " + routerId + "."); |
1330 | 1333 | } |
1331 | 1334 | _accountMgr.checkAccess(account, router); |
| 1335 | + |
| 1336 | + Account owner = _accountMgr.getAccount(router.getAccountId()); |
| 1337 | + |
| 1338 | + //Check if all networks are implemented for the domR; if not - implement them |
| 1339 | + DataCenter dc = _dcDao.findById(router.getDataCenterId()); |
| 1340 | + HostPodVO pod = _podDao.findById(router.getPodId()); |
| 1341 | + DeployDestination dest = new DeployDestination(dc, pod, null, null); |
| 1342 | + |
| 1343 | + ReservationContext context = new ReservationContextImpl(null, null, caller, owner); |
| 1344 | + |
| 1345 | + List<NicVO> nics = _nicDao.listByVmId(routerId); |
| 1346 | + |
| 1347 | + for (NicVO nic : nics) { |
| 1348 | + if (!_networkMgr.startNetwork(nic.getNetworkId(), dest, context)) { |
| 1349 | + s_logger.warn("Failed to start network id=" + nic.getNetworkId() + " as a part of domR start"); |
| 1350 | + throw new CloudRuntimeException("Failed to start network id=" + nic.getNetworkId() + " as a part of domR start"); |
| 1351 | + } |
| 1352 | + } |
1332 | 1353 |
|
1333 | 1354 | UserVO user = _userDao.findById(UserContext.current().getCallerUserId()); |
1334 | 1355 | Map<Param, Object> params = new HashMap<Param, Object>(); |
|
0 commit comments