mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
Modification to the way SolidFire account info is stored in the DB
This commit is contained in:
parent
b517156fe3
commit
83034907ca
@ -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);
|
||||
|
||||
SolidFireUtil.updateCsDbWithSolidFireAccountInfo(account.getId(), sfAccount, _accountDetailsDao);
|
||||
if (accountDetail == null || accountDetail.getValue() == null) {
|
||||
SolidFireUtil.SolidFireAccount sfAccount = SolidFireUtil.getSolidFireAccount(sfConnection, sfAccountName);
|
||||
|
||||
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();
|
||||
|
||||
|
||||
@ -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());
|
||||
}
|
||||
|
||||
@ -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.");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user