mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 1974: add upgraderoutercmd to upgrade router vm's service offering
status 1974: resolved fixed It's a synced API, which just update router vm's service offering, parameter: router id, service offering id, return: ture on successfull, otherwise false
This commit is contained in:
parent
09768ca751
commit
3d9f25e903
@ -129,6 +129,7 @@ listLoadBalancerRuleInstances=com.cloud.api.commands.ListLoadBalancerRuleInstanc
|
||||
startRouter=com.cloud.api.commands.StartRouterCmd;3
|
||||
rebootRouter=com.cloud.api.commands.RebootRouterCmd;3
|
||||
stopRouter=com.cloud.api.commands.StopRouterCmd;3
|
||||
changeServiceForRouter=com.cloud.api.commands.UpgradeRouterCmd;3
|
||||
listRouters=com.cloud.api.commands.ListRoutersCmd;7
|
||||
|
||||
#### system vm commands
|
||||
|
||||
@ -2261,5 +2261,6 @@ public interface ManagementServer {
|
||||
*/
|
||||
String getVersion();
|
||||
boolean uploadCertificate(String certificatePath);
|
||||
boolean upgradeRouter(long routerId, long serviceOfferingId) throws InvalidParameterValueException;
|
||||
|
||||
}
|
||||
|
||||
@ -320,4 +320,8 @@ public class DomainRouterVO extends VMInstanceVO implements DomainRouter {
|
||||
public String getGuestZoneMacAddress() {
|
||||
return guestZoneMacAddress;
|
||||
}
|
||||
|
||||
public void setServiceOfferingId(long serviceOfferingId) {
|
||||
this.serviceOfferingId = serviceOfferingId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -234,4 +234,5 @@ public interface NetworkManager extends Manager {
|
||||
<K extends VMInstanceVO> void create(K vm);
|
||||
|
||||
<K extends VMInstanceVO> List<NicVO> getNics(K vm);
|
||||
boolean upgradeRouter(long routerId, long serviceOfferingId);
|
||||
}
|
||||
|
||||
@ -778,6 +778,15 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public boolean upgradeRouter(long routerId, long serviceOfferingId) {
|
||||
DomainRouterVO router = _routerDao.acquire(routerId);
|
||||
|
||||
router.setServiceOfferingId(serviceOfferingId);
|
||||
return _routerDao.update(routerId, router);
|
||||
}
|
||||
|
||||
private String rot13(final String password) {
|
||||
final StringBuffer newPassword = new StringBuffer("");
|
||||
@ -888,10 +897,11 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
||||
final HashSet<Host> avoid = new HashSet<Host>();
|
||||
final VMTemplateVO template = _templateDao.findById(router.getTemplateId());
|
||||
final DataCenterVO dc = _dcDao.findById(router.getDataCenterId());
|
||||
ServiceOfferingVO offering = _serviceOfferingDao.findById(router.getServiceOfferingId());
|
||||
List<StoragePoolVO> sps = _storageMgr.getStoragePoolsForVm(router.getId());
|
||||
StoragePoolVO sp = sps.get(0); // FIXME
|
||||
|
||||
HostVO routingHost = (HostVO)_agentMgr.findHost(Host.Type.Routing, dc, pod, sp, _offering, template, router, null, avoid);
|
||||
HostVO routingHost = (HostVO)_agentMgr.findHost(Host.Type.Routing, dc, pod, sp, offering, template, router, null, avoid);
|
||||
|
||||
if (routingHost == null) {
|
||||
s_logger.error("Unable to find a host to start " + router.toString());
|
||||
@ -1053,7 +1063,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
||||
_dcDao.releaseLinkLocalPrivateIpAddress(privateIpAddress, router.getDataCenterId(), router.getId());
|
||||
|
||||
_storageMgr.unshare(router, vols, routingHost);
|
||||
} while (--retry > 0 && (routingHost = (HostVO)_agentMgr.findHost(Host.Type.Routing, dc, pod, sp, _offering, template, router, null, avoid)) != null);
|
||||
} while (--retry > 0 && (routingHost = (HostVO)_agentMgr.findHost(Host.Type.Routing, dc, pod, sp, offering, template, router, null, avoid)) != null);
|
||||
|
||||
|
||||
if (routingHost == null || retry <= 0) {
|
||||
@ -2134,6 +2144,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
||||
final boolean mirroredVols = router.isMirroredVols();
|
||||
final DataCenterVO dc = _dcDao.findById(router.getDataCenterId());
|
||||
final HostPodVO pod = _podDao.findById(router.getPodId());
|
||||
final ServiceOfferingVO offering = _serviceOfferingDao.findById(router.getServiceOfferingId());
|
||||
List<StoragePoolVO> sps = _storageMgr.getStoragePoolsForVm(router.getId());
|
||||
StoragePoolVO sp = sps.get(0); // FIXME
|
||||
|
||||
@ -2158,7 +2169,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
||||
}
|
||||
avoid.add(fromHost);
|
||||
|
||||
while ((routingHost = (HostVO)_agentMgr.findHost(Host.Type.Routing, dc, pod, sp, _offering, _template, router, fromHost, avoid)) != null) {
|
||||
while ((routingHost = (HostVO)_agentMgr.findHost(Host.Type.Routing, dc, pod, sp, offering, _template, router, fromHost, avoid)) != null) {
|
||||
avoid.add(routingHost);
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Trying to migrate router to host " + routingHost.getName());
|
||||
|
||||
@ -2903,6 +2903,37 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
public boolean destroyRouter(long routerId) {
|
||||
return _networkMgr.destroyRouter(routerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean upgradeRouter(long routerId, long serviceOfferingId) throws InvalidParameterValueException {
|
||||
DomainRouterVO router = _routerDao.findById(routerId);
|
||||
if (router == null) {
|
||||
throw new InvalidParameterValueException("Unable to find router with id " + routerId);
|
||||
}
|
||||
|
||||
if (router.getServiceOfferingId() == serviceOfferingId) {
|
||||
s_logger.debug("Router: " + routerId + "already has service offering: " + serviceOfferingId);
|
||||
return true;
|
||||
}
|
||||
|
||||
ServiceOfferingVO newServiceOffering = _offeringsDao.findById(serviceOfferingId);
|
||||
if (newServiceOffering == null) {
|
||||
throw new InvalidParameterValueException("Unable to find service offering with id " + serviceOfferingId);
|
||||
}
|
||||
|
||||
ServiceOfferingVO currentServiceOffering = _offeringsDao.findById(router.getServiceOfferingId());
|
||||
|
||||
if (!currentServiceOffering.getGuestIpType().equals(newServiceOffering.getGuestIpType())) {
|
||||
throw new InvalidParameterValueException("Can't upgrade, due to new newtowrk type: " + newServiceOffering.getGuestIpType() + " is different from " +
|
||||
"curruent network type: " + currentServiceOffering.getGuestIpType());
|
||||
}
|
||||
if (currentServiceOffering.getUseLocalStorage() != newServiceOffering.getUseLocalStorage()) {
|
||||
throw new InvalidParameterValueException("Can't upgrade, due to new local storage status : " + newServiceOffering.getGuestIpType() + " is different from " +
|
||||
"curruent local storage status: " + currentServiceOffering.getUseLocalStorage());
|
||||
}
|
||||
|
||||
return _networkMgr.upgradeRouter(routerId, serviceOfferingId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainRouterVO findDomainRouterBy(long accountId, long dataCenterId) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user