rg9975 commented on code in PR #7889: URL: https://github.com/apache/cloudstack/pull/7889#discussion_r1353020144
########## plugins/storage/volume/primera/src/main/java/org/apache/cloudstack/storage/datastore/adapter/primera/PrimeraAdapter.java: ########## @@ -0,0 +1,911 @@ +// 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.adapter.primera; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URL; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLContext; + +import org.apache.cloudstack.storage.datastore.adapter.ProviderAdapter; +import org.apache.cloudstack.storage.datastore.adapter.ProviderAdapterContext; +import org.apache.cloudstack.storage.datastore.adapter.ProviderAdapterDataObject; +import org.apache.cloudstack.storage.datastore.adapter.ProviderAdapterDiskOffering; +import org.apache.cloudstack.storage.datastore.adapter.ProviderSnapshot; +import org.apache.cloudstack.storage.datastore.adapter.ProviderVolume; +import org.apache.cloudstack.storage.datastore.adapter.ProviderVolume.AddressType; +import org.apache.cloudstack.storage.datastore.adapter.ProviderVolumeNamer; +import org.apache.cloudstack.storage.datastore.adapter.ProviderVolumeStats; +import org.apache.cloudstack.storage.datastore.adapter.ProviderVolumeStorageStats; +import org.apache.cloudstack.storage.datastore.adapter.ProviderAdapterDiskOffering.ProvisioningType; +import org.apache.http.Header; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpDelete; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.HttpPut; +import org.apache.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.conn.ssl.TrustAllStrategy; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.ssl.SSLContextBuilder; +import org.apache.log4j.Logger; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class PrimeraAdapter implements ProviderAdapter { + + static final Logger logger = Logger.getLogger(PrimeraAdapter.class); + + public static final String HOSTSET = "hostset"; + public static final String CPG = "cpg"; + public static final String SNAP_CPG = "snapCpg"; + public static final String KEY_TTL = "keyttl"; + public static final String CONNECT_TIMEOUT_MS = "connectTimeoutMs"; + public static final String POST_COPY_WAIT_MS = "postCopyWaitMs"; + public static final String TASK_WAIT_TIMEOUT_MS = "taskWaitTimeoutMs"; + + private static final long KEY_TTL_DEFAULT = (1000 * 60 * 14); + private static final long CONNECT_TIMEOUT_MS_DEFAULT = 600000; + private static final long TASK_WAIT_TIMEOUT_MS_DEFAULT = 10 * 60 * 1000; + public static final long BYTES_IN_MiB = 1048576; + + static final ObjectMapper mapper = new ObjectMapper(); + public String cpg = null; + public String snapCpg = null; + public String hostset = null; + private String username; + private String password; + private String key; + private String url; + private long keyExpiration = -1; + private long keyTtl = KEY_TTL_DEFAULT; + private long connTimeout = CONNECT_TIMEOUT_MS_DEFAULT; + private long taskWaitTimeoutMs = TASK_WAIT_TIMEOUT_MS_DEFAULT; + private CloseableHttpClient _client = null; + private boolean skipTlsValidation; + + private Map<String, String> connectionDetails = null; + + public PrimeraAdapter(String url, Map<String, String> details) { + this.url = url; + this.connectionDetails = details; + login(); + } + + @Override + public void refresh(Map<String, String> details) { + this.connectionDetails = details; + this.refreshSession(true); + } + + @Override + public void validate() { + login(); + // check if hostgroup and pod from details really exist - we will + // require a distinct configuration object/connection object for each type Review Comment: Updated in upcoming commit. -- 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]
