You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by hu...@apache.org on 2014/07/14 15:37:17 UTC

[13/44] git commit: updated refs/heads/vpc-toolkit-hugo to 1ad1883

Modification to the way SolidFire account info is stored in the DB


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

Branch: refs/heads/vpc-toolkit-hugo
Commit: 83034907ca460b91850e73ea3ac7fe4d1bee3db9
Parents: b517156
Author: Mike Tutkowski <mi...@solidfire.com>
Authored: Wed Jul 2 10:58:42 2014 -0600
Committer: Mike Tutkowski <mi...@solidfire.com>
Committed: Mon Jul 7 22:16:58 2014 -0600

----------------------------------------------------------------------
 .../driver/SolidFirePrimaryDataStoreDriver.java | 24 +++++++++-----
 ...olidFireSharedPrimaryDataStoreLifeCycle.java | 33 +++++++++++++++++---
 .../storage/datastore/util/SolidFireUtil.java   | 20 ++++++++++--
 3 files changed, 62 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83034907/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java
index 124b117..c06a728 100644
--- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java
+++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java
@@ -195,10 +195,7 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
         return (long)(maxIops * fClusterDefaultBurstIopsPercentOfMaxIops);
     }
 
-    private SolidFireUtil.SolidFireVolume createSolidFireVolume(SolidFireUtil.SolidFireConnection sfConnection, VolumeInfo volumeInfo) {
-        AccountDetailVO accountDetail = _accountDetailsDao.findDetail(volumeInfo.getAccountId(), SolidFireUtil.ACCOUNT_ID);
-        long sfAccountId = Long.parseLong(accountDetail.getValue());
-
+    private SolidFireUtil.SolidFireVolume createSolidFireVolume(SolidFireUtil.SolidFireConnection sfConnection, VolumeInfo volumeInfo, long sfAccountId) {
         long storagePoolId = volumeInfo.getDataStore().getId();
 
         final Iops iops;
@@ -298,15 +295,26 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
             String sfAccountName = SolidFireUtil.getSolidFireAccountName(account.getUuid(), account.getAccountId());
 
             long storagePoolId = dataStore.getId();
+
             SolidFireUtil.SolidFireConnection sfConnection = SolidFireUtil.getSolidFireConnection(storagePoolId, _storagePoolDetailsDao);
 
-            if (SolidFireUtil.getSolidFireAccount(sfConnection, sfAccountName) == null) {
-                SolidFireUtil.SolidFireAccount sfAccount = createSolidFireAccount(sfConnection, sfAccountName);
+            AccountDetailVO accountDetail = SolidFireUtil.getAccountDetail(volumeInfo.getAccountId(), storagePoolId, _accountDetailsDao);
+
+            if (accountDetail == null || accountDetail.getValue() == null) {
+                SolidFireUtil.SolidFireAccount sfAccount = SolidFireUtil.getSolidFireAccount(sfConnection, sfAccountName);
 
-                SolidFireUtil.updateCsDbWithSolidFireAccountInfo(account.getId(), sfAccount, _accountDetailsDao);
+                if (sfAccount == null) {
+                    sfAccount = createSolidFireAccount(sfConnection, sfAccountName);
+                }
+
+                SolidFireUtil.updateCsDbWithSolidFireAccountInfo(account.getId(), sfAccount, storagePoolId, _accountDetailsDao);
+
+                accountDetail = SolidFireUtil.getAccountDetail(volumeInfo.getAccountId(), storagePoolId, _accountDetailsDao);
             }
 
-            SolidFireUtil.SolidFireVolume sfVolume = createSolidFireVolume(sfConnection, volumeInfo);
+            long sfAccountId = Long.parseLong(accountDetail.getValue());
+
+            SolidFireUtil.SolidFireVolume sfVolume = createSolidFireVolume(sfConnection, volumeInfo, sfAccountId);
 
             iqn = sfVolume.getIqn();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83034907/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFireSharedPrimaryDataStoreLifeCycle.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFireSharedPrimaryDataStoreLifeCycle.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFireSharedPrimaryDataStoreLifeCycle.java
index b03634b..5065822 100644
--- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFireSharedPrimaryDataStoreLifeCycle.java
+++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFireSharedPrimaryDataStoreLifeCycle.java
@@ -219,7 +219,9 @@ public class SolidFireSharedPrimaryDataStoreLifeCycle implements PrimaryDataStor
 
         SolidFireUtil.SolidFireConnection sfConnection = new SolidFireUtil.SolidFireConnection(managementVip, managementPort, clusterAdminUsername, clusterAdminPassword);
 
-        SolidFireUtil.SolidFireVolume sfVolume = createSolidFireVolume(sfConnection, storagePoolName, capacityBytes, lMinIops, lMaxIops, lBurstIops);
+        SolidFireCreateVolume sfCreateVolume = createSolidFireVolume(sfConnection, storagePoolName, capacityBytes, lMinIops, lMaxIops, lBurstIops);
+
+        SolidFireUtil.SolidFireVolume sfVolume = sfCreateVolume.getVolume();
 
         String iqn = sfVolume.getIqn();
 
@@ -255,6 +257,11 @@ public class SolidFireSharedPrimaryDataStoreLifeCycle implements PrimaryDataStor
             List<HostVO> hosts = _hostDao.findByClusterId(clusterId);
 
             SolidFireUtil.placeVolumeInVolumeAccessGroup(sfConnection, sfVolume.getId(), dataStore.getId(), hosts, _clusterDetailsDao);
+
+            SolidFireUtil.SolidFireAccount sfAccount = sfCreateVolume.getAccount();
+            Account csAccount = CallContext.current().getCallingAccount();
+
+            SolidFireUtil.updateCsDbWithSolidFireAccountInfo(csAccount.getId(), sfAccount, dataStore.getId(), _accountDetailsDao);
         } catch (Exception ex) {
             _primaryDataStoreDao.expunge(dataStore.getId());
 
@@ -286,7 +293,25 @@ public class SolidFireSharedPrimaryDataStoreLifeCycle implements PrimaryDataStor
         throw new CloudRuntimeException("The 'hypervisor' parameter must be '" + HypervisorType.XenServer + "' or '" + HypervisorType.VMware + "'.");
     }
 
-    private SolidFireUtil.SolidFireVolume createSolidFireVolume(SolidFireUtil.SolidFireConnection sfConnection,
+    private class SolidFireCreateVolume {
+        private final SolidFireUtil.SolidFireVolume _sfVolume;
+        private final SolidFireUtil.SolidFireAccount _sfAccount;
+
+        public SolidFireCreateVolume(SolidFireUtil.SolidFireVolume sfVolume, SolidFireUtil.SolidFireAccount sfAccount) {
+            _sfVolume = sfVolume;
+            _sfAccount = sfAccount;
+        }
+
+        public SolidFireUtil.SolidFireVolume getVolume() {
+            return _sfVolume;
+        }
+
+        public SolidFireUtil.SolidFireAccount getAccount() {
+            return _sfAccount;
+        }
+    }
+
+    private SolidFireCreateVolume createSolidFireVolume(SolidFireUtil.SolidFireConnection sfConnection,
             String volumeName, long volumeSize, long minIops, long maxIops, long burstIops) {
         try {
             Account csAccount = CallContext.current().getCallingAccount();
@@ -301,15 +326,13 @@ public class SolidFireSharedPrimaryDataStoreLifeCycle implements PrimaryDataStor
                 long accountNumber = SolidFireUtil.createSolidFireAccount(sfConnection, sfAccountName);
 
                 sfAccount = SolidFireUtil.getSolidFireAccountById(sfConnection, accountNumber);
-
-                SolidFireUtil.updateCsDbWithSolidFireAccountInfo(csAccountId, sfAccount, _accountDetailsDao);
             }
 
             long sfVolumeId = SolidFireUtil.createSolidFireVolume(sfConnection, SolidFireUtil.getSolidFireVolumeName(volumeName), sfAccount.getId(), volumeSize,
                     true, null, minIops, maxIops, burstIops);
             SolidFireUtil.SolidFireVolume sfVolume = SolidFireUtil.getSolidFireVolume(sfConnection, sfVolumeId);
 
-            return sfVolume;
+            return new SolidFireCreateVolume(sfVolume, sfAccount);
         } catch (Throwable e) {
             throw new CloudRuntimeException("Failed to create a SolidFire volume: " + e.toString());
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83034907/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/util/SolidFireUtil.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/util/SolidFireUtil.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/util/SolidFireUtil.java
index 3f35d71..7c09d85 100644
--- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/util/SolidFireUtil.java
+++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/util/SolidFireUtil.java
@@ -187,13 +187,14 @@ public class SolidFireUtil {
     }
 
     public static void updateCsDbWithSolidFireAccountInfo(long csAccountId, SolidFireUtil.SolidFireAccount sfAccount,
-            AccountDetailsDao accountDetailsDao) {
+            long storagePoolId, AccountDetailsDao accountDetailsDao) {
         AccountDetailVO accountDetail = new AccountDetailVO(csAccountId,
-                SolidFireUtil.ACCOUNT_ID,
+                SolidFireUtil.getAccountKey(storagePoolId),
                 String.valueOf(sfAccount.getId()));
 
         accountDetailsDao.persist(accountDetail);
 
+        /*
         accountDetail = new AccountDetailVO(csAccountId,
                 SolidFireUtil.CHAP_INITIATOR_USERNAME,
                 String.valueOf(sfAccount.getName()));
@@ -217,6 +218,7 @@ public class SolidFireUtil {
                 sfAccount.getTargetSecret());
 
         accountDetailsDao.persist(accountDetail);
+        */
     }
 
     public static SolidFireAccount getSolidFireAccount(SolidFireConnection sfConnection, String sfAccountName) {
@@ -358,6 +360,20 @@ public class SolidFireUtil {
         return "sfVolumeAccessGroup_" + storagePoolId;
     }
 
+    private static String getAccountKey(long storagePoolId) {
+        return SolidFireUtil.ACCOUNT_ID + "_" + storagePoolId;
+    }
+
+    public static AccountDetailVO getAccountDetail(long csAccountId, long storagePoolId, AccountDetailsDao accountDetailsDao) {
+        AccountDetailVO accountDetail = accountDetailsDao.findDetail(csAccountId, SolidFireUtil.getAccountKey(storagePoolId));
+
+        if (accountDetail == null || accountDetail.getValue() == null) {
+            accountDetail = accountDetailsDao.findDetail(csAccountId, SolidFireUtil.ACCOUNT_ID);
+        }
+
+        return accountDetail;
+    }
+
     public static String[] getIqnsFromHosts(List<? extends Host> hosts) {
         if (hosts == null || hosts.size() == 0) {
             throw new CloudRuntimeException("There do not appear to be any hosts in this cluster.");