mirror of https://github.com/apache/cloudstack.git
Better integration between it and virtual machine gurus
This commit is contained in:
parent
1bc46cdc6f
commit
4db0b7d156
|
|
@ -33,7 +33,7 @@ updateResourceLimit=com.cloud.api.commands.UpdateResourceLimitCmd;3
|
|||
listResourceLimits=com.cloud.api.commands.ListResourceLimitsCmd;15
|
||||
|
||||
#### VM commands
|
||||
deployVirtualMachine=com.cloud.api.commands.DeployVMCmd;11
|
||||
deployVirtualMachine=com.cloud.api.commands.DeployVm2Cmd;11
|
||||
destroyVirtualMachine=com.cloud.api.commands.DestroyVMCmd;15
|
||||
rebootVirtualMachine=com.cloud.api.commands.RebootVMCmd;15
|
||||
startVirtualMachine=com.cloud.api.commands.StartVMCmd;15
|
||||
|
|
|
|||
|
|
@ -552,7 +552,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
|
||||
DeploymentPlan plan = new DataCenterDeployment(proxy.getDataCenterId(), 1);
|
||||
AccountVO systemAcct = _accountMgr.getSystemAccount();
|
||||
return _vmMgr.start(proxy, plan, systemAcct, this);
|
||||
return _vmMgr.start(proxy, plan, systemAcct);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -2346,6 +2346,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
if (haMgr != null) {
|
||||
haMgr.registerHandler(VirtualMachine.Type.ConsoleProxy, this);
|
||||
}
|
||||
_vmMgr.registerGuru(VirtualMachine.Type.ConsoleProxy, this);
|
||||
|
||||
boolean useLocalStorage = Boolean.parseBoolean(configs.get(Config.SystemVMUseLocalStorage.key()));
|
||||
String networkRateStr = _configDao.getValue("network.throttling.rate");
|
||||
|
|
@ -2531,4 +2532,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
event = _eventDao.persist(event);
|
||||
return event.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConsoleProxyVO persist(ConsoleProxyVO proxy) {
|
||||
return _consoleProxyDao.persist(proxy);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1454,6 +1454,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
|||
|
||||
_agentMgr.registerForHostEvents(new SshKeysDistriMonitor(this, _hostDao, _configDao), true, false, false);
|
||||
_haMgr.registerHandler(VirtualMachine.Type.DomainRouter, this);
|
||||
_vmMgr.registerGuru(VirtualMachine.Type.DomainRouter, this);
|
||||
|
||||
boolean useLocalStorage = Boolean.parseBoolean(configs.get(Config.SystemVMUseLocalStorage.key()));
|
||||
String networkRateStr = _configDao.getValue("network.throttling.rate");
|
||||
|
|
@ -2056,7 +2057,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
|||
}
|
||||
txn.commit();
|
||||
|
||||
return _vmMgr.start(router, plan, owner, this);
|
||||
return _vmMgr.start(router, plan, owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -2107,6 +2108,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
|||
return true;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
@Override
|
||||
public RemoteAccessVpnVO startRemoteAccessVpn(RemoteAccessVpnVO vpnVO) {
|
||||
DomainRouterVO router = getRouter(vpnVO.getAccountId(), vpnVO.getZoneId());
|
||||
|
|
@ -2163,4 +2165,8 @@ public class DomainRouterManagerImpl implements DomainRouterManager, VirtualMach
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainRouterVO persist(DomainRouterVO router) {
|
||||
return _routerDao.persist(router);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
package com.cloud.vm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -91,8 +92,17 @@ public class MauriceMoss implements VmManager {
|
|||
@Inject(adapter=DeploymentPlanner.class)
|
||||
private Adapters<DeploymentPlanner> _planners;
|
||||
|
||||
Map<VirtualMachine.Type, VirtualMachineGuru<? extends VMInstanceVO>> _vmGurus = new HashMap<VirtualMachine.Type, VirtualMachineGuru<? extends VMInstanceVO>>();
|
||||
|
||||
private int _retry;
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> void registerGuru(VirtualMachine.Type type, VirtualMachineGuru<T> guru) {
|
||||
synchronized(_vmGurus) {
|
||||
_vmGurus.put(type, guru);
|
||||
}
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
public <T extends VMInstanceVO> VirtualMachineProfile allocate(T vm,
|
||||
VMTemplateVO template,
|
||||
|
|
@ -212,7 +222,7 @@ public class MauriceMoss implements VmManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> T start(T vm, DeploymentPlan plan, Account acct, VirtualMachineGuru<T> guru) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
|
||||
public <T extends VMInstanceVO> T start(T vm, DeploymentPlan plan, Account acct) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
|
||||
State state = vm.getState();
|
||||
if (state == State.Starting || state == State.Running) {
|
||||
s_logger.debug("VM is already started: " + vm);
|
||||
|
|
@ -286,6 +296,10 @@ public class MauriceMoss implements VmManager {
|
|||
|
||||
Commands cmds = new Commands(OnError.Revert);
|
||||
cmds.addCommand(new Start2Command(vmTO));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
VirtualMachineGuru<T> guru = (VirtualMachineGuru<T>)_vmGurus.get(vm.getType());
|
||||
|
||||
if (guru != null) {
|
||||
guru.finalizeDeployment(cmds, vm, vmProfile, dest);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2214,6 +2214,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
_executor = Executors.newScheduledThreadPool(wrks, new NamedThreadFactory("UserVm-Scavenger"));
|
||||
|
||||
_haMgr.registerHandler(Type.User, this);
|
||||
_itMgr.registerGuru(Type.User, this);
|
||||
|
||||
s_logger.info("User VM Manager is configured.");
|
||||
|
||||
|
|
@ -3897,7 +3898,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
|
||||
AccountVO owner = _accountDao.findById(vm.getAccountId());
|
||||
|
||||
return _itMgr.start(vm, plan, owner, this);
|
||||
return _itMgr.start(vm, plan, owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -3909,5 +3910,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
|||
public boolean processDeploymentResult(Commands cmds, UserVmVO vm, VirtualMachineProfile profile, DeployDestination dest) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UserVmVO persist(UserVmVO vm) {
|
||||
return _vmDao.persist(vm);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ import com.cloud.deploy.DeployDestination;
|
|||
*
|
||||
*/
|
||||
public interface VirtualMachineGuru<T extends VMInstanceVO> {
|
||||
T persist(T vm);
|
||||
|
||||
/**
|
||||
* finalize the virtual machine deployment.
|
||||
* @param cmds commands that were created.
|
||||
|
|
|
|||
|
|
@ -63,10 +63,12 @@ public interface VmManager extends Manager {
|
|||
DeploymentPlan plan,
|
||||
Account owner) throws InsufficientCapacityException, StorageUnavailableException;
|
||||
|
||||
<T extends VMInstanceVO> T start(T vm, DeploymentPlan plan, Account user, VirtualMachineGuru<T> checker) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException, ResourceUnavailableException;
|
||||
<T extends VMInstanceVO> T start(T vm, DeploymentPlan plan, Account user) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
<T extends VMInstanceVO> T stop(T vm) throws AgentUnavailableException, ConcurrentOperationException;
|
||||
|
||||
void destroy();
|
||||
|
||||
<T extends VMInstanceVO> void registerGuru(VirtualMachine.Type type, VirtualMachineGuru<T> guru);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue