bug 11716: save VMware local datastore info to local storage to support multiple local datastores per host situation

This commit is contained in:
Kelven Yang 2011-10-14 17:13:10 -07:00
parent 762890f58e
commit faa3622187
3 changed files with 18 additions and 3 deletions

View File

@ -3084,9 +3084,9 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
DatastoreSummary dsSummary = dsMo.getSummary();
String address = hostMo.getHostName();
StoragePoolInfo pInfo = new StoragePoolInfo(poolUuid, address, "", "", StoragePoolType.LVM, dsSummary.getCapacity(), dsSummary.getFreeSpace());
StoragePoolInfo pInfo = new StoragePoolInfo(poolUuid, address, dsMo.getMor().get_value(), "", StoragePoolType.LVM, dsSummary.getCapacity(), dsSummary.getFreeSpace());
StartupStorageCommand cmd = new StartupStorageCommand();
cmd.setName(poolUuid + "@" + hostMo.getHostName());
cmd.setName(poolUuid);
cmd.setPoolInfo(pInfo);
cmd.setGuid(poolUuid); // give storage host the same UUID as the local storage pool itself
cmd.setResourceType(Storage.StorageResourceType.STORAGE_POOL);

View File

@ -228,6 +228,10 @@ public class StoragePoolVO implements StoragePool {
this.uuid = uuid;
}
public void setPath(String path) {
this.path = path;
}
@Override
public int getPort() {
return port;

View File

@ -30,6 +30,7 @@ import com.cloud.agent.api.StoragePoolInfo;
import com.cloud.exception.ConnectionException;
import com.cloud.host.HostVO;
import com.cloud.host.Status;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.dao.StoragePoolDao;
import com.cloud.storage.dao.StoragePoolHostDao;
import com.cloud.utils.component.Inject;
@ -83,7 +84,17 @@ public class LocalStoragePoolListener implements Listener {
try {
StoragePoolVO pool = _storagePoolDao.findPoolByHostPath(host.getDataCenterId(), host.getPodId(), pInfo.getHost(), pInfo.getHostPath(), pInfo.getUuid());
if(pool == null && host.getHypervisorType() == HypervisorType.VMware) {
// perform run-time upgrade. In versions prior to 2.2.12, there is a bug that we don't save local datastore info (host path is empty), this will cause us
// not able to distinguish multiple local datastores that may be available on the host, to support smooth migration, we
// need to perform runtime upgrade here
if(pInfo.getHostPath().length() > 0) {
pool = _storagePoolDao.findPoolByHostPath(host.getDataCenterId(), host.getPodId(), pInfo.getHost(), "", pInfo.getUuid());
}
}
if (pool == null) {
long poolId = _storagePoolDao.getNextInSequence(Long.class, "id");
String name = cmd.getName() == null ? (host.getName() + " Local Storage") : cmd.getName();
Transaction txn = Transaction.currentTxn();
@ -99,6 +110,7 @@ public class LocalStoragePoolListener implements Listener {
} else {
Transaction txn = Transaction.currentTxn();
txn.start();
pool.setPath(pInfo.getHostPath());
pool.setAvailableBytes(pInfo.getAvailableBytes());
pool.setCapacityBytes(pInfo.getCapacityBytes());
_storagePoolDao.update(pool.getId(), pool);
@ -117,7 +129,6 @@ public class LocalStoragePoolListener implements Listener {
throw new ConnectionException(true, "Unable to setup the local storage pool for " + host, e);
}
}
@Override