Skip to content

Commit ec4db7b

Browse files
John Kinsellachaturvedia
authored andcommitted
CLOUDSTACK-6204: Removing realhostip.com dependency
For more info, see https://cwiki.apache.org/confluence/display/CLOUDSTACK/Realhost+IP+changes Author: Amogh Vasekar <amogh.vasekar@citrix.com> Signed-off-by: John Kinsella <jlk@stratosec.co> 1394399081 -0700 (cherry picked from commit 2fe7aee) Signed-off-by: Animesh Chaturvedi <animesh@apache.org>
1 parent 859a78e commit ec4db7b

7 files changed

Lines changed: 41 additions & 12 deletions

File tree

‎engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,12 +793,21 @@ private String generateCopyUrl(String ipAddress, String dir, String path){
793793
String scheme = "http";
794794
boolean _sslCopy = false;
795795
String sslCfg = _configDao.getValue(Config.SecStorageEncryptCopy.toString());
796+
String _ssvmUrlDomain = _configDao.getValue("secstorage.ssl.cert.domain");
796797
if ( sslCfg != null ){
797798
_sslCopy = Boolean.parseBoolean(sslCfg);
798799
}
800+
if(_sslCopy && (_ssvmUrlDomain == null || _ssvmUrlDomain.isEmpty())){
801+
s_logger.warn("Empty secondary storage url domain, ignoring SSL");
802+
_sslCopy = false;
803+
}
799804
if (_sslCopy) {
800-
hostname = ipAddress.replace(".", "-");
801-
hostname = hostname + ".realhostip.com";
805+
if(_ssvmUrlDomain.startsWith("*")) {
806+
hostname = ipAddress.replace(".", "-");
807+
hostname = hostname + _ssvmUrlDomain.substring(1);
808+
} else {
809+
hostname = _ssvmUrlDomain;
810+
}
802811
scheme = "https";
803812
}
804813
return scheme + "://" + hostname + "/copy/SecStorage/" + dir + "/" + path;

‎plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackImageStoreDriverImpl.java‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,16 @@ private String generateCopyUrl(String ipAddress, String uuid){
9292
if ( sslCfg != null ){
9393
_sslCopy = Boolean.parseBoolean(sslCfg);
9494
}
95+
if(_sslCopy && (_ssvmUrlDomain == null || _ssvmUrlDomain.isEmpty())){
96+
s_logger.warn("Empty secondary storage url domain, ignoring SSL");
97+
_sslCopy = false;
98+
}
9599
if (_sslCopy) {
96-
hostname = ipAddress.replace(".", "-");
97-
if(_ssvmUrlDomain != null && _ssvmUrlDomain.length() > 0){
98-
hostname = hostname + "." + _ssvmUrlDomain;
100+
if(_ssvmUrlDomain.startsWith("*")) {
101+
hostname = ipAddress.replace(".", "-");
102+
hostname = hostname + _ssvmUrlDomain.substring(1);
99103
} else {
100-
hostname = hostname + ".realhostip.com";
104+
hostname = _ssvmUrlDomain;
101105
}
102106
scheme = "https";
103107
}

‎server/src/com/cloud/configuration/Config.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public enum Config {
118118
ConsoleProxyCapacityScanInterval("Console Proxy", AgentManager.class, String.class, "consoleproxy.capacityscan.interval", "30000", "The time interval(in millisecond) to scan whether or not system needs more console proxy to ensure minimal standby capacity", null),
119119
ConsoleProxyCmdPort("Console Proxy", AgentManager.class, Integer.class, "consoleproxy.cmd.port", "8001", "Console proxy command port that is used to communicate with management server", null),
120120
ConsoleProxyRestart("Console Proxy", AgentManager.class, Boolean.class, "consoleproxy.restart", "true", "Console proxy restart flag, defaulted to true", null),
121-
ConsoleProxyUrlDomain("Console Proxy", AgentManager.class, String.class, "consoleproxy.url.domain", "realhostip.com", "Console proxy url domain", null),
121+
ConsoleProxyUrlDomain("Console Proxy", AgentManager.class, String.class, "consoleproxy.url.domain", "", "Console proxy url domain", null),
122122
ConsoleProxyLoadscanInterval("Console Proxy", AgentManager.class, String.class, "consoleproxy.loadscan.interval", "10000", "The time interval(in milliseconds) to scan console proxy working-load info", null),
123123
ConsoleProxySessionMax("Console Proxy", AgentManager.class, Integer.class, "consoleproxy.session.max", String.valueOf(ConsoleProxyManager.DEFAULT_PROXY_CAPACITY), "The max number of viewer sessions console proxy is configured to serve for", null),
124124
ConsoleProxySessionTimeout("Console Proxy", AgentManager.class, Integer.class, "consoleproxy.session.timeout", "300000", "Timeout(in milliseconds) that console proxy tries to maintain a viewer session before it times out the session for no activity", null),
@@ -185,7 +185,7 @@ public enum Config {
185185
MaxTemplateAndIsoSize("Advanced", ManagementServer.class, Long.class, "max.template.iso.size", "50", "The maximum size for a downloaded template or ISO (in GB).", null),
186186
SecStorageAllowedInternalDownloadSites("Advanced", ManagementServer.class, String.class, "secstorage.allowed.internal.sites", null, "Comma separated list of cidrs internal to the datacenter that can host template download servers, please note 0.0.0.0 is not a valid site", null),
187187
SecStorageEncryptCopy("Advanced", ManagementServer.class, Boolean.class, "secstorage.encrypt.copy", "false", "Use SSL method used to encrypt copy traffic between zones", "true,false"),
188-
SecStorageSecureCopyCert("Advanced", ManagementServer.class, String.class, "secstorage.ssl.cert.domain", "realhostip.com", "SSL certificate used to encrypt copy traffic between zones", null),
188+
SecStorageSecureCopyCert("Advanced", ManagementServer.class, String.class, "secstorage.ssl.cert.domain", "", "SSL certificate used to encrypt copy traffic between zones", null),
189189
SecStorageCapacityStandby("Advanced", AgentManager.class, Integer.class, "secstorage.capacity.standby", "10", "The minimal number of command execution sessions that system is able to serve immediately(standby capacity)", null),
190190
SecStorageSessionMax("Advanced", AgentManager.class, Integer.class, "secstorage.session.max", "50", "The max number of command execution sessions that a SSVM can handle", null),
191191
SecStorageCmdExecutionTimeMax("Advanced", AgentManager.class, Integer.class, "secstorage.cmd.execution.time.max", "30", "The max command execution time in minute", null),

‎server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
249249

250250
private int _proxySessionTimeoutValue = DEFAULT_PROXY_SESSION_TIMEOUT;
251251
private boolean _sslEnabled = true;
252+
private String _consoleProxyUrlDomain;
252253

253254
// global load picture at zone basis
254255
private SystemVmLoadScanner<Long> _loadScanner;
@@ -402,9 +403,9 @@ public ConsoleProxyInfo assignProxy(final long dataCenterId, final long vmId) {
402403
assert (ksVo != null);
403404

404405
if (_staticPublicIp == null) {
405-
return new ConsoleProxyInfo(proxy.isSslEnabled(), proxy.getPublicIpAddress(), _consoleProxyPort, proxy.getPort(), ksVo.getDomainSuffix());
406+
return new ConsoleProxyInfo(proxy.isSslEnabled(), proxy.getPublicIpAddress(), _consoleProxyPort, proxy.getPort(), _consoleProxyUrlDomain);
406407
} else {
407-
return new ConsoleProxyInfo(proxy.isSslEnabled(), _staticPublicIp, _consoleProxyPort, _staticPort, ksVo.getDomainSuffix());
408+
return new ConsoleProxyInfo(proxy.isSslEnabled(), _staticPublicIp, _consoleProxyPort, _staticPort, _consoleProxyUrlDomain);
408409
}
409410
}
410411

@@ -1220,7 +1221,11 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
12201221
if (value != null && value.equalsIgnoreCase("true")) {
12211222
_sslEnabled = true;
12221223
}
1223-
1224+
_consoleProxyUrlDomain = configs.get(Config.ConsoleProxyUrlDomain.key());
1225+
if( _sslEnabled && (_consoleProxyUrlDomain == null || _consoleProxyUrlDomain.isEmpty())) {
1226+
s_logger.warn("Empty console proxy domain, explicitly disabling SSL");
1227+
_sslEnabled = false;
1228+
}
12241229
value = configs.get(Config.ConsoleProxyCapacityScanInterval.key());
12251230
_capacityScanInterval = NumbersUtil.parseLong(value, DEFAULT_CAPACITY_SCAN_INTERVAL);
12261231

‎server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,13 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
812812
_useSSlCopy = true;
813813
}
814814

815+
//default to HTTP in case of missing domain
816+
String ssvmUrlDomain = _configDao.getValue("secstorage.ssl.cert.domain");
817+
if(_useSSlCopy && (ssvmUrlDomain == null || ssvmUrlDomain.isEmpty())){
818+
s_logger.warn("Empty secondary storage url domain, explicitly disabling SSL");
819+
_useSSlCopy = false;
820+
}
821+
815822
_allowedInternalSites = _configDao.getValue("secstorage.allowed.internal.sites");
816823

817824
String value = configs.get("secstorage.capacityscan.interval");

‎setup/db/db/schema-421to430.sql‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ CREATE TABLE `cloud`.`async_job_join_map` (
110110
INDEX `i_async_job_join_map__expiration`(`expiration`)
111111
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
112112

113+
#realhostip changes, before changing table and adding default value
114+
UPDATE `cloud`.`configuration` SET value = CONCAT("*.",(SELECT `temptable`.`value` FROM (SELECT * FROM `cloud`.`configuration` WHERE `name`="consoleproxy.url.domain") AS `temptable` WHERE `temptable`.`name`="consoleproxy.url.domain")) WHERE `name`="consoleproxy.url.domain";
115+
UPDATE `cloud`.`configuration` SET `value` = CONCAT("*.",(SELECT `temptable`.`value` FROM (SELECT * FROM `cloud`.`configuration` WHERE `name`="secstorage.ssl.cert.domain") AS `temptable` WHERE `temptable`.`name`="secstorage.ssl.cert.domain")) WHERE `name`="secstorage.ssl.cert.domain";
116+
113117
ALTER TABLE `cloud`.`configuration` ADD COLUMN `default_value` VARCHAR(4095) COMMENT 'Default value for a configuration parameter';
114118
ALTER TABLE `cloud`.`configuration` ADD COLUMN `updated` datetime COMMENT 'Time this was updated by the server. null means this row is obsolete.';
115119
ALTER TABLE `cloud`.`configuration` ADD COLUMN `scope` VARCHAR(255) DEFAULT NULL COMMENT 'Can this parameter be scoped';

‎systemvm/conf/consoleproxy.properties‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# under the License.
1717

1818
consoleproxy.tcpListenPort=0
19-
consoleproxy.httpListenPort=8088
19+
consoleproxy.httpListenPort=80
2020
consoleproxy.httpCmdListenPort=8001
2121
consoleproxy.jarDir=./applet/
2222
consoleproxy.viewerLinger=180

0 commit comments

Comments
 (0)