private long getDefaultMaxIops(long storagePoolId) { StoragePoolDetailVO storagePoolDetail = _storagePoolDetailsDao.findDetail(storagePoolId, SolidFireUtil.CLUSTER_DEFAULT_MAX_IOPS); String clusterDefaultMaxIops = storagePoolDetail.getValue(); return Long.parseLong(clusterDefaultMaxIops); }
private SolidFireUtil.SolidFireVolume createSolidFireVolume( VolumeInfo volumeInfo, SolidFireConnection sfConnection) { String mVip = sfConnection.getManagementVip(); int mPort = sfConnection.getManagementPort(); String clusterAdminUsername = sfConnection.getClusterAdminUsername(); String clusterAdminPassword = sfConnection.getClusterAdminPassword(); AccountDetailVO accountDetail = _accountDetailsDao.findDetail(volumeInfo.getAccountId(), SolidFireUtil.ACCOUNT_ID); long sfAccountId = Long.parseLong(accountDetail.getValue()); long storagePoolId = volumeInfo.getDataStore().getId(); final Iops iops; Long minIops = volumeInfo.getMinIops(); Long maxIops = volumeInfo.getMaxIops(); if (minIops == null || minIops <= 0 || maxIops == null || maxIops <= 0) { long defaultMaxIops = getDefaultMaxIops(storagePoolId); iops = new Iops( getDefaultMinIops(storagePoolId), defaultMaxIops, getDefaultBurstIops(storagePoolId, defaultMaxIops)); } else { iops = new Iops( volumeInfo.getMinIops(), volumeInfo.getMaxIops(), getDefaultBurstIops(storagePoolId, volumeInfo.getMaxIops())); } long sfVolumeId = SolidFireUtil.createSolidFireVolume( mVip, mPort, clusterAdminUsername, clusterAdminPassword, getSolidFireVolumeName(volumeInfo.getName()), sfAccountId, volumeInfo.getSize(), true, iops.getMinIops(), iops.getMaxIops(), iops.getBurstIops()); return SolidFireUtil.getSolidFireVolume( mVip, mPort, clusterAdminUsername, clusterAdminPassword, sfVolumeId); }
@Override public void deleteAsync( DataStore dataStore, DataObject dataObject, AsyncCompletionCallback<CommandResult> callback) { String errMsg = null; if (dataObject.getType() == DataObjectType.VOLUME) { VolumeInfo volumeInfo = (VolumeInfo) dataObject; AccountVO account = _accountDao.findById(volumeInfo.getAccountId()); AccountDetailVO accountDetails = _accountDetailsDao.findDetail(account.getAccountId(), SolidFireUtil.ACCOUNT_ID); long sfAccountId = Long.parseLong(accountDetails.getValue()); long storagePoolId = dataStore.getId(); SolidFireConnection sfConnection = getSolidFireConnection(storagePoolId); deleteSolidFireVolume(volumeInfo, sfConnection); _volumeDao.deleteVolumesByInstance(volumeInfo.getId()); // if (!sfAccountHasVolume(sfAccountId, sfConnection)) { // // delete the account from the SolidFire SAN // deleteSolidFireAccount(sfAccountId, sfConnection); // // // delete the info in the account_details table // // that's related to the SolidFire account // _accountDetailsDao.deleteDetails(account.getAccountId()); // } StoragePoolVO storagePool = _storagePoolDao.findById(storagePoolId); long usedBytes = storagePool.getUsedBytes(); usedBytes -= volumeInfo.getSize(); storagePool.setUsedBytes(usedBytes < 0 ? 0 : usedBytes); _storagePoolDao.update(storagePoolId, storagePool); } else { errMsg = "Invalid DataObjectType (" + dataObject.getType() + ") passed to deleteAsync"; } CommandResult result = new CommandResult(); result.setResult(errMsg); callback.complete(result); }
private void deleteSolidFireVolume(VolumeInfo volumeInfo, SolidFireConnection sfConnection) { Long storagePoolId = volumeInfo.getPoolId(); if (storagePoolId == null) { return; // this volume was never assigned to a storage pool, so no SAN volume should exist for // it } String mVip = sfConnection.getManagementVip(); int mPort = sfConnection.getManagementPort(); String clusterAdminUsername = sfConnection.getClusterAdminUsername(); String clusterAdminPassword = sfConnection.getClusterAdminPassword(); long sfVolumeId = Long.parseLong(volumeInfo.getFolder()); SolidFireUtil.deleteSolidFireVolume( mVip, mPort, clusterAdminUsername, clusterAdminPassword, sfVolumeId); }