DaanHoogland commented on code in PR #12124:
URL: https://github.com/apache/cloudstack/pull/12124#discussion_r2571517861


##########
plugins/storage/object/ECS/src/main/java/org/apache/cloudstack/storage/datastore/driver/EcsObjectStoreDriverImpl.java:
##########


Review Comment:
   methods `createBucket`, listBuckets`, `listBucketObjects`, `deleteBucket`, 
`setBucketPolicy`, `getBucketPolicy`, `setOrSuspendVersioning`, 
`setBucketQuota`, `ensureAccountUserAndSecret` and `ecsBucketExists` are rather 
great. Again not my code to maintain, but extracting smaller methods will make 
it more readible and may help find some code deduplication possibilities.



##########
plugins/storage/object/ECS/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/EcsObjectStoreLifeCycleImpl.java:
##########
@@ -0,0 +1,255 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.datastore.lifecycle;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.net.ssl.SSLContext;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.HostScope;
+import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
+import org.apache.cloudstack.storage.datastore.db.ObjectStoreVO;
+import org.apache.cloudstack.storage.object.datastore.ObjectStoreHelper;
+import 
org.apache.cloudstack.storage.object.datastore.ObjectStoreProviderManager;
+import 
org.apache.cloudstack.storage.object.store.lifecycle.ObjectStoreLifeCycle;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet; // change to POST if ECS needs 
it
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.http.impl.auth.BasicScheme;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.ssl.SSLContextBuilder;
+import org.apache.http.ssl.TrustStrategy;
+
+import com.cloud.agent.api.StoragePoolInfo;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+public class EcsObjectStoreLifeCycleImpl implements ObjectStoreLifeCycle {
+
+    private static final Logger LOG = 
LogManager.getLogger(EcsObjectStoreLifeCycleImpl.class);
+
+    // detail keys coming from the API
+    private static final String MGMT_URL   = "mgmt_url";
+    private static final String SA_USER    = "sa_user";
+    private static final String SA_PASS    = "sa_password";
+    private static final String INSECURE   = "insecure";
+
+    // optional details (currently not used in persistence logic but accepted)
+    private static final String S3_HOST    = "s3_host";
+    private static final String NAMESPACE  = "namespace";
+
+    private static final String PROVIDER_NAME = "ECS";
+
+    @Inject
+    ObjectStoreHelper objectStoreHelper;
+
+    @Inject
+    ObjectStoreProviderManager objectStoreMgr;
+
+    public EcsObjectStoreLifeCycleImpl() {
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public DataStore initialize(Map<String, Object> dsInfos) {

Review Comment:
   this method can be split into several verify methods. Your code to maintain 
@mhkadhum , so I won’t -1 on this point but for readability it would be good.



-- 
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]

Reply via email to