1717package org .apache .cloudstack .storage .datastore .driver ;
1818
1919import java .util .List ;
20- import java .util .Set ;
2120
2221import javax .inject .Inject ;
2322
2928import org .apache .cloudstack .storage .datastore .db .StoragePoolDetailVO ;
3029import org .apache .cloudstack .storage .datastore .db .StoragePoolVO ;
3130import org .apache .cloudstack .storage .datastore .util .SolidFireUtil ;
32- import org .apache .log4j . Logger ;
31+ import org .apache .commons . lang . StringUtils ;
3332
3433import com .cloud .agent .api .Answer ;
3534import com .cloud .agent .api .to .DataObjectType ;
3635import com .cloud .agent .api .to .DataStoreTO ;
3736import com .cloud .agent .api .to .DataTO ;
3837import com .cloud .dc .dao .DataCenterDao ;
39- import com .cloud .utils .exception .CloudRuntimeException ;
40- import com .cloud .exception .StorageUnavailableException ;
4138import com .cloud .storage .Storage .StoragePoolType ;
4239import com .cloud .storage .VolumeVO ;
4340import com .cloud .storage .dao .VolumeDao ;
4845import com .cloud .user .dao .AccountDao ;
4946
5047public class SolidfirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
51- private static final Logger s_logger = Logger .getLogger (SolidfirePrimaryDataStoreDriver .class );
52-
5348 @ Inject private PrimaryDataStoreDao _storagePoolDao ;
5449 @ Inject private StoragePoolDetailsDao _storagePoolDetailsDao ;
5550 @ Inject private VolumeDao _volumeDao ;
@@ -220,6 +215,32 @@ public ChapInfo getChapInfo(VolumeInfo volumeInfo) {
220215 chapTargetUsername , chapTargetSecret );
221216 }
222217
218+ private long getDefaultMinIops (long storagePoolId ) {
219+ StoragePoolDetailVO storagePoolDetail = _storagePoolDetailsDao .findDetail (storagePoolId , SolidFireUtil .CLUSTER_DEFAULT_MIN_IOPS );
220+
221+ String clusterDefaultMinIops = storagePoolDetail .getValue ();
222+
223+ return Long .parseLong (clusterDefaultMinIops );
224+ }
225+
226+ private long getDefaultMaxIops (long storagePoolId ) {
227+ StoragePoolDetailVO storagePoolDetail = _storagePoolDetailsDao .findDetail (storagePoolId , SolidFireUtil .CLUSTER_DEFAULT_MAX_IOPS );
228+
229+ String clusterDefaultMaxIops = storagePoolDetail .getValue ();
230+
231+ return Long .parseLong (clusterDefaultMaxIops );
232+ }
233+
234+ private long getDefaultBurstIops (long storagePoolId , long maxIops ) {
235+ StoragePoolDetailVO storagePoolDetail = _storagePoolDetailsDao .findDetail (storagePoolId , SolidFireUtil .CLUSTER_DEFAULT_BURST_IOPS_PERCENT_OF_MAX_IOPS );
236+
237+ String clusterDefaultBurstIopsPercentOfMaxIops = storagePoolDetail .getValue ();
238+
239+ float fClusterDefaultBurstIopsPercentOfMaxIops = Float .parseFloat (clusterDefaultBurstIopsPercentOfMaxIops );
240+
241+ return (long )(maxIops * fClusterDefaultBurstIopsPercentOfMaxIops );
242+ }
243+
223244 private SolidFireUtil .SolidFireVolume createSolidFireVolume (VolumeInfo volumeInfo , SolidFireConnection sfConnection )
224245 {
225246 String mVip = sfConnection .getManagementVip ();
@@ -230,46 +251,72 @@ private SolidFireUtil.SolidFireVolume createSolidFireVolume(VolumeInfo volumeInf
230251 AccountDetailVO accountDetail = _accountDetailsDao .findDetail (volumeInfo .getAccountId (), SolidFireUtil .ACCOUNT_ID );
231252 long sfAccountId = Long .parseLong (accountDetail .getValue ());
232253
254+ long storagePoolId = volumeInfo .getDataStore ().getId ();
255+
233256 final Iops iops ;
234257
235258 Long minIops = volumeInfo .getMinIops ();
236259 Long maxIops = volumeInfo .getMaxIops ();
237260
238261 if (minIops == null || minIops <= 0 ||
239262 maxIops == null || maxIops <= 0 ) {
240- iops = new Iops (100 , 15000 );
263+ long defaultMaxIops = getDefaultMaxIops (storagePoolId );
264+
265+ iops = new Iops (getDefaultMinIops (storagePoolId ), defaultMaxIops , getDefaultBurstIops (storagePoolId , defaultMaxIops ));
241266 }
242267 else {
243- iops = new Iops (volumeInfo .getMinIops (), volumeInfo .getMaxIops ());
268+ iops = new Iops (volumeInfo .getMinIops (), volumeInfo .getMaxIops (), getDefaultBurstIops ( storagePoolId , volumeInfo . getMaxIops ()) );
244269 }
245270
246271 long sfVolumeId = SolidFireUtil .createSolidFireVolume (mVip , mPort , clusterAdminUsername , clusterAdminPassword ,
247- volumeInfo .getName (), sfAccountId , volumeInfo .getSize (), true ,
272+ getSolidFireVolumeName ( volumeInfo .getName () ), sfAccountId , volumeInfo .getSize (), true ,
248273 iops .getMinIops (), iops .getMaxIops (), iops .getBurstIops ());
249274
250275 return SolidFireUtil .getSolidFireVolume (mVip , mPort , clusterAdminUsername , clusterAdminPassword , sfVolumeId );
251276 }
252277
278+ private String getSolidFireVolumeName (String strCloudStackVolumeName ) {
279+ final String specialChar = "-" ;
280+
281+ StringBuilder strSolidFireVolumeName = new StringBuilder ();
282+
283+ for (int i = 0 ; i < strCloudStackVolumeName .length (); i ++) {
284+ String strChar = strCloudStackVolumeName .substring (i , i + 1 );
285+
286+ if (StringUtils .isAlphanumeric (strChar )) {
287+ strSolidFireVolumeName .append (strChar );
288+ }
289+ else {
290+ strSolidFireVolumeName .append (specialChar );
291+ }
292+ }
293+
294+ return strSolidFireVolumeName .toString ();
295+ }
296+
253297 private static class Iops
254298 {
255- private final long _minIops ;
256- private final long _maxIops ;
257- private final long _burstIops ;
299+ private final long _minIops ;
300+ private final long _maxIops ;
301+ private final long _burstIops ;
258302
259- public Iops (long minIops , long maxIops ) throws IllegalArgumentException
260- {
261- if (minIops <= 0 || maxIops <= 0 ) {
262- throw new IllegalArgumentException ("The 'Min IOPS' and 'Max IOPS' values must be greater than 0." );
263- }
303+ public Iops (long minIops , long maxIops , long burstIops ) throws IllegalArgumentException
304+ {
305+ if (minIops <= 0 || maxIops <= 0 ) {
306+ throw new IllegalArgumentException ("The 'Min IOPS' and 'Max IOPS' values must be greater than 0." );
307+ }
264308
265309 if (minIops > maxIops ) {
266310 throw new IllegalArgumentException ("The 'Min IOPS' value cannot exceed the 'Max IOPS' value." );
267311 }
268312
313+ if (maxIops > burstIops ) {
314+ throw new IllegalArgumentException ("The 'Max IOPS' value cannot exceed the 'Burst IOPS' value." );
315+ }
316+
269317 _minIops = minIops ;
270318 _maxIops = maxIops ;
271-
272- _burstIops = getBurstIops (_maxIops );
319+ _burstIops = burstIops ;
273320 }
274321
275322 public long getMinIops ()
@@ -286,11 +333,6 @@ public long getBurstIops()
286333 {
287334 return _burstIops ;
288335 }
289-
290- private static long getBurstIops (long maxIops )
291- {
292- return (long )(maxIops * 1.5 );
293- }
294336 }
295337
296338 private void deleteSolidFireVolume (VolumeInfo volumeInfo , SolidFireConnection sfConnection )
@@ -448,14 +490,14 @@ public void deleteAsync(DataStore dataStore, DataObject dataObject,
448490
449491 _volumeDao .deleteVolumesByInstance (volumeInfo .getId ());
450492
451- if (!sfAccountHasVolume (sfAccountId , sfConnection )) {
452- // delete the account from the SolidFire SAN
453- deleteSolidFireAccount (sfAccountId , sfConnection );
454-
455- // delete the info in the account_details table
456- // that's related to the SolidFire account
457- _accountDetailsDao .deleteDetails (account .getAccountId ());
458- }
493+ // if (!sfAccountHasVolume(sfAccountId, sfConnection)) {
494+ // // delete the account from the SolidFire SAN
495+ // deleteSolidFireAccount(sfAccountId, sfConnection);
496+ //
497+ // // delete the info in the account_details table
498+ // // that's related to the SolidFire account
499+ // _accountDetailsDao.deleteDetails(account.getAccountId());
500+ // }
459501
460502 StoragePoolVO storagePool = _storagePoolDao .findById (storagePoolId );
461503
0 commit comments