mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
vmware: support vmfs as local storage pool type
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
b34202a84e
commit
752d784d92
@ -22,6 +22,7 @@ import com.cloud.utils.db.TransactionLegacy;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.script.Script;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jasypt.exceptions.EncryptionOperationNotPossibleException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@ -75,6 +76,7 @@ public class Upgrade450to451 implements DbUpgrade {
|
||||
encryptIpSecPresharedKeysOfRemoteAccessVpn(conn);
|
||||
encryptStoragePoolUserInfo(conn);
|
||||
updateUserVmDetailsWithNicAdapterType(conn);
|
||||
upgradeVMWareLocalStorage(conn);
|
||||
}
|
||||
|
||||
private void encryptKeyInKeyStore(Connection conn) {
|
||||
@ -85,9 +87,11 @@ public class Upgrade450to451 implements DbUpgrade {
|
||||
selectStatement = conn.prepareStatement("SELECT ks.id, ks.key FROM cloud.keystore ks WHERE ks.key IS NOT null");
|
||||
selectResultSet = selectStatement.executeQuery();
|
||||
while (selectResultSet.next()) {
|
||||
Long keyId = selectResultSet.getLong(1);
|
||||
String preSharedKey = selectResultSet.getString(2);
|
||||
updateStatement = conn.prepareStatement("UPDATE cloud.keystore ks SET ks.key = ? WHERE ks.id = ?");
|
||||
updateStatement.setString(1, DBEncryptionUtil.encrypt(selectResultSet.getString(2)));
|
||||
updateStatement.setLong(2, selectResultSet.getLong(1));
|
||||
updateStatement.setString(1, DBEncryptionUtil.encrypt(preSharedKey));
|
||||
updateStatement.setLong(2, keyId);
|
||||
updateStatement.executeUpdate();
|
||||
updateStatement.close();
|
||||
}
|
||||
@ -121,10 +125,16 @@ public class Upgrade450to451 implements DbUpgrade {
|
||||
selectStatement = conn.prepareStatement("SELECT id, ipsec_psk FROM `cloud`.`remote_access_vpn`");
|
||||
resultSet = selectStatement.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
Long rowId = resultSet.getLong(1);
|
||||
String preSharedKey = resultSet.getString(2);
|
||||
try {
|
||||
preSharedKey = DBEncryptionUtil.decrypt(preSharedKey);
|
||||
} catch (EncryptionOperationNotPossibleException ignored) {
|
||||
s_logger.debug("The ipsec_psk preshared key id=" + rowId + "in remote_access_vpn is not encrypted, encrypting it.");
|
||||
}
|
||||
updateStatement = conn.prepareStatement("UPDATE `cloud`.`remote_access_vpn` SET ipsec_psk=? WHERE id=?");
|
||||
updateStatement.setString(1, DBEncryptionUtil.encrypt(preSharedKey));
|
||||
updateStatement.setLong(2, resultSet.getLong(1));
|
||||
updateStatement.setLong(2, rowId);
|
||||
updateStatement.executeUpdate();
|
||||
updateStatement.close();
|
||||
}
|
||||
@ -193,4 +203,21 @@ public class Upgrade450to451 implements DbUpgrade {
|
||||
}
|
||||
s_logger.debug("Done. Updated user_vm_details table with nicAdapter entries by copying from vm_template_detail table. This affects only VM/templates with hypervisor_type as VMware.");
|
||||
}
|
||||
|
||||
private void upgradeVMWareLocalStorage(Connection conn) {
|
||||
PreparedStatement updatePstmt = null;
|
||||
try {
|
||||
updatePstmt = conn.prepareStatement("UPDATE storage_pool SET pool_type='VMFS',host_address=@newaddress WHERE (@newaddress:=concat('VMFS datastore: ', path)) IS NOT NULL AND scope = 'HOST' AND pool_type = 'LVM' AND id IN (SELECT * FROM (SELECT storage_pool.id FROM storage_pool,cluster WHERE storage_pool.cluster_id = cluster.id AND cluster.hypervisor_type='VMware') AS t);");
|
||||
updatePstmt.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("Unable to upgrade VMWare local storage pool type", e);
|
||||
} finally {
|
||||
try {
|
||||
if (updatePstmt != null)
|
||||
updatePstmt.close();
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
s_logger.debug("Done, upgraded VMWare local storage pool type to VMFS and host_address to the VMFS format");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -378,12 +378,22 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co
|
||||
//NOTE: the hostid can be a hypervisor host, or a ssvm agent. For copycommand, if it's for volume upload, the hypervisor
|
||||
//type is empty, so we need to check the format of volume at first.
|
||||
if (cmd instanceof CopyCommand) {
|
||||
CopyCommand cpyCommand = (CopyCommand)cmd;
|
||||
CopyCommand cpyCommand = (CopyCommand) cmd;
|
||||
DataTO srcData = cpyCommand.getSrcTO();
|
||||
DataStoreTO srcStoreTO = srcData.getDataStore();
|
||||
DataTO destData = cpyCommand.getDestTO();
|
||||
DataStoreTO destStoreTO = destData.getDataStore();
|
||||
|
||||
boolean inSeq = true;
|
||||
if ((srcData.getObjectType() == DataObjectType.SNAPSHOT) || (destData.getObjectType() == DataObjectType.SNAPSHOT)) {
|
||||
inSeq = false;
|
||||
} else if ((destStoreTO.getRole() == DataStoreRole.Image) || (destStoreTO.getRole() == DataStoreRole.ImageCache)) {
|
||||
inSeq = false;
|
||||
} else if (!VmwareFullClone.value()) {
|
||||
inSeq = false;
|
||||
}
|
||||
cpyCommand.setExecuteInSequence(inSeq);
|
||||
|
||||
if (srcData.getObjectType() == DataObjectType.VOLUME) {
|
||||
VolumeObjectTO volumeObjectTO = (VolumeObjectTO)srcData;
|
||||
if (Storage.ImageFormat.OVA == volumeObjectTO.getFormat()) {
|
||||
|
||||
@ -4194,7 +4194,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
DatastoreSummary dsSummary = dsMo.getSummary();
|
||||
String address = hostMo.getHostName();
|
||||
StoragePoolInfo pInfo =
|
||||
new StoragePoolInfo(poolUuid, address, dsMo.getMor().getValue(), "", StoragePoolType.LVM, dsSummary.getCapacity(), dsSummary.getFreeSpace());
|
||||
new StoragePoolInfo(poolUuid, address, dsMo.getMor().getValue(), "", StoragePoolType.VMFS, dsSummary.getCapacity(), dsSummary.getFreeSpace());
|
||||
StartupStorageCommand cmd = new StartupStorageCommand();
|
||||
cmd.setName(poolUuid);
|
||||
cmd.setPoolInfo(pInfo);
|
||||
|
||||
@ -41,6 +41,7 @@ import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -542,7 +543,11 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
||||
}
|
||||
DataStore store;
|
||||
try {
|
||||
StoragePoolVO pool = _storagePoolDao.findPoolByHostPath(host.getDataCenterId(), host.getPodId(), pInfo.getHost(), pInfo.getHostPath(), pInfo.getUuid());
|
||||
String hostAddress = pInfo.getHost();
|
||||
if (host.getHypervisorType() == Hypervisor.HypervisorType.VMware) {
|
||||
hostAddress = "VMFS datastore: " + pInfo.getHostPath();
|
||||
}
|
||||
StoragePoolVO pool = _storagePoolDao.findPoolByHostPath(host.getDataCenterId(), host.getPodId(), hostAddress, 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
|
||||
@ -551,12 +556,12 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
||||
// 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());
|
||||
pool = _storagePoolDao.findPoolByHostPath(host.getDataCenterId(), host.getPodId(), hostAddress, "", pInfo.getUuid());
|
||||
}
|
||||
}
|
||||
if (pool == null) {
|
||||
//the path can be different, but if they have the same uuid, assume they are the same storage
|
||||
pool = _storagePoolDao.findPoolByHostPath(host.getDataCenterId(), host.getPodId(), pInfo.getHost(), null,
|
||||
pool = _storagePoolDao.findPoolByHostPath(host.getDataCenterId(), host.getPodId(), hostAddress, null,
|
||||
pInfo.getUuid());
|
||||
if (pool != null) {
|
||||
s_logger.debug("Found a storage pool: " + pInfo.getUuid() + ", but with different hostpath " + pInfo.getHostPath() + ", still treat it as the same pool");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user