winterhazel commented on code in PR #12124: URL: https://github.com/apache/cloudstack/pull/12124#discussion_r3137648060
########## plugins/storage/object/ECS/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/EcsObjectStoreLifeCycleImpl.java: ########## @@ -0,0 +1,321 @@ +/* + * 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.datastore.driver.EcsConstants; +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); + + private static final String PROVIDER_NAME = "ECS"; + + @Inject + ObjectStoreHelper objectStoreHelper; + + @Inject + ObjectStoreProviderManager objectStoreMgr; + + public EcsObjectStoreLifeCycleImpl() { + } + + @Override + public DataStore initialize(final Map<String, Object> dsInfos) { + requireInjected(); + + final String url = getString(dsInfos, "url", true); + final String name = getString(dsInfos, "name", true); + final Long size = getLong(dsInfos, "size"); // optional + final String providerName = getProviderName(dsInfos); Review Comment: You can use `PROVIDER_NAME` directly without having to obtain it from `dsInfos`. This method will not be called if `providerName` does not match `PROVIDER_NAME`. -- 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]
