mirror of https://github.com/apache/cloudstack.git
merge changes
This commit is contained in:
parent
2c42ebbf71
commit
9bae18d915
|
|
@ -36,7 +36,9 @@ import com.cloud.agent.api.GetVncPortCommand;
|
|||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.agent.api.StartupProxyCommand;
|
||||
import com.cloud.agent.api.StopCommand;
|
||||
import com.cloud.agent.manager.Commands;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
|
|
@ -51,17 +53,19 @@ import com.cloud.utils.NumbersUtil;
|
|||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.vm.ConsoleProxyVO;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine.Type;
|
||||
import com.cloud.vm.VirtualMachineManager;
|
||||
import com.cloud.vm.VirtualMachineGuru;
|
||||
import com.cloud.vm.VirtualMachineName;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.cloud.vm.dao.ConsoleProxyDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
@Local(value = { ConsoleProxyManager.class })
|
||||
public class AgentBasedConsoleProxyManager implements ConsoleProxyManager, VirtualMachineManager<ConsoleProxyVO>, AgentHook {
|
||||
public class AgentBasedConsoleProxyManager implements ConsoleProxyManager, VirtualMachineGuru<ConsoleProxyVO>, AgentHook {
|
||||
private static final Logger s_logger = Logger.getLogger(AgentBasedConsoleProxyManager.class);
|
||||
|
||||
private String _name;
|
||||
|
|
@ -92,8 +96,9 @@ public class AgentBasedConsoleProxyManager implements ConsoleProxyManager, Virtu
|
|||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
|
||||
if (s_logger.isInfoEnabled())
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Start configuring AgentBasedConsoleProxyManager");
|
||||
}
|
||||
|
||||
_name = name;
|
||||
|
||||
|
|
@ -105,16 +110,19 @@ public class AgentBasedConsoleProxyManager implements ConsoleProxyManager, Virtu
|
|||
|
||||
Map<String, String> configs = configDao.getConfiguration("management-server", params);
|
||||
String value = configs.get("consoleproxy.url.port");
|
||||
if (value != null)
|
||||
if (value != null) {
|
||||
_consoleProxyUrlPort = NumbersUtil.parseInt(value, ConsoleProxyManager.DEFAULT_PROXY_URL_PORT);
|
||||
}
|
||||
|
||||
value = configs.get("consoleproxy.port");
|
||||
if (value != null)
|
||||
if (value != null) {
|
||||
_consoleProxyPort = NumbersUtil.parseInt(value, ConsoleProxyManager.DEFAULT_PROXY_VNC_PORT);
|
||||
}
|
||||
|
||||
value = configs.get("consoleproxy.sslEnabled");
|
||||
if (value != null && value.equalsIgnoreCase("true"))
|
||||
if (value != null && value.equalsIgnoreCase("true")) {
|
||||
_sslEnabled = true;
|
||||
}
|
||||
|
||||
_instance = configs.get("instance.name");
|
||||
|
||||
|
|
@ -126,8 +134,9 @@ public class AgentBasedConsoleProxyManager implements ConsoleProxyManager, Virtu
|
|||
HighAvailabilityManager haMgr = locator.getManager(HighAvailabilityManager.class);
|
||||
haMgr.registerHandler(Type.ConsoleProxy, this);
|
||||
|
||||
if (s_logger.isInfoEnabled())
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("AgentBasedConsoleProxyManager has been configured. SSL enabled: " + _sslEnabled);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -155,24 +164,27 @@ public class AgentBasedConsoleProxyManager implements ConsoleProxyManager, Virtu
|
|||
|
||||
HostVO host = findHost(userVm);
|
||||
if (host != null) {
|
||||
if (s_logger.isDebugEnabled())
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Assign embedded console proxy running at " + host.getName() + " to user vm " + userVmId + " with public IP "
|
||||
+ host.getPublicIpAddress());
|
||||
}
|
||||
|
||||
// only private IP, public IP, host id have meaningful values, rest
|
||||
// of all are place-holder values
|
||||
String publicIp = host.getPublicIpAddress();
|
||||
if (publicIp == null) {
|
||||
if (s_logger.isDebugEnabled())
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Host " + host.getName() + "/" + host.getPrivateIpAddress()
|
||||
+ " does not have public interface, we will return its private IP for cosole proxy.");
|
||||
}
|
||||
publicIp = host.getPrivateIpAddress();
|
||||
}
|
||||
|
||||
int urlPort = _consoleProxyUrlPort;
|
||||
|
||||
if (host.getProxyPort() != null && host.getProxyPort().intValue() > 0)
|
||||
if (host.getProxyPort() != null && host.getProxyPort().intValue() > 0) {
|
||||
urlPort = host.getProxyPort().intValue();
|
||||
}
|
||||
|
||||
return new ConsoleProxyInfo(_sslEnabled, publicIp, _consoleProxyPort, urlPort, _consoleProxyUrlDomain);
|
||||
} else {
|
||||
|
|
@ -190,8 +202,9 @@ public class AgentBasedConsoleProxyManager implements ConsoleProxyManager, Virtu
|
|||
long vmId = 0;
|
||||
|
||||
if (cmd.getVmId() != null && cmd.getVmId().isEmpty()) {
|
||||
if (s_logger.isTraceEnabled())
|
||||
if (s_logger.isTraceEnabled()) {
|
||||
s_logger.trace("Invalid vm id sent from proxy(happens when proxy session has terminated)");
|
||||
}
|
||||
return new ConsoleAccessAuthenticationAnswer(cmd, false);
|
||||
}
|
||||
|
||||
|
|
@ -325,5 +338,47 @@ public class AgentBasedConsoleProxyManager implements ConsoleProxyManager, Virtu
|
|||
public boolean applyCustomCertToNewProxy(StartupProxyCommand cmd) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConsoleProxyVO findByName(String name) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConsoleProxyVO findById(long id) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConsoleProxyVO persist(ConsoleProxyVO vm) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<ConsoleProxyVO> profile, DeployDestination dest, ReservationContext context) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile<ConsoleProxyVO> profile, DeployDestination dest, ReservationContext context) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean finalizeStart(Commands cmds, VirtualMachineProfile<ConsoleProxyVO> profile, DeployDestination dest, ReservationContext context) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finalizeStop(VirtualMachineProfile<ConsoleProxyVO> profile, long hostId, String reservationId) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import com.cloud.host.Status;
|
|||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineManager;
|
||||
import com.cloud.vm.VirtualMachineGuru;
|
||||
|
||||
/**
|
||||
* HighAvailabilityManager checks to make sure the VMs are running fine.
|
||||
|
|
@ -84,7 +84,7 @@ public interface HighAvailabilityManager extends Manager {
|
|||
* @param type virtual machine type.
|
||||
* @param handler handler that can handle starting and stopping the machine.
|
||||
*/
|
||||
void registerHandler(final VirtualMachine.Type type, final VirtualMachineManager<? extends VMInstanceVO> handler);
|
||||
void registerHandler(final VirtualMachine.Type type, final VirtualMachineGuru<? extends VMInstanceVO> handler);
|
||||
|
||||
/**
|
||||
* Unregisters a handler. Not likely called but here for completeness.
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ import javax.naming.ConfigurationException;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.MigrateCommand;
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.alert.AlertManager;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
|
|
@ -70,7 +70,7 @@ import com.cloud.vm.State;
|
|||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.Event;
|
||||
import com.cloud.vm.VirtualMachineManager;
|
||||
import com.cloud.vm.VirtualMachineGuru;
|
||||
import com.cloud.vm.VmManager;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
|
|
@ -141,7 +141,7 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager {
|
|||
int _migrateRetryInterval;
|
||||
int _restartRetryInterval;
|
||||
|
||||
HashMap<VirtualMachine.Type, VirtualMachineManager<VMInstanceVO>> _handlers;
|
||||
HashMap<VirtualMachine.Type, VirtualMachineGuru<VMInstanceVO>> _handlers;
|
||||
|
||||
int _maxRetries;
|
||||
long _timeBetweenFailures;
|
||||
|
|
@ -149,7 +149,7 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager {
|
|||
boolean _forceHA;
|
||||
|
||||
protected HighAvailabilityManagerImpl() {
|
||||
_handlers = new HashMap<VirtualMachine.Type, VirtualMachineManager<VMInstanceVO>>(11);
|
||||
_handlers = new HashMap<VirtualMachine.Type, VirtualMachineGuru<VMInstanceVO>>(11);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -240,9 +240,9 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public synchronized void registerHandler(final VirtualMachine.Type type, final VirtualMachineManager<? extends VMInstanceVO> handler) {
|
||||
public synchronized void registerHandler(final VirtualMachine.Type type, final VirtualMachineGuru<? extends VMInstanceVO> handler) {
|
||||
s_logger.info("Registering " + handler.getClass().getSimpleName() + " as the handler for " + type);
|
||||
_handlers.put(type, (VirtualMachineManager<VMInstanceVO>)handler);
|
||||
_handlers.put(type, (VirtualMachineGuru<VMInstanceVO>)handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -267,7 +267,7 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager {
|
|||
@Override
|
||||
public void scheduleRestart(VMInstanceVO vm, final boolean investigate) {
|
||||
Long hostId = vm.getHostId();
|
||||
VirtualMachineManager<VMInstanceVO> mgr = findManager(vm.getType());
|
||||
VirtualMachineGuru<VMInstanceVO> mgr = findManager(vm.getType());
|
||||
vm = mgr.get(vm.getId());
|
||||
if (!investigate) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
|
|
@ -317,14 +317,14 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager {
|
|||
wakeupWorkers();
|
||||
}
|
||||
|
||||
protected VirtualMachineManager<VMInstanceVO> findManager(final VirtualMachine.Type type) {
|
||||
protected VirtualMachineGuru<VMInstanceVO> findManager(final VirtualMachine.Type type) {
|
||||
return _handlers.get(type);
|
||||
}
|
||||
|
||||
protected Long restart(final HaWorkVO work) {
|
||||
final long vmId = work.getInstanceId();
|
||||
|
||||
final VirtualMachineManager<VMInstanceVO> mgr = findManager(work.getType());
|
||||
final VirtualMachineGuru<VMInstanceVO> mgr = findManager(work.getType());
|
||||
if (mgr == null) {
|
||||
s_logger.warn("Unable to find a handler for " + work.getType().toString() + ", throwing out " + vmId);
|
||||
return null;
|
||||
|
|
@ -636,10 +636,10 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager {
|
|||
return map;
|
||||
}
|
||||
|
||||
final Collection<VirtualMachineManager<VMInstanceVO>> handlers = _handlers.values();
|
||||
final Collection<VirtualMachineGuru<VMInstanceVO>> handlers = _handlers.values();
|
||||
|
||||
for (final Map.Entry<String, State> entry : states.entrySet()) {
|
||||
for (final VirtualMachineManager<VMInstanceVO> handler : handlers) {
|
||||
for (final VirtualMachineGuru<VMInstanceVO> handler : handlers) {
|
||||
final String name = entry.getKey();
|
||||
|
||||
final Long id = handler.convertToId(name);
|
||||
|
|
@ -682,7 +682,7 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager {
|
|||
public Long migrate(final HaWorkVO work) {
|
||||
final long vmId = work.getInstanceId();
|
||||
|
||||
final VirtualMachineManager<VMInstanceVO> mgr = findManager(work.getType());
|
||||
final VirtualMachineGuru<VMInstanceVO> mgr = findManager(work.getType());
|
||||
|
||||
VMInstanceVO vm = mgr.get(vmId);
|
||||
if (vm == null || vm.getRemoved() != null) {
|
||||
|
|
@ -827,7 +827,7 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager {
|
|||
}
|
||||
|
||||
protected Long destroyVM(HaWorkVO work) {
|
||||
final VirtualMachineManager<VMInstanceVO> mgr = findManager(work.getType());
|
||||
final VirtualMachineGuru<VMInstanceVO> mgr = findManager(work.getType());
|
||||
final VMInstanceVO vm = mgr.get(work.getInstanceId());
|
||||
s_logger.info("Destroying " + vm.toString());
|
||||
try {
|
||||
|
|
@ -864,7 +864,7 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager {
|
|||
}
|
||||
|
||||
protected Long stopVM(final HaWorkVO work) {
|
||||
final VirtualMachineManager<VMInstanceVO> mgr = findManager(work.getType());
|
||||
final VirtualMachineGuru<VMInstanceVO> mgr = findManager(work.getType());
|
||||
final VMInstanceVO vm = mgr.get(work.getInstanceId());
|
||||
s_logger.info("Stopping " + vm.toString());
|
||||
try {
|
||||
|
|
@ -931,47 +931,6 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager {
|
|||
_name = name;
|
||||
ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
|
||||
|
||||
/*
|
||||
_haDao = locator.getDao(HighAvailabilityDao.class);
|
||||
if (_haDao == null) {
|
||||
throw new ConfigurationException("Unable to get ha dao");
|
||||
}
|
||||
|
||||
_instanceDao = locator.getDao(VMInstanceDao.class);
|
||||
if (_instanceDao == null) {
|
||||
throw new ConfigurationException("Unable to get vm dao");
|
||||
}
|
||||
|
||||
_hostDao = locator.getDao(HostDao.class);
|
||||
if (_hostDao == null) {
|
||||
throw new ConfigurationException("unable to get host dao");
|
||||
}
|
||||
|
||||
_dcDao = locator.getDao(DataCenterDao.class);
|
||||
if (_dcDao == null) {
|
||||
throw new ConfigurationException("unable to get data center dao");
|
||||
}
|
||||
|
||||
_podDao = locator.getDao(HostPodDao.class);
|
||||
if (_podDao == null) {
|
||||
throw new ConfigurationException("unable to get pod dao");
|
||||
}
|
||||
|
||||
_agentMgr = locator.getManager(AgentManager.class);
|
||||
if (_agentMgr == null) {
|
||||
throw new ConfigurationException("Unable to find " + AgentManager.class.getName());
|
||||
}
|
||||
|
||||
_alertMgr = locator.getManager(AlertManager.class);
|
||||
if (_alertMgr == null) {
|
||||
throw new ConfigurationException("Unable to find " + AlertManager.class.getName());
|
||||
}
|
||||
|
||||
_storageMgr = locator.getManager(StorageManager.class);
|
||||
if (_storageMgr == null) {
|
||||
throw new ConfigurationException("Unable to find " + StorageManager.class.getName());
|
||||
}
|
||||
*/
|
||||
_serverId = ((ManagementServer)ComponentLocator.getComponent(ManagementServer.Name)).getId();
|
||||
|
||||
_investigators = locator.getAdapters(Investigator.class);
|
||||
|
|
@ -1188,11 +1147,11 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager {
|
|||
|
||||
protected class AgentVmInfo {
|
||||
public String name;
|
||||
public VirtualMachineManager mgr;
|
||||
public VirtualMachineGuru<VMInstanceVO> mgr;
|
||||
public State state;
|
||||
public State action;
|
||||
|
||||
public AgentVmInfo(final String name, final VirtualMachineManager handler, final State state) {
|
||||
public AgentVmInfo(final String name, final VirtualMachineGuru<VMInstanceVO> handler, final State state) {
|
||||
this.name = name;
|
||||
this.mgr = handler;
|
||||
this.state = state;
|
||||
|
|
|
|||
|
|
@ -58,9 +58,9 @@ import com.cloud.configuration.ResourceCount.ResourceType;
|
|||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.configuration.dao.ResourceLimitDao;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.Vlan;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.Vlan.VlanType;
|
||||
import com.cloud.dc.VlanVO;
|
||||
import com.cloud.dc.dao.AccountVlanMapDao;
|
||||
|
|
@ -980,7 +980,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
if (state == Network.State.Implemented || state == Network.State.Setup) {
|
||||
if (state == Network.State.Setup) {
|
||||
config.setState(Network.State.Implemented);
|
||||
_networkConfigDao.update(configId, config);
|
||||
_networksDao.update(networkId, config);
|
||||
}
|
||||
implemented.set(guru, config);
|
||||
return implemented;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import com.cloud.exception.ConcurrentOperationException;
|
|||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InsufficientNetworkCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
|
|
@ -41,7 +42,6 @@ import com.cloud.offering.NetworkOffering.GuestIpType;
|
|||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.net.Ip;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
|
|
@ -140,12 +140,12 @@ public class DhcpElement extends AdapterBase implements NetworkElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean associate(Network network, Ip ipAddress) throws ResourceUnavailableException {
|
||||
public boolean associate(Network network, List<? extends IpAddress> ipAddress) throws ResourceUnavailableException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disassociate(Network network, Ip ipAddress) throws ResourceUnavailableException {
|
||||
public boolean disassociate(Network network, List<? extends IpAddress> ipAddress) throws ResourceUnavailableException {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2150,7 +2150,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
|
|||
|
||||
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmControlNetwork);
|
||||
NetworkOfferingVO controlOffering = offerings.get(0);
|
||||
NetworkVO controlConfig = _networkMgr.setupNetworkConfiguration(_systemAcct, controlOffering, plan, null, null, false).get(0);
|
||||
NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false).get(0);
|
||||
|
||||
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(3);
|
||||
NicProfile gatewayNic = new NicProfile();
|
||||
|
|
|
|||
|
|
@ -17,8 +17,17 @@
|
|||
*/
|
||||
package com.cloud.vm;
|
||||
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.manager.Commands;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.utils.exception.ExecutionException;
|
||||
|
||||
/**
|
||||
* A VirtualMachineGuru knows how to process a certain type of virtual machine.
|
||||
|
|
@ -57,4 +66,85 @@ public interface VirtualMachineGuru<T extends VirtualMachine> {
|
|||
boolean finalizeStart(Commands cmds, VirtualMachineProfile<T> profile, DeployDestination dest, ReservationContext context);
|
||||
|
||||
void finalizeStop(VirtualMachineProfile<T> profile, long hostId, String reservationId);
|
||||
/**
|
||||
* Returns the id parsed from the name. If it cannot parse the name,
|
||||
* then return null. This method is used to determine if this is
|
||||
* the right handler for this vm.
|
||||
*
|
||||
* @param vmName vm name coming form the agent.
|
||||
* @return id if the handler works for this vm and can parse id. null if not.
|
||||
*/
|
||||
Long convertToId(String vmName);
|
||||
|
||||
/**
|
||||
* Retrieves the vm based on the id given.
|
||||
*
|
||||
* @param id id of the vm.
|
||||
* @return VMInstanceVO
|
||||
*/
|
||||
T get(long id);
|
||||
|
||||
/**
|
||||
* Complete the start command. HA calls this when it determines that
|
||||
* a vm was starting but the state was not complete.
|
||||
*
|
||||
* @param vm vm to execute this on.
|
||||
*/
|
||||
void completeStartCommand(T vm);
|
||||
|
||||
/**
|
||||
* Complete the stop command. HA calls this when it determines that
|
||||
* a vm was being stopped but it didn't complete.
|
||||
*
|
||||
* @param vm vm to stop.
|
||||
*/
|
||||
void completeStopCommand(T vm);
|
||||
|
||||
/**
|
||||
* start the vm
|
||||
*
|
||||
* @param vm to start.
|
||||
* @return true if started. false if not.
|
||||
* @throws InsufficientCapacityException if there's not enough capacity to start the vm.
|
||||
* @throws StorageUnavailableException if the storage is unavailable.
|
||||
* @throws ConcurrentOperationException there's multiple threads working on this vm.
|
||||
* @throws ExecutionException
|
||||
* @throws ResourceUnavailableException
|
||||
*/
|
||||
T start(long vmId, long startEventId) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException, ExecutionException;
|
||||
|
||||
/**
|
||||
* stop the vm
|
||||
*
|
||||
* @param vm vm to Stop.
|
||||
* @return true if stopped and false if not.
|
||||
* @throws AgentUnavailableException if the agent is unavailable.
|
||||
*/
|
||||
boolean stop(T vm, long startEventId) throws AgentUnavailableException;
|
||||
|
||||
/**
|
||||
* Produce a cleanup command to be sent to the agent to cleanup anything
|
||||
* out of the ordinary.
|
||||
* @param vm vm to cleanup. It's possible this is null.
|
||||
* @param vmName name of the vm from the agent.
|
||||
* @return Command to clean it up. If not cleanup is needed, then return null.
|
||||
*/
|
||||
Command cleanup(T vm, String vmName);
|
||||
|
||||
/**
|
||||
* Prepare for migration.
|
||||
*
|
||||
* @param vm vm to migrate.
|
||||
* @return HostVO if a host is found.
|
||||
*/
|
||||
HostVO prepareForMigration(T vm) throws InsufficientCapacityException, StorageUnavailableException;
|
||||
|
||||
/**
|
||||
* Migrate the vm.
|
||||
*/
|
||||
boolean migrate(T vm, HostVO host) throws AgentUnavailableException, OperationTimedoutException;
|
||||
|
||||
boolean completeMigration(T vm, HostVO host) throws AgentUnavailableException, OperationTimedoutException;
|
||||
|
||||
boolean destroy(T vm) throws AgentUnavailableException;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue