bug 11307: Add destroyRouter command

This commit is contained in:
Sheng Yang 2011-09-14 02:58:44 -07:00
parent 58ee9f4855
commit 3ba15fe813
6 changed files with 12 additions and 9 deletions

View File

@ -52,5 +52,6 @@ public interface VirtualNetworkApplianceService{
VirtualRouter stopRouter(long routerId, boolean forced) throws ResourceUnavailableException, ConcurrentOperationException;
VirtualRouter startRouter(StartRouterCmd cmd) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException;
VirtualRouter destroyRouter(long routerId) throws ResourceUnavailableException, ConcurrentOperationException;
}

View File

@ -134,6 +134,7 @@ updateLoadBalancerRule=com.cloud.api.commands.UpdateLoadBalancerRuleCmd;15
startRouter=com.cloud.api.commands.StartRouterCmd;7
rebootRouter=com.cloud.api.commands.RebootRouterCmd;7
stopRouter=com.cloud.api.commands.StopRouterCmd;7
destroyRouter=com.cloud.api.commands.DestroyRouterCmd;7
changeServiceForRouter=com.cloud.api.commands.UpgradeRouterCmd;7
listRouters=com.cloud.api.commands.ListRoutersCmd;7

View File

@ -166,7 +166,7 @@ public class DhcpElement extends AdapterBase implements NetworkElement, Password
}
boolean result = true;
for (DomainRouterVO router : routers) {
result = result && _routerMgr.destroyRouter(router.getId());
result = result && (_routerMgr.destroyRouter(router.getId()) != null);
}
return result;
}

View File

@ -164,7 +164,7 @@ public class VirtualRouterElement extends DhcpElement implements NetworkElement,
if (router.getState() != State.Stopped || _routerMgr.stopRouter(router.getId(), false) == null) {
s_logger.warn("Failed to stop virtual router element " + router + " as a part of network " + network + " restart");
}
if (!_routerMgr.destroyRouter(router.getId())) {
if (_routerMgr.destroyRouter(router.getId()) == null) {
s_logger.warn("Failed to destroy virtual router element " + router + " as a part of network " + network + " restart");
}
}
@ -353,7 +353,7 @@ public class VirtualRouterElement extends DhcpElement implements NetworkElement,
}
boolean result = true;
for (DomainRouterVO router : routers) {
result = result && _routerMgr.destroyRouter(router.getId());
result = result && (_routerMgr.destroyRouter(router.getId()) != null);
}
return result;
}

View File

@ -64,8 +64,6 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA
*/
boolean savePasswordToRouter(Network network, NicProfile nic, VirtualMachineProfile<UserVm> profile, List<? extends VirtualRouter> routers) throws ResourceUnavailableException;
boolean destroyRouter(long routerId) throws ResourceUnavailableException, ConcurrentOperationException;
boolean getRouterStatistics(long vmId, Map<String, long[]> netStats, Map<String, long[]> diskStats);
List<DomainRouterVO> getRouters(long accountId, long zoneId);

View File

@ -356,7 +356,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
}
@Override
public boolean destroyRouter(final long routerId) throws ResourceUnavailableException, ConcurrentOperationException {
public VirtualRouter destroyRouter(final long routerId) throws ResourceUnavailableException, ConcurrentOperationException {
UserContext context = UserContext.current();
User user = _accountMgr.getActiveUser(context.getCallerUserId());
@ -366,11 +366,14 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
DomainRouterVO router = _routerDao.findById(routerId);
if (router == null) {
return true;
return null;
}
boolean result = _itMgr.expunge(router, user, _accountMgr.getAccount(router.getAccountId()));
return result;
if (result) {
return router;
}
return null;
}
@Override