cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [1/3] git commit: updated refs/heads/master to 05e4ba7
Date Thu, 16 Apr 2015 12:15:03 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master e262a3a4b -> 05e4ba735


vmware: support vmfs as local storage pool type

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit 752d784d92b4ce461ec6a19a6b54220bb967d4d0)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/06e353e5
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/06e353e5
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/06e353e5

Branch: refs/heads/master
Commit: 06e353e5c75a39799dbb1d79790baaeb3678b947
Parents: e262a3a
Author: Rohit Yadav <rohit.yadav@shapeblue.com>
Authored: Thu Apr 16 16:39:24 2015 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Thu Apr 16 17:36:52 2015 +0530

----------------------------------------------------------------------
 .../com/cloud/upgrade/dao/Upgrade450to451.java  | 33 ++++++++++++++++++--
 .../com/cloud/hypervisor/guru/VMwareGuru.java   | 12 ++++++-
 .../vmware/resource/VmwareResource.java         |  2 +-
 .../com/cloud/storage/StorageManagerImpl.java   | 11 +++++--
 4 files changed, 50 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/06e353e5/engine/schema/src/com/cloud/upgrade/dao/Upgrade450to451.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade450to451.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade450to451.java
index 218f4ec..d56db85 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade450to451.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade450to451.java
@@ -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");
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/06e353e5/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java
index 808cb5b..9ac32d4 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java
@@ -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()) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/06e353e5/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index 796999b..a628fb7 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -4245,7 +4245,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);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/06e353e5/server/src/com/cloud/storage/StorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java
index fafcdcd..2a46592 100644
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -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;
 
@@ -545,7 +546,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
@@ -554,12 +559,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");


Mime
View raw message