Skip to content

Commit 5174b00

Browse files
nitinmehustcweizhou
authored andcommitted
CLOUDSTACK-2940
Allowing Replacement of realhostip.com with a customized domain for SSVM. Though the config variable was there we were always hardcoding to realhostip.com Reviewed-by: Abhi
1 parent e4d96bd commit 5174b00

2 files changed

Lines changed: 21 additions & 13 deletions

File tree

‎server/src/com/cloud/storage/download/DownloadMonitorImpl.java‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ public class DownloadMonitorImpl extends ManagerBase implements DownloadMonitor
159159
protected ResourceLimitService _resourceLimitMgr;
160160

161161
private Boolean _sslCopy = new Boolean(false);
162+
String _ssvmUrlDomain;
162163
private String _copyAuthPasswd;
163164
private String _proxy = null;
164165
protected SearchBuilder<VMTemplateHostVO> ReadyTemplateStatesSearch;
@@ -179,11 +180,8 @@ public boolean configure(String name, Map<String, Object> params) {
179180
_sslCopy = Boolean.parseBoolean(configs.get("secstorage.encrypt.copy"));
180181
_proxy = configs.get(Config.SecStorageProxy.key());
181182

182-
String cert = configs.get("secstorage.ssl.cert.domain");
183-
if (!"realhostip.com".equalsIgnoreCase(cert)) {
184-
s_logger.warn("Only realhostip.com ssl cert is supported, ignoring self-signed and other certs");
185-
}
186-
183+
_ssvmUrlDomain = configs.get("secstorage.ssl.cert.domain");
184+
187185
_copyAuthPasswd = configs.get("secstorage.copy.password");
188186

189187
_agentMgr.registerForHostEvents(new DownloadListener(this), true, false, false);
@@ -299,9 +297,15 @@ private String generateCopyUrl(String ipAddress, String dir, String path){
299297
String hostname = ipAddress;
300298
String scheme = "http";
301299
if (_sslCopy) {
302-
hostname = ipAddress.replace(".", "-");
303-
hostname = hostname + ".realhostip.com";
304-
scheme = "https";
300+
hostname = ipAddress.replace(".", "-");
301+
scheme = "https";
302+
303+
// Code for putting in custom certificates.
304+
if(_ssvmUrlDomain != null && _ssvmUrlDomain.length() > 0){
305+
hostname = hostname + "." + _ssvmUrlDomain;
306+
}else{
307+
hostname = hostname + ".realhostip.com";
308+
}
305309
}
306310
return scheme + "://" + hostname + "/copy/SecStorage/" + dir + "/" + path;
307311
}

‎server/src/com/cloud/storage/upload/UploadMonitorImpl.java‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public class UploadMonitorImpl extends ManagerBase implements UploadMonitor {
106106

107107
private String _name;
108108
private Boolean _sslCopy = new Boolean(false);
109+
private String _ssvmUrlDomain;
109110
private ScheduledExecutorService _executor = null;
110111

111112
Timer _timer;
@@ -329,8 +330,14 @@ private String generateCopyUrl(String ipAddress, String uuid){
329330
String scheme = "http";
330331
if (_sslCopy) {
331332
hostname = ipAddress.replace(".", "-");
332-
hostname = hostname + ".realhostip.com";
333333
scheme = "https";
334+
335+
// Code for putting in custom certificates.
336+
if(_ssvmUrlDomain != null && _ssvmUrlDomain.length() > 0){
337+
hostname = hostname + "." + _ssvmUrlDomain;
338+
}else{
339+
hostname = hostname + ".realhostip.com";
340+
}
334341
}
335342
return scheme + "://" + hostname + "/userdata/" + uuid;
336343
}
@@ -347,10 +354,7 @@ public boolean configure(String name, Map<String, Object> params)
347354
final Map<String, String> configs = _configDao.getConfiguration("ManagementServer", params);
348355
_sslCopy = Boolean.parseBoolean(configs.get("secstorage.encrypt.copy"));
349356

350-
String cert = configs.get("secstorage.secure.copy.cert");
351-
if ("realhostip.com".equalsIgnoreCase(cert)) {
352-
s_logger.warn("Only realhostip.com ssl cert is supported, ignoring self-signed and other certs");
353-
}
357+
_ssvmUrlDomain = configs.get("secstorage.ssl.cert.domain");
354358

355359
_agentMgr.registerForHostEvents(new UploadListener(this), true, false, false);
356360
String cleanupInterval = configs.get("extract.url.cleanup.interval");

0 commit comments

Comments
 (0)