bug 9643: propagate fix from 2.2.4

This commit is contained in:
Alex Huang 2011-04-29 17:51:42 -07:00
parent 44263a161c
commit 6ce656220f
7 changed files with 49 additions and 57 deletions

View File

@ -796,7 +796,6 @@ public class ApiResponseHelper implements ResponseGenerator {
volResponse.setVirtualMachineName(vm.getHostName());
UserVm userVm = ApiDBUtils.findUserVmById(vm.getId());
volResponse.setVirtualMachineDisplayName(userVm.getDisplayName());
volResponse.setVirtualMachineState(vm.getState().toString());
}

View File

@ -901,8 +901,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
private boolean reserveStandbyCapacity() {
ConsoleProxyManagementState state = getManagementState();
if (state == null || state != ConsoleProxyManagementState.Auto)
if (state == null || state != ConsoleProxyManagementState.Auto) {
return false;
}
return true;
}
@ -1633,13 +1634,15 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
long dataCenterId = pool.longValue();
if (!isZoneReady(_zoneHostInfoMap, dataCenterId)) {
if (s_logger.isDebugEnabled())
if (s_logger.isDebugEnabled()) {
s_logger.debug("Zone " + dataCenterId + " is not ready to launch console proxy yet");
}
return false;
}
if (s_logger.isDebugEnabled())
if (s_logger.isDebugEnabled()) {
s_logger.debug("Zone " + dataCenterId + " is ready to launch console proxy");
}
return true;
}
@ -1648,16 +1651,19 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
long dataCenterId = pool.longValue();
ConsoleProxyLoadInfo proxyInfo = this._zoneProxyCountMap.get(dataCenterId);
if (proxyInfo == null)
if (proxyInfo == null) {
return new Pair<AfterScanAction, Object>(AfterScanAction.nop, null);
}
ConsoleProxyLoadInfo vmInfo = this._zoneVmCountMap.get(dataCenterId);
if (vmInfo == null)
if (vmInfo == null) {
vmInfo = new ConsoleProxyLoadInfo();
}
if (!checkCapacity(proxyInfo, vmInfo)) {
if (s_logger.isDebugEnabled())
if (s_logger.isDebugEnabled()) {
s_logger.debug("Expand console proxy standby capacity for zone " + proxyInfo.getName());
}
return new Pair<AfterScanAction, Object>(AfterScanAction.expand, null);
}

View File

@ -376,7 +376,6 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager, Clu
break;
}
}
boolean fenced = false;
if (alive == null) {
s_logger.debug("Fencing off VM that we don't know the state of");

View File

@ -4467,8 +4467,9 @@ public class ManagementServerImpl implements ManagementServer {
@Override
@DB
public String uploadCertificate(UploadCustomCertificateCmd cmd) {
if (!_ksMgr.validateCertificate(cmd.getCertificate(), cmd.getPrivateKey(), cmd.getDomainSuffix()))
if (!_ksMgr.validateCertificate(cmd.getCertificate(), cmd.getPrivateKey(), cmd.getDomainSuffix())) {
throw new InvalidParameterValueException("Failed to pass certificate validation check");
}
_ksMgr.saveCertificate(ConsoleProxyManager.CERTIFICATE_NAME, cmd.getCertificate(), cmd.getPrivateKey(), cmd.getDomainSuffix());

View File

@ -17,30 +17,30 @@
*/
package com.cloud.storage;
import java.util.List;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
import com.cloud.agent.manager.Commands;
import com.cloud.capacity.CapacityVO;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
import com.cloud.deploy.DeployDestination;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientStorageCapacityException;
import com.cloud.exception.StorageUnavailableException;
import com.cloud.host.Host;
import com.cloud.host.HostVO;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.storage.Volume.Type;
import com.cloud.user.Account;
import com.cloud.utils.Pair;
import com.cloud.utils.component.Manager;
import com.cloud.vm.DiskProfile;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;
import java.util.List;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
import com.cloud.agent.manager.Commands;
import com.cloud.capacity.CapacityVO;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
import com.cloud.deploy.DeployDestination;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientStorageCapacityException;
import com.cloud.exception.StorageUnavailableException;
import com.cloud.host.Host;
import com.cloud.host.HostVO;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.storage.Volume.Type;
import com.cloud.user.Account;
import com.cloud.utils.Pair;
import com.cloud.utils.component.Manager;
import com.cloud.vm.DiskProfile;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;
public interface StorageManager extends Manager {
boolean canVmRestartOnAnotherServer(long vmId);
@ -73,14 +73,6 @@ public interface StorageManager extends Manager {
*/
public HostVO getSecondaryStorageHost(long zoneId);
/**
* Add a pool to a host
* @param hostId
* @param pool
* @throws StorageUnavailableException
*/
void addPoolToHost(long hostId, StoragePoolVO pool) throws StorageUnavailableException;
/**
* Moves a volume from its current storage pool to a storage pool with enough capacity in the specified zone, pod, or cluster
* @param volume

View File

@ -809,7 +809,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
_storagePoolAcquisitionWaitSeconds = NumbersUtil.parseInt(configs.get("pool.acquisition.wait.seconds"), 1800);
s_logger.info("pool.acquisition.wait.seconds is configured as " + _storagePoolAcquisitionWaitSeconds + " seconds");
_agentMgr.registerForHostEvents(new StoragePoolMonitor(this, _hostDao, _storagePoolDao), true, false, true);
_agentMgr.registerForHostEvents(new StoragePoolMonitor(this, _storagePoolDao), true, false, true);
String storageCleanupEnabled = configs.get("storage.cleanup.enabled");
_storageCleanupEnabled = (storageCleanupEnabled == null) ? true : Boolean.parseBoolean(storageCleanupEnabled);
@ -1171,7 +1171,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
List<HostVO> poolHosts = new ArrayList<HostVO>();
for (HostVO h : allHosts) {
try {
addPoolToHost(h.getId(), pool);
connectHostToSharedPool(h.getId(), pool);
poolHosts.add(h);
} catch (Exception e) {
s_logger.warn("Unable to establish a connection between " + h + " and " + pool, e);
@ -1375,14 +1375,9 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
return true;
}
@Override
public void addPoolToHost(long hostId, StoragePoolVO pool) throws StorageUnavailableException {
public void connectHostToSharedPool(long hostId, StoragePoolVO pool) throws StorageUnavailableException {
assert (pool.getPoolType().isShared()) : "Now, did you actually read the name of this method?";
s_logger.debug("Adding pool " + pool.getName() + " to host " + hostId);
if (pool.getPoolType() != StoragePoolType.NetworkFilesystem && pool.getPoolType() != StoragePoolType.Filesystem && pool.getPoolType() != StoragePoolType.IscsiLUN
&& pool.getPoolType() != StoragePoolType.Iscsi && pool.getPoolType() != StoragePoolType.VMFS && pool.getPoolType() != StoragePoolType.SharedMountPoint
&& pool.getPoolType() != StoragePoolType.PreSetup) {
throw new CloudRuntimeException("Doesn't support storage pool type " + pool.getPoolType());
}
ModifyStoragePoolCommand cmd = new ModifyStoragePoolCommand(true, pool);
final Answer answer = _agentMgr.easySend(hostId, cmd);

View File

@ -31,21 +31,18 @@ import com.cloud.agent.api.StartupRoutingCommand;
import com.cloud.exception.ConnectionException;
import com.cloud.host.HostVO;
import com.cloud.host.Status;
import com.cloud.host.dao.HostDao;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.StorageManager;
import com.cloud.storage.StorageManagerImpl;
import com.cloud.storage.StoragePoolVO;
import com.cloud.storage.dao.StoragePoolDao;
public class StoragePoolMonitor implements Listener {
private static final Logger s_logger = Logger.getLogger(StoragePoolMonitor.class);
private final HostDao _hostDao;
private final StorageManager _storageManager;
private final StorageManagerImpl _storageManager;
private final StoragePoolDao _poolDao;
public StoragePoolMonitor(StorageManager mgr, HostDao hostDao, StoragePoolDao poolDao) {
public StoragePoolMonitor(StorageManagerImpl mgr, StoragePoolDao poolDao) {
this._storageManager = mgr;
this._hostDao = hostDao;
this._poolDao = poolDao;
}
@ -74,10 +71,13 @@ public class StoragePoolMonitor implements Listener {
scCmd.getHypervisorType() == HypervisorType.VMware) {
List<StoragePoolVO> pools = _poolDao.listBy(host.getDataCenterId(), host.getPodId(), host.getClusterId());
for (StoragePoolVO pool : pools) {
if (!pool.getPoolType().isShared()) {
continue;
}
Long hostId = host.getId();
s_logger.debug("Host " + hostId + " connected, sending down storage pool information ...");
try {
_storageManager.addPoolToHost(hostId, pool);
_storageManager.connectHostToSharedPool(hostId, pool);
_storageManager.createCapacityEntry(pool);
} catch (Exception e) {
throw new ConnectionException(true, "Unable to connect to pool " + pool, e);