mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
volume upload: getUploadParamsForVolume url has IP address instead of hostname, SSL fails
This commit is contained in:
parent
01c41d09db
commit
3814677977
@ -29,6 +29,7 @@ import java.util.concurrent.ExecutionException;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import com.cloud.utils.EncryptionUtil;
|
import com.cloud.utils.EncryptionUtil;
|
||||||
|
import com.cloud.utils.ImageStoreUtil;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
|
|
||||||
@ -303,7 +304,10 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||||||
|
|
||||||
|
|
||||||
GetUploadParamsResponse response = new GetUploadParamsResponse();
|
GetUploadParamsResponse response = new GetUploadParamsResponse();
|
||||||
String url = "https://" + ep.getPublicAddr() + "/upload/" + vol.getUuid();
|
|
||||||
|
String ssvmUrlDomain = _configDao.getValue(Config.SecStorageSecureCopyCert.key());
|
||||||
|
|
||||||
|
String url = ImageStoreUtil.generatePostUploadUrl(ssvmUrlDomain, ep.getPublicAddr(), vol.getUuid());
|
||||||
response.setPostURL(new URL(url));
|
response.setPostURL(new URL(url));
|
||||||
|
|
||||||
// set the post url, this is used in the monitoring thread to determine the SSVM
|
// set the post url, this is used in the monitoring thread to determine the SSVM
|
||||||
|
|||||||
@ -34,6 +34,7 @@ import javax.inject.Inject;
|
|||||||
import javax.naming.ConfigurationException;
|
import javax.naming.ConfigurationException;
|
||||||
|
|
||||||
import com.cloud.utils.EncryptionUtil;
|
import com.cloud.utils.EncryptionUtil;
|
||||||
|
import com.cloud.utils.ImageStoreUtil;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
|
|
||||||
@ -348,7 +349,9 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
|||||||
*/
|
*/
|
||||||
TemplateOrVolumePostUploadCommand firstCommand = payload.get(0);
|
TemplateOrVolumePostUploadCommand firstCommand = payload.get(0);
|
||||||
|
|
||||||
String url = "https://" + firstCommand.getRemoteEndPoint() + "/upload/" + firstCommand.getEntityUUID();
|
String ssvmUrlDomain = _configDao.getValue(Config.SecStorageSecureCopyCert.key());
|
||||||
|
|
||||||
|
String url = ImageStoreUtil.generatePostUploadUrl(ssvmUrlDomain, firstCommand.getRemoteEndPoint(), firstCommand.getEntityUUID());
|
||||||
response.setPostURL(new URL(url));
|
response.setPostURL(new URL(url));
|
||||||
|
|
||||||
// set the post url, this is used in the monitoring thread to determine the SSVM
|
// set the post url, this is used in the monitoring thread to determine the SSVM
|
||||||
|
|||||||
39
utils/src/com/cloud/utils/ImageStoreUtil.java
Normal file
39
utils/src/com/cloud/utils/ImageStoreUtil.java
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* 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 com.cloud.utils;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
public class ImageStoreUtil {
|
||||||
|
public static final Logger s_logger = Logger.getLogger(ImageStoreUtil.class.getName());
|
||||||
|
|
||||||
|
public static String generatePostUploadUrl(String ssvmUrlDomain, String ipAddress, String uuid) {
|
||||||
|
String hostname = ipAddress;
|
||||||
|
|
||||||
|
//if ssvm url domain is present, use it to construct hostname in the format 1-2-3-4.domain
|
||||||
|
// if the domain name is not present, ssl validation fails and has to be ignored
|
||||||
|
if(StringUtils.isNotBlank(ssvmUrlDomain)) {
|
||||||
|
hostname = ipAddress.replace(".", "-");
|
||||||
|
hostname = hostname + ssvmUrlDomain.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//only https works with postupload and url format is fixed
|
||||||
|
return "https://" + hostname + "/upload/" + uuid;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user