cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raj...@apache.org
Subject [2/5] git commit: updated refs/heads/volume-upload to bc997f1
Date Tue, 17 Feb 2015 06:11:37 GMT
volume upload: getUploadParamsForVolume url has IP address instead of hostname, SSL fails


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/38146779
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/38146779
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/38146779

Branch: refs/heads/volume-upload
Commit: 38146779779fa51e7b11335cbb3bd24ab9672c67
Parents: 01c41d0
Author: Rajani Karuturi <rajanikaruturi@gmail.com>
Authored: Mon Feb 2 12:13:01 2015 +0530
Committer: Rajani Karuturi <rajanikaruturi@gmail.com>
Committed: Tue Feb 17 11:31:44 2015 +0530

----------------------------------------------------------------------
 .../com/cloud/storage/VolumeApiServiceImpl.java |  6 ++-
 .../com/cloud/template/TemplateManagerImpl.java |  5 ++-
 utils/src/com/cloud/utils/ImageStoreUtil.java   | 39 ++++++++++++++++++++
 3 files changed, 48 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/38146779/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
index 39ecf31..7bc864b 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -29,6 +29,7 @@ import java.util.concurrent.ExecutionException;
 import javax.inject.Inject;
 
 import com.cloud.utils.EncryptionUtil;
+import com.cloud.utils.ImageStoreUtil;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 
@@ -303,7 +304,10 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
 
 
         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));
 
         // set the post url, this is used in the monitoring thread to determine the SSVM

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/38146779/server/src/com/cloud/template/TemplateManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java
index 6385789..32c121c 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -34,6 +34,7 @@ import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
 import com.cloud.utils.EncryptionUtil;
+import com.cloud.utils.ImageStoreUtil;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 
@@ -348,7 +349,9 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
              */
             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));
 
             // set the post url, this is used in the monitoring thread to determine the SSVM

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/38146779/utils/src/com/cloud/utils/ImageStoreUtil.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/ImageStoreUtil.java b/utils/src/com/cloud/utils/ImageStoreUtil.java
new file mode 100644
index 0000000..52f1324
--- /dev/null
+++ b/utils/src/com/cloud/utils/ImageStoreUtil.java
@@ -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;
+    }
+}


Mime
View raw message