Skip to content

Commit e53cfec

Browse files
author
Alena Prokharchyk
committed
bug 14379: don't enable 8096 port by default (set global config variable to null by default, and don't create a listener on this port unless its set to valid integer)
1 parent 20acc4d commit e53cfec

4 files changed

Lines changed: 12 additions & 19 deletions

File tree

‎server/src/com/cloud/api/ApiServer.java‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,16 @@ public void init(String[] apiConfig) {
278278
_dispatcher = ApiDispatcher.getInstance();
279279
_domainMgr = locator.getManager(DomainManager.class);
280280

281-
int apiPort = 8096; // default port
281+
Integer apiPort = null; // api port, null by default
282282
ConfigurationDao configDao = locator.getDao(ConfigurationDao.class);
283283
SearchCriteria<ConfigurationVO> sc = configDao.createSearchCriteria();
284284
sc.addAnd("name", SearchCriteria.Op.EQ, "integration.api.port");
285285
List<ConfigurationVO> values = configDao.search(sc, null);
286286
if ((values != null) && (values.size() > 0)) {
287287
ConfigurationVO apiPortConfig = values.get(0);
288-
apiPort = Integer.parseInt(apiPortConfig.getValue());
288+
if (apiPortConfig.getValue() != null) {
289+
apiPort = Integer.parseInt(apiPortConfig.getValue());
290+
}
289291
}
290292

291293
encodeApiResponse = Boolean.valueOf(configDao.getValue(Config.EncodeApiResponse.key()));
@@ -295,8 +297,10 @@ public void init(String[] apiConfig) {
295297
jsonContentType = jsonType;
296298
}
297299

298-
ListenerThread listenerThread = new ListenerThread(this, apiPort);
299-
listenerThread.start();
300+
if (apiPort != null) {
301+
ListenerThread listenerThread = new ListenerThread(this, apiPort);
302+
listenerThread.start();
303+
}
300304
}
301305

302306
@SuppressWarnings({ "unchecked", "rawtypes" })

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public enum Config {
154154
ExtractURLExpirationInterval("Advanced", ManagementServer.class, Integer.class, "extract.url.expiration.interval", "14400", "The life of an extract URL after which it is deleted ", null),
155155
HostStatsInterval("Advanced", ManagementServer.class, Integer.class, "host.stats.interval", "60000", "The interval (in milliseconds) when host stats are retrieved from agents.", null),
156156
HostRetry("Advanced", AgentManager.class, Integer.class, "host.retry", "2", "Number of times to retry hosts for creating a volume", null),
157-
IntegrationAPIPort("Advanced", ManagementServer.class, Integer.class, "integration.api.port", "8096", "Defaul API port", null),
157+
IntegrationAPIPort("Advanced", ManagementServer.class, Integer.class, "integration.api.port", null, "Defaul API port", null),
158158
InvestigateRetryInterval("Advanced", HighAvailabilityManager.class, Integer.class, "investigate.retry.interval", "60", "Time (in seconds) between VM pings when agent is disconnected", null),
159159
MigrateRetryInterval("Advanced", HighAvailabilityManager.class, Integer.class, "migrate.retry.interval", "120", "Time (in seconds) between migration retries", null),
160160
PingInterval("Advanced", AgentManager.class, Integer.class, "ping.interval", "60", "Ping interval in seconds", null),

‎server/src/com/cloud/template/TemplateAdapter.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public TemplateProfile prepare(boolean isIso, Long userId, String name, String d
4545
Boolean isExtractable, String format, Long guestOSId, Long zoneId, HypervisorType hypervisorType,
4646
String accountName, Long domainId, String chksum, Boolean bootable, Map details) throws ResourceAllocationException;
4747

48-
public TemplateProfile prepare(boolean isIso, Long userId, String name, String displayText, Integer bits,
48+
public TemplateProfile prepare(boolean isIso, long userId, String name, String displayText, Integer bits,
4949
Boolean passwordEnabled, Boolean requiresHVM, String url, Boolean isPublic, Boolean featured,
5050
Boolean isExtractable, String format, Long guestOSId, Long zoneId, HypervisorType hypervisorType,
5151
String chksum, Boolean bootable, String templateTag, Account templateOwner, Map details, Boolean sshKeyEnabled) throws ResourceAllocationException;

‎server/src/com/cloud/template/TemplateAdapterBase.java‎

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public TemplateProfile prepare(boolean isIso, Long userId, String name, String d
9696
chksum, bootable, null, null, details, false);
9797
}
9898

99-
public TemplateProfile prepare(boolean isIso, Long userId, String name, String displayText, Integer bits,
99+
public TemplateProfile prepare(boolean isIso, long userId, String name, String displayText, Integer bits,
100100
Boolean passwordEnabled, Boolean requiresHVM, String url, Boolean isPublic, Boolean featured,
101101
Boolean isExtractable, String format, Long guestOSId, Long zoneId, HypervisorType hypervisorType,
102102
String chksum, Boolean bootable, String templateTag, Account templateOwner, Map details, Boolean sshkeyEnabled) throws ResourceAllocationException {
@@ -159,12 +159,6 @@ public TemplateProfile prepare(boolean isIso, Long userId, String name, String d
159159
if (!isAdmin || featured == null) {
160160
featured = Boolean.FALSE;
161161
}
162-
163-
// If command is executed via 8096 port, set userId to the id of System
164-
// account (1)
165-
if (userId == null) {
166-
userId = Long.valueOf(1);
167-
}
168162

169163
ImageFormat imgfmt = ImageFormat.valueOf(format.toUpperCase());
170164
if (imgfmt == null) {
@@ -258,7 +252,7 @@ protected VMTemplateVO persistTemplate(TemplateProfile profile) {
258252
}
259253

260254

261-
private Long accountAndUserValidation(Account account, Long userId, UserVmVO vmInstanceCheck, VMTemplateVO template, String msg)
255+
private Long accountAndUserValidation(Account account, long userId, UserVmVO vmInstanceCheck, VMTemplateVO template, String msg)
262256
throws PermissionDeniedException {
263257

264258
if (account != null) {
@@ -287,11 +281,6 @@ private Long accountAndUserValidation(Account account, Long userId, UserVmVO vmI
287281
}
288282
}
289283
}
290-
// If command is executed via 8096 port, set userId to the id of System
291-
// account (1)
292-
if (userId == null) {
293-
userId = new Long(1);
294-
}
295284

296285
return userId;
297286
}

0 commit comments

Comments
 (0)