From e53cfeceb6f24a1cada75fdfbcaad41e693109a8 Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Mon, 19 Mar 2012 16:18:37 -0700 Subject: [PATCH] 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) --- server/src/com/cloud/api/ApiServer.java | 12 ++++++++---- server/src/com/cloud/configuration/Config.java | 2 +- .../src/com/cloud/template/TemplateAdapter.java | 2 +- .../com/cloud/template/TemplateAdapterBase.java | 15 ++------------- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java index 83d47cf439a..aa71cdc28d2 100755 --- a/server/src/com/cloud/api/ApiServer.java +++ b/server/src/com/cloud/api/ApiServer.java @@ -278,14 +278,16 @@ public class ApiServer implements HttpRequestHandler { _dispatcher = ApiDispatcher.getInstance(); _domainMgr = locator.getManager(DomainManager.class); - int apiPort = 8096; // default port + Integer apiPort = null; // api port, null by default ConfigurationDao configDao = locator.getDao(ConfigurationDao.class); SearchCriteria sc = configDao.createSearchCriteria(); sc.addAnd("name", SearchCriteria.Op.EQ, "integration.api.port"); List values = configDao.search(sc, null); if ((values != null) && (values.size() > 0)) { ConfigurationVO apiPortConfig = values.get(0); - apiPort = Integer.parseInt(apiPortConfig.getValue()); + if (apiPortConfig.getValue() != null) { + apiPort = Integer.parseInt(apiPortConfig.getValue()); + } } encodeApiResponse = Boolean.valueOf(configDao.getValue(Config.EncodeApiResponse.key())); @@ -295,8 +297,10 @@ public class ApiServer implements HttpRequestHandler { jsonContentType = jsonType; } - ListenerThread listenerThread = new ListenerThread(this, apiPort); - listenerThread.start(); + if (apiPort != null) { + ListenerThread listenerThread = new ListenerThread(this, apiPort); + listenerThread.start(); + } } @SuppressWarnings({ "unchecked", "rawtypes" }) diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index 6d7f7641de2..520960958b8 100755 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -154,7 +154,7 @@ public enum Config { ExtractURLExpirationInterval("Advanced", ManagementServer.class, Integer.class, "extract.url.expiration.interval", "14400", "The life of an extract URL after which it is deleted ", null), HostStatsInterval("Advanced", ManagementServer.class, Integer.class, "host.stats.interval", "60000", "The interval (in milliseconds) when host stats are retrieved from agents.", null), HostRetry("Advanced", AgentManager.class, Integer.class, "host.retry", "2", "Number of times to retry hosts for creating a volume", null), - IntegrationAPIPort("Advanced", ManagementServer.class, Integer.class, "integration.api.port", "8096", "Defaul API port", null), + IntegrationAPIPort("Advanced", ManagementServer.class, Integer.class, "integration.api.port", null, "Defaul API port", null), InvestigateRetryInterval("Advanced", HighAvailabilityManager.class, Integer.class, "investigate.retry.interval", "60", "Time (in seconds) between VM pings when agent is disconnected", null), MigrateRetryInterval("Advanced", HighAvailabilityManager.class, Integer.class, "migrate.retry.interval", "120", "Time (in seconds) between migration retries", null), PingInterval("Advanced", AgentManager.class, Integer.class, "ping.interval", "60", "Ping interval in seconds", null), diff --git a/server/src/com/cloud/template/TemplateAdapter.java b/server/src/com/cloud/template/TemplateAdapter.java index 3ca0819c808..c3195036f26 100755 --- a/server/src/com/cloud/template/TemplateAdapter.java +++ b/server/src/com/cloud/template/TemplateAdapter.java @@ -45,7 +45,7 @@ public interface TemplateAdapter extends Adapter { Boolean isExtractable, String format, Long guestOSId, Long zoneId, HypervisorType hypervisorType, String accountName, Long domainId, String chksum, Boolean bootable, Map details) throws ResourceAllocationException; - public TemplateProfile prepare(boolean isIso, Long userId, String name, String displayText, Integer bits, + public TemplateProfile prepare(boolean isIso, long userId, String name, String displayText, Integer bits, Boolean passwordEnabled, Boolean requiresHVM, String url, Boolean isPublic, Boolean featured, Boolean isExtractable, String format, Long guestOSId, Long zoneId, HypervisorType hypervisorType, String chksum, Boolean bootable, String templateTag, Account templateOwner, Map details, Boolean sshKeyEnabled) throws ResourceAllocationException; diff --git a/server/src/com/cloud/template/TemplateAdapterBase.java b/server/src/com/cloud/template/TemplateAdapterBase.java index 28ef42403be..084940f427a 100755 --- a/server/src/com/cloud/template/TemplateAdapterBase.java +++ b/server/src/com/cloud/template/TemplateAdapterBase.java @@ -96,7 +96,7 @@ public abstract class TemplateAdapterBase implements TemplateAdapter { chksum, bootable, null, null, details, false); } - public TemplateProfile prepare(boolean isIso, Long userId, String name, String displayText, Integer bits, + public TemplateProfile prepare(boolean isIso, long userId, String name, String displayText, Integer bits, Boolean passwordEnabled, Boolean requiresHVM, String url, Boolean isPublic, Boolean featured, Boolean isExtractable, String format, Long guestOSId, Long zoneId, HypervisorType hypervisorType, String chksum, Boolean bootable, String templateTag, Account templateOwner, Map details, Boolean sshkeyEnabled) throws ResourceAllocationException { @@ -159,12 +159,6 @@ public abstract class TemplateAdapterBase implements TemplateAdapter { if (!isAdmin || featured == null) { featured = Boolean.FALSE; } - - // If command is executed via 8096 port, set userId to the id of System - // account (1) - if (userId == null) { - userId = Long.valueOf(1); - } ImageFormat imgfmt = ImageFormat.valueOf(format.toUpperCase()); if (imgfmt == null) { @@ -258,7 +252,7 @@ public abstract class TemplateAdapterBase implements TemplateAdapter { } - private Long accountAndUserValidation(Account account, Long userId, UserVmVO vmInstanceCheck, VMTemplateVO template, String msg) + private Long accountAndUserValidation(Account account, long userId, UserVmVO vmInstanceCheck, VMTemplateVO template, String msg) throws PermissionDeniedException { if (account != null) { @@ -287,11 +281,6 @@ public abstract class TemplateAdapterBase implements TemplateAdapter { } } } - // If command is executed via 8096 port, set userId to the id of System - // account (1) - if (userId == null) { - userId = new Long(1); - } return userId; }