mhkadhum commented on code in PR #12124:
URL: https://github.com/apache/cloudstack/pull/12124#discussion_r2689226429
##########
plugins/storage/object/ECS/src/main/java/org/apache/cloudstack/storage/datastore/driver/EcsObjectStoreDriverImpl.java:
##########
@@ -137,68 +93,88 @@ public DataStoreTO getStoreTO(final DataStore store) {
@Override
public Bucket createBucket(final Bucket bucket, final boolean objectLock) {
final long storeId = bucket.getObjectStoreId();
- final String name = bucket.getName();
+ final String name = bucket.getName();
if (objectLock) {
- throw new CloudRuntimeException("Dell ECS doesn't support this
feature: object locking");
+ throw new InvalidParameterValueException("Dell ECS doesn't support
this feature: object locking");
}
final Map<String, String> ds = storeDetailsDao.getDetails(storeId);
final EcsCfg cfg = ecsCfgFromDetails(ds, storeId);
- // Resolve owner username for this bucket
final BucketVO vo = bucketDao.findById(bucket.getId());
+ if (vo == null) {
+ throw new CloudRuntimeException("ECS createBucket: bucket record
not found: id=" + bucket.getId());
+ }
+
final long accountId = vo.getAccountId();
final Account acct = accountDao.findById(accountId);
if (acct == null) {
throw new CloudRuntimeException("ECS createBucket: account not
found: id=" + accountId);
}
- final String ownerUser = "cs-" + acct.getUuid();
+
+ final String ownerUser = getUserPrefix(ds) + acct.getUuid();
// Ensure per-account credentials exist (single-key policy with
adopt-if-exists)
ensureAccountUserAndSecret(accountId, ownerUser, cfg.mgmtUrl,
cfg.saUser, cfg.saPass, cfg.ns, cfg.insecure);
- // Quota from UI (INT GB)
+ // Quota from UI (INT GB). Bucket.getQuota may be Integer;
Bucket.getSize may be Long.
Integer quotaGb = null;
try {
Review Comment:
https://github.com/mhkadhum/cloudstack/commit/6f3efbefc9ae8ba2ab62e00e1e0df472fd5beca0
##########
plugins/storage/object/ECS/src/main/java/org/apache/cloudstack/storage/datastore/driver/EcsObjectStoreDriverImpl.java:
##########
@@ -137,68 +93,88 @@ public DataStoreTO getStoreTO(final DataStore store) {
@Override
public Bucket createBucket(final Bucket bucket, final boolean objectLock) {
final long storeId = bucket.getObjectStoreId();
- final String name = bucket.getName();
+ final String name = bucket.getName();
if (objectLock) {
- throw new CloudRuntimeException("Dell ECS doesn't support this
feature: object locking");
+ throw new InvalidParameterValueException("Dell ECS doesn't support
this feature: object locking");
}
final Map<String, String> ds = storeDetailsDao.getDetails(storeId);
final EcsCfg cfg = ecsCfgFromDetails(ds, storeId);
- // Resolve owner username for this bucket
final BucketVO vo = bucketDao.findById(bucket.getId());
+ if (vo == null) {
+ throw new CloudRuntimeException("ECS createBucket: bucket record
not found: id=" + bucket.getId());
+ }
+
final long accountId = vo.getAccountId();
final Account acct = accountDao.findById(accountId);
if (acct == null) {
throw new CloudRuntimeException("ECS createBucket: account not
found: id=" + accountId);
}
- final String ownerUser = "cs-" + acct.getUuid();
+
+ final String ownerUser = getUserPrefix(ds) + acct.getUuid();
// Ensure per-account credentials exist (single-key policy with
adopt-if-exists)
ensureAccountUserAndSecret(accountId, ownerUser, cfg.mgmtUrl,
cfg.saUser, cfg.saPass, cfg.ns, cfg.insecure);
- // Quota from UI (INT GB)
+ // Quota from UI (INT GB). Bucket.getQuota may be Integer;
Bucket.getSize may be Long.
Integer quotaGb = null;
try {
- quotaGb = safeIntFromGetter(bucket, "getQuota");
- if (quotaGb == null) quotaGb = safeIntFromGetter(bucket,
"getSize");
- } catch (Throwable ignored) { }
+ quotaGb = bucket.getQuota();
+ } catch (Throwable ignored) {
+ }
- final int blockSizeGb = quotaGb != null && quotaGb > 0 ? quotaGb : 2;
- final int notifSizeGb = quotaGb != null && quotaGb > 0 ? quotaGb : 1;
+ if (quotaGb == null) {
+ try {
+ final Long sz = bucket.getSize();
+ if (sz != null) {
+ quotaGb = sz.intValue();
+ }
+ } catch (Throwable ignored) {
+ }
+ }
+
+ final int blockSizeGb;
+ final int notifSizeGb;
+ if (quotaGb != null && quotaGb > 0) {
+ blockSizeGb = quotaGb;
+ notifSizeGb = quotaGb;
+ } else {
+ blockSizeGb = 2;
+ notifSizeGb = 1;
+ }
- // Encryption flag from request/VO best-effort
- boolean encryptionEnabled =
- getBooleanFlagLoose(bucket, "getEncryption", "isEncryption",
false) ||
- getBooleanFlagLoose(bucket, "getEncryptionEnabled",
"isEncryptionEnabled", false);
+ // Encryption flag from request (Bucket has isEncryption()).
+ boolean encryptionEnabled = bucket.isEncryption();
- if (!encryptionEnabled && vo != null) {
- encryptionEnabled =
- getBooleanFlagLoose(vo, "getEncryption", "isEncryption",
false) ||
- getBooleanFlagLoose(vo, "getEncryptionEnabled",
"isEncryptionEnabled", false);
+ // Fallback to persisted value if request did not explicitly enable it.
+ if (!encryptionEnabled) {
+ try {
Review Comment:
https://github.com/mhkadhum/cloudstack/commit/6f3efbefc9ae8ba2ab62e00e1e0df472fd5beca0
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]