Skip to content

Commit 33c7a07

Browse files
committed
Use original GUI store details key names
- The Store details are maintained outside of the plugin so it is best to save them using their original key names.
1 parent e6145c8 commit 33c7a07

File tree

5 files changed

+35
-45
lines changed

5 files changed

+35
-45
lines changed

plugins/storage/object/cloudian/src/main/java/org/apache/cloudstack/storage/datastore/driver/CloudianHyperStoreObjectStoreDriverImpl.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ public Bucket createBucket(Bucket bucket, boolean objectLock) {
425425

426426
// get an s3client using Account Root User Credentials
427427
Map<String, String> storeDetails = _storeDetailsDao.getDetails(storeId);
428-
String s3url = storeDetails.get(CloudianHyperStoreUtil.KEY_S3_ENDPOINT_URL);
428+
String s3url = storeDetails.get(CloudianHyperStoreUtil.STORE_DETAILS_KEY_S3_URL);
429429
Map<String, String> accountDetails = _accountDetailsDao.findDetails(accountId);
430430
String accessKey = accountDetails.get(CloudianHyperStoreUtil.KEY_ROOT_ACCESS_KEY);
431431
String secretKey = accountDetails.get(CloudianHyperStoreUtil.KEY_ROOT_SECRET_KEY);
@@ -807,9 +807,9 @@ protected CloudianClient getCloudianClientByStoreId(long storeId) {
807807
ObjectStoreVO store = _storeDao.findById(storeId);
808808
String url = store.getUrl();
809809
Map<String, String> storeDetails = _storeDetailsDao.getDetails(storeId);
810-
String adminUsername = storeDetails.get(CloudianHyperStoreUtil.KEY_ADMIN_USER);
811-
String adminPassword = storeDetails.get(CloudianHyperStoreUtil.KEY_ADMIN_PASS);
812-
String strValidateSSL = storeDetails.get(CloudianHyperStoreUtil.KEY_ADMIN_VALIDATE_SSL);
810+
String adminUsername = storeDetails.get(CloudianHyperStoreUtil.STORE_DETAILS_KEY_USER_NAME);
811+
String adminPassword = storeDetails.get(CloudianHyperStoreUtil.STORE_DETAILS_KEY_PASSWORD);
812+
String strValidateSSL = storeDetails.get(CloudianHyperStoreUtil.STORE_DETAILS_KEY_VALIDATE_SSL);
813813
boolean validateSSL = Boolean.parseBoolean(strValidateSSL);
814814

815815
return CloudianHyperStoreUtil.getCloudianClient(url, adminUsername, adminPassword, validateSSL);
@@ -831,7 +831,7 @@ protected AmazonS3 getS3ClientByBucketAndStore(BucketTO bucket, long storeId) {
831831
if (bvo.getName().equals(bucket.getName())) {
832832
long accountId = bvo.getAccountId();
833833
Map<String, String> storeDetails = _storeDetailsDao.getDetails(storeId);
834-
String s3url = storeDetails.get(CloudianHyperStoreUtil.KEY_S3_ENDPOINT_URL);
834+
String s3url = storeDetails.get(CloudianHyperStoreUtil.STORE_DETAILS_KEY_S3_URL);
835835
String accessKey = _accountDetailsDao.findDetail(accountId, CloudianHyperStoreUtil.KEY_ROOT_ACCESS_KEY).getValue();
836836
String secretKey = _accountDetailsDao.findDetail(accountId, CloudianHyperStoreUtil.KEY_ROOT_SECRET_KEY).getValue();
837837
logger.debug("Creating S3 connection to {} for {} ", s3url, accessKey);
@@ -868,7 +868,7 @@ protected AmazonS3 getS3Client(String s3url, String accessKey, String secretKey)
868868
*/
869869
protected AmazonIdentityManagement getIAMClientByStoreId(long storeId, CloudianCredential credential) {
870870
Map<String, String> storeDetails = _storeDetailsDao.getDetails(storeId);
871-
String iamUrl = storeDetails.get(CloudianHyperStoreUtil.KEY_IAM_ENDPOINT_URL);
871+
String iamUrl = storeDetails.get(CloudianHyperStoreUtil.STORE_DETAILS_KEY_IAM_URL);
872872
logger.debug("Creating a new IAM connection to {} for {}", iamUrl, credential.getAccessKey());
873873

874874
return CloudianHyperStoreUtil.getIAMClient(iamUrl, credential.getAccessKey(), credential.getSecretKey());

plugins/storage/object/cloudian/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/CloudianHyperStoreObjectStoreLifeCycleImpl.java

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,46 +71,41 @@ public DataStore initialize(Map<String, Object> dsInfos) {
7171
objectStoreParameters.put(CloudianHyperStoreUtil.STORE_KEY_URL, url);
7272
objectStoreParameters.put(CloudianHyperStoreUtil.STORE_KEY_PROVIDER_NAME, providerName);
7373

74-
// Build the details map
74+
// Pull out the details map
7575
@SuppressWarnings("unchecked")
76-
Map<String, String> details_from_gui = (Map<String, String>) dsInfos.get(CloudianHyperStoreUtil.STORE_KEY_DETAILS);
77-
if (details_from_gui == null) {
76+
Map<String, String> details = (Map<String, String>) dsInfos.get(CloudianHyperStoreUtil.STORE_KEY_DETAILS);
77+
if (details == null) {
7878
String msg = String.format("Unexpected null receiving Object Store initialization \"%s\"", CloudianHyperStoreUtil.STORE_KEY_DETAILS);
7979
logger.error(msg);
8080
throw new CloudRuntimeException(msg);
8181
}
8282

83-
// The Admin Username/Password are available respectively as accesskey/secretkey
84-
String adminUsername = details_from_gui.get(CloudianHyperStoreUtil.GUI_DETAILS_KEY_ACCESSKEY);
85-
String adminPassword = details_from_gui.get(CloudianHyperStoreUtil.GUI_DETAILS_KEY_SECRETKEY);
86-
String validateSSL = details_from_gui.get(CloudianHyperStoreUtil.GUI_DETAILS_KEY_VALIDATE_SSL);
83+
// Note: The Admin Username/Password are available respectively as accesskey/secretkey
84+
String adminUsername = details.get(CloudianHyperStoreUtil.STORE_DETAILS_KEY_USER_NAME);
85+
String adminPassword = details.get(CloudianHyperStoreUtil.STORE_DETAILS_KEY_PASSWORD);
86+
String validateSSL = details.get(CloudianHyperStoreUtil.STORE_DETAILS_KEY_VALIDATE_SSL);
8787
boolean adminValidateSSL = Boolean.parseBoolean(validateSSL);
88-
String s3Url = details_from_gui.get(CloudianHyperStoreUtil.GUI_DETAILS_KEY_S3_URL);
89-
String iamUrl = details_from_gui.get(CloudianHyperStoreUtil.GUI_DETAILS_KEY_IAM_URL);
88+
String s3Url = details.get(CloudianHyperStoreUtil.STORE_DETAILS_KEY_S3_URL);
89+
String iamUrl = details.get(CloudianHyperStoreUtil.STORE_DETAILS_KEY_IAM_URL);
9090

9191
if (StringUtils.isAnyBlank(adminUsername, adminPassword, validateSSL, s3Url, iamUrl)) {
9292
final String asteriskPassword = (adminPassword == null) ? null : "*".repeat(adminPassword.length());
9393
logger.error("Required parameters are missing; username={} password={} validateSSL={} s3Url={} iamUrl={}",
9494
adminUsername, asteriskPassword, validateSSL, s3Url, iamUrl);
9595
throw new CloudRuntimeException("Required Cloudian HyperStore configuration parameters are missing/empty.");
9696
}
97-
Map<String, String> details = new HashMap<String, String>();
98-
details.put(CloudianHyperStoreUtil.KEY_ADMIN_USER, adminUsername);
99-
details.put(CloudianHyperStoreUtil.KEY_ADMIN_PASS, adminPassword);
100-
details.put(CloudianHyperStoreUtil.KEY_ADMIN_VALIDATE_SSL, Boolean.toString(adminValidateSSL));
101-
details.put(CloudianHyperStoreUtil.KEY_S3_ENDPOINT_URL, s3Url);
102-
details.put(CloudianHyperStoreUtil.KEY_IAM_ENDPOINT_URL, iamUrl);
10397

10498
// Validate the ADMIN API Service Information
10599
logger.info("Confirming connection to the HyperStore Admin Service at: {}", url);
106100
CloudianClient client = CloudianHyperStoreUtil.getCloudianClient(url, adminUsername, adminPassword, adminValidateSSL);
107101
String version = client.getServerVersion();
108-
logger.info("Successfully connected to HyperStore: {}", version);
109102

110103
// Validate S3 and IAM Service URLs.
111104
CloudianHyperStoreUtil.validateS3Url(s3Url);
112105
CloudianHyperStoreUtil.validateIAMUrl(iamUrl);
113106

107+
logger.info("Successfully connected to HyperStore: {}", version);
108+
114109
ObjectStoreVO objectStore = objectStoreHelper.createObjectStore(objectStoreParameters, details);
115110
return objectStoreMgr.getObjectStore(objectStore.getId());
116111
}

plugins/storage/object/cloudian/src/main/java/org/apache/cloudstack/storage/datastore/util/CloudianHyperStoreUtil.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,16 @@ public class CloudianHyperStoreUtil {
4646
public static final String STORE_KEY_NAME = "name";
4747
public static final String STORE_KEY_DETAILS = "details";
4848

49-
// GUI Object Store Details map key names
50-
public static final String GUI_DETAILS_KEY_ACCESSKEY = "accesskey";
51-
public static final String GUI_DETAILS_KEY_SECRETKEY = "secretkey";
52-
public static final String GUI_DETAILS_KEY_VALIDATE_SSL = "validateSSL";
53-
public static final String GUI_DETAILS_KEY_S3_URL = "s3Url";
54-
public static final String GUI_DETAILS_KEY_IAM_URL = "iamUrl";
55-
56-
// detail map key names
57-
public static final String KEY_ADMIN_USER = "hs_AdminUser";
58-
public static final String KEY_ADMIN_PASS = "hs_AdminPass";
59-
public static final String KEY_ADMIN_VALIDATE_SSL = "hs_AdminValidateSSL";
60-
public static final String KEY_S3_ENDPOINT_URL = "hs_S3EndpointURL";
49+
// Store Details Map key names - managed outside of plugin
50+
public static final String STORE_DETAILS_KEY_USER_NAME = "accesskey"; // admin user name
51+
public static final String STORE_DETAILS_KEY_PASSWORD = "secretkey"; // admin password
52+
public static final String STORE_DETAILS_KEY_VALIDATE_SSL = "validateSSL";
53+
public static final String STORE_DETAILS_KEY_S3_URL = "s3Url";
54+
public static final String STORE_DETAILS_KEY_IAM_URL = "iamUrl";
55+
56+
// Account Detail Map key names
6157
public static final String KEY_ROOT_ACCESS_KEY = "hs_AccessKey";
6258
public static final String KEY_ROOT_SECRET_KEY = "hs_SecretKey";
63-
public static final String KEY_IAM_ENDPOINT_URL = "hs_IAMEndpointURL";
6459
public static final String KEY_IAM_ACCESS_KEY = "hs_IAMAccessKey";
6560
public static final String KEY_IAM_SECRET_KEY = "hs_IAMSecretKey";
6661

plugins/storage/object/cloudian/src/test/java/org/apache/cloudstack/storage/datastore/driver/CloudianHyperStoreObjectStoreDriverImplTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,11 @@ public void setUp() {
160160

161161
// The StoreDetailMap has Endpoint info and Admin Credentials
162162
StoreDetailsMap = new HashMap<String, String>();
163-
StoreDetailsMap.put(CloudianHyperStoreUtil.KEY_ADMIN_USER, TEST_ADMIN_USER_NAME);
164-
StoreDetailsMap.put(CloudianHyperStoreUtil.KEY_ADMIN_PASS, TEST_ADMIN_PASSWORD);
165-
StoreDetailsMap.put(CloudianHyperStoreUtil.KEY_ADMIN_VALIDATE_SSL, TEST_ADMIN_VALIDATE_SSL);
166-
StoreDetailsMap.put(CloudianHyperStoreUtil.KEY_S3_ENDPOINT_URL, TEST_S3_URL);
167-
StoreDetailsMap.put(CloudianHyperStoreUtil.KEY_IAM_ENDPOINT_URL, TEST_IAM_URL);
163+
StoreDetailsMap.put(CloudianHyperStoreUtil.STORE_DETAILS_KEY_USER_NAME, TEST_ADMIN_USER_NAME);
164+
StoreDetailsMap.put(CloudianHyperStoreUtil.STORE_DETAILS_KEY_PASSWORD, TEST_ADMIN_PASSWORD);
165+
StoreDetailsMap.put(CloudianHyperStoreUtil.STORE_DETAILS_KEY_VALIDATE_SSL, TEST_ADMIN_VALIDATE_SSL);
166+
StoreDetailsMap.put(CloudianHyperStoreUtil.STORE_DETAILS_KEY_S3_URL, TEST_S3_URL);
167+
StoreDetailsMap.put(CloudianHyperStoreUtil.STORE_DETAILS_KEY_IAM_URL, TEST_IAM_URL);
168168
when(objectStoreDetailsDao.getDetails(TEST_STORE_ID)).thenReturn(StoreDetailsMap);
169169

170170
// The AccountDetailsMap has credentials for operating on the account.

plugins/storage/object/cloudian/src/test/java/org/apache/cloudstack/storage/datastore/lifecycle/CloudianHyperStoreObjectStoreLifeCycleImplTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ public void testInitializeValidation() {
166166
assertEquals(TEST_PROVIDER_NAME, updatedParams.get(CloudianHyperStoreUtil.STORE_KEY_PROVIDER_NAME));
167167
Map<String, String> updatedDetails = detailsArg.getValue();
168168
assertEquals(5, updatedDetails.size());
169-
assertEquals(TEST_ADMIN_USERNAME, updatedDetails.get(CloudianHyperStoreUtil.KEY_ADMIN_USER));
170-
assertEquals(TEST_ADMIN_PASSWORD, updatedDetails.get(CloudianHyperStoreUtil.KEY_ADMIN_PASS));
171-
assertEquals(TEST_VALIDATE_SSL, updatedDetails.get(CloudianHyperStoreUtil.KEY_ADMIN_VALIDATE_SSL));
172-
assertEquals(TEST_S3_URL, updatedDetails.get(CloudianHyperStoreUtil.KEY_S3_ENDPOINT_URL));
173-
assertEquals(TEST_IAM_URL, updatedDetails.get(CloudianHyperStoreUtil.KEY_IAM_ENDPOINT_URL));
169+
assertEquals(TEST_ADMIN_USERNAME, updatedDetails.get(CloudianHyperStoreUtil.STORE_DETAILS_KEY_USER_NAME));
170+
assertEquals(TEST_ADMIN_PASSWORD, updatedDetails.get(CloudianHyperStoreUtil.STORE_DETAILS_KEY_PASSWORD));
171+
assertEquals(TEST_VALIDATE_SSL, updatedDetails.get(CloudianHyperStoreUtil.STORE_DETAILS_KEY_VALIDATE_SSL));
172+
assertEquals(TEST_S3_URL, updatedDetails.get(CloudianHyperStoreUtil.STORE_DETAILS_KEY_S3_URL));
173+
assertEquals(TEST_IAM_URL, updatedDetails.get(CloudianHyperStoreUtil.STORE_DETAILS_KEY_IAM_URL));
174174
}
175175

176176
@Test

0 commit comments

Comments
 (0)