@@ -233,17 +233,10 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
233233 private ServiceOfferingVO serviceOfferingVO ;
234234
235235 private long capacityScanInterval = DEFAULT_CAPACITY_SCAN_INTERVAL_IN_MILLISECONDS ;
236- private int capacityPerProxy = ConsoleProxyManager .DEFAULT_PROXY_CAPACITY ;
237- private int standbyCapacity = ConsoleProxyManager .DEFAULT_STANDBY_CAPACITY ;
238236
239237 private boolean useStorageVm ;
240- private boolean disableRpFilter = false ;
241238 private String instance ;
242239
243- private int proxySessionTimeoutValue = DEFAULT_PROXY_SESSION_TIMEOUT ;
244- private boolean sslEnabled = false ;
245- private String consoleProxyUrlDomain ;
246-
247240 private SystemVmLoadScanner <Long > loadScanner ;
248241 private Map <Long , ZoneHostInfo > zoneHostInfoMap ;
249242 private Map <Long , ConsoleProxyLoadInfo > zoneProxyCountMap ;
@@ -342,7 +335,7 @@ public ConsoleProxyInfo assignProxy(final long dataCenterId, final VMInstanceVO
342335 logger .warn (String .format ("SSL is enabled for console proxy [%s] but no server certificate found in database." , proxy .toString ()));
343336 }
344337
345- consoleProxyUrlDomain = ConsoleProxyUrlDomain .valueIn (dataCenterId );
338+ String consoleProxyUrlDomain = ConsoleProxyUrlDomain .valueIn (dataCenterId );
346339 ConsoleProxyInfo info ;
347340 if (staticPublicIp == null ) {
348341 info = new ConsoleProxyInfo (proxy .isSslEnabled (), proxy .getPublicIpAddress (), consoleProxyPort , proxy .getPort (), consoleProxyUrlDomain );
@@ -375,6 +368,7 @@ public ConsoleProxyVO doAssignProxy(long dataCenterId, VMInstanceVO vm) {
375368 }
376369 proxy = null ;
377370 } else {
371+ long capacityPerProxy = ConsoleProxySessionMax .valueIn (dataCenterId );
378372 if (consoleProxyDao .getProxyActiveLoad (proxy .getId ()) < capacityPerProxy || hasPreviousSession (proxy , vm )) {
379373 if (logger .isDebugEnabled ()) {
380374 logger .debug ("Assign previous allocated console proxy for user vm: {}" , vm );
@@ -409,7 +403,7 @@ public ConsoleProxyVO doAssignProxy(long dataCenterId, VMInstanceVO vm) {
409403 if (vm .getProxyId () == null || vm .getProxyId () != proxy .getId ()) {
410404 vmInstanceDao .updateProxyId (vm .getId (), proxy .getId (), DateUtil .currentGMTTime ());
411405 }
412-
406+ boolean sslEnabled = isSslEnabled ( dataCenterId );
413407 proxy .setSslEnabled (sslEnabled );
414408 if (sslEnabled ) {
415409 proxy .setPort (443 );
@@ -452,6 +446,7 @@ private boolean hasPreviousSession(ConsoleProxyVO proxy, VMInstanceVO vm) {
452446 }
453447 }
454448
449+ Integer proxySessionTimeoutValue = ConsoleProxySessionTimeout .valueIn (proxy .getDataCenterId ());
455450 return DateUtil .currentGMTTime ().getTime () - vm .getProxyAssignTime ().getTime () < proxySessionTimeoutValue ;
456451 } else {
457452 logger .warn (String .format ("Unable to retrieve load info from proxy [%s] on an overloaded proxy." , proxy .toString ()));
@@ -501,6 +496,8 @@ public ConsoleProxyVO assignProxyFromRunningPool(long dataCenterId) {
501496 logger .debug ("Assign console proxy from running pool for request from data center: {}" , zone );
502497 }
503498
499+ long capacityPerProxy = ConsoleProxySessionMax .valueIn (dataCenterId );
500+
504501 ConsoleProxyAllocator allocator = getCurrentAllocator ();
505502 assert (allocator != null );
506503 List <ConsoleProxyVO > runningList = consoleProxyDao .getProxyListInStates (dataCenterId , State .Running );
@@ -820,8 +817,9 @@ private boolean allowToLaunchNew(long dcId) {
820817 return l .size () < launchLimit ;
821818 }
822819
823- private boolean checkCapacity (ConsoleProxyLoadInfo proxyCountInfo , ConsoleProxyLoadInfo vmCountInfo ) {
824- return proxyCountInfo .getCount () * capacityPerProxy - vmCountInfo .getCount () > standbyCapacity ;
820+ private boolean checkCapacity (ConsoleProxyLoadInfo proxyCountInfo , ConsoleProxyLoadInfo vmCountInfo , long dataCenterId ) {
821+ long capacityPerProxy = ConsoleProxySessionMax .valueIn (dataCenterId );
822+ return proxyCountInfo .getCount () * capacityPerProxy - vmCountInfo .getCount () > getStandbyCapacity (dataCenterId );
825823 }
826824
827825 private void allocCapacity (long dataCenterId ) {
@@ -1118,8 +1116,8 @@ public boolean destroyProxy(long vmId) {
11181116 }
11191117
11201118 @ Override
1121- public int getVncPort () {
1122- return sslEnabled && _ksDao .findByName (ConsoleProxyManager .CERTIFICATE_NAME ) != null ? 8443 : 8080 ;
1119+ public int getVncPort (Long dataCenterId ) {
1120+ return isSslEnabled ( dataCenterId ) && _ksDao .findByName (ConsoleProxyManager .CERTIFICATE_NAME ) != null ? 8443 : 8080 ;
11231121 }
11241122
11251123 private String getAllocProxyLockName () {
@@ -1136,44 +1134,20 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
11361134 for (Map .Entry <String , String > entry : configs .entrySet ()) {
11371135 logger .info ("PEARL - Configure console proxy manager : " + entry .getKey () + " = " + entry .getValue ());
11381136 }
1139- String value = configs .get (ConsoleProxySslEnabled .key ());
1140- if (value != null && value .equalsIgnoreCase ("true" )) {
1141- sslEnabled = true ;
1142- }
11431137
1144- consoleProxyUrlDomain = ConsoleProxyUrlDomain .value ();
1145- if ( sslEnabled && (consoleProxyUrlDomain == null || consoleProxyUrlDomain .isEmpty ())) {
1146- logger .warn ("Empty console proxy domain, explicitly disabling SSL" );
1147- sslEnabled = false ;
1148- }
1149-
1150- value = ConsoleProxyCapacityScanInterval .value ();
1138+ String value = ConsoleProxyCapacityScanInterval .value ();
11511139 capacityScanInterval = NumbersUtil .parseLong (value , DEFAULT_CAPACITY_SCAN_INTERVAL_IN_MILLISECONDS );
11521140
1153- capacityPerProxy = NumbersUtil .parseInt (configs .get ("consoleproxy.session.max" ), DEFAULT_PROXY_CAPACITY );
1154- standbyCapacity = NumbersUtil .parseInt (ConsoleProxyCapacityStandby .value (), DEFAULT_STANDBY_CAPACITY );
1155- proxySessionTimeoutValue = NumbersUtil .parseInt (configs .get ("consoleproxy.session.timeout" ), DEFAULT_PROXY_SESSION_TIMEOUT );
1156-
11571141 value = configs .get ("consoleproxy.port" );
11581142 if (value != null ) {
11591143 consoleProxyPort = NumbersUtil .parseInt (value , ConsoleProxyManager .DEFAULT_PROXY_VNC_PORT );
11601144 }
11611145
1162- Boolean rpFilterDisabled = ConsoleProxyDisableRpFilter .value ();
1163- if (Boolean .TRUE .equals (rpFilterDisabled )) {
1164- disableRpFilter = true ;
1165- }
1166-
11671146 value = configs .get ("secondary.storage.vm" );
11681147 if (value != null && value .equalsIgnoreCase ("true" )) {
11691148 useStorageVm = true ;
11701149 }
11711150
1172- if (logger .isInfoEnabled ()) {
1173- logger .info ("Console proxy max session soft limit : " + capacityPerProxy );
1174- logger .info ("Console proxy standby capacity : " + standbyCapacity );
1175- }
1176-
11771151 instance = configs .get ("instance.name" );
11781152 if (instance == null ) {
11791153 instance = "DEFAULT" ;
@@ -1255,16 +1229,16 @@ public boolean finalizeVirtualMachineProfile(VirtualMachineProfile profile, Depl
12551229 buf .append (" host=" ).append (StringUtils .toCSVList (indirectAgentLB .getManagementServerList (dest .getHost ().getId (), dest .getDataCenter ().getId (), null )));
12561230 buf .append (" port=" ).append (managementPort );
12571231 buf .append (" name=" ).append (profile .getVirtualMachine ().getHostName ());
1258- if (sslEnabled ) {
1232+ if (isSslEnabled ( dest . getDataCenter (). getId ()) ) {
12591233 buf .append (" premium=true" );
12601234 }
12611235 Long datacenterId = dest .getDataCenter ().getId ();
12621236 buf .append (" zone=" ).append (datacenterId );
12631237 buf .append (" pod=" ).append (dest .getPod ().getId ());
12641238 buf .append (" guid=Proxy." ).append (profile .getId ());
12651239 buf .append (" proxy_vm=" ).append (profile .getId ());
1266- disableRpFilter = ConsoleProxyDisableRpFilter .valueIn (datacenterId );
1267- if (disableRpFilter ) {
1240+ Boolean disableRpFilter = ConsoleProxyDisableRpFilter .valueIn (datacenterId );
1241+ if (Boolean . TRUE . equals ( disableRpFilter ) ) {
12681242 buf .append (" disable_rp_filter=true" );
12691243 }
12701244
@@ -1324,7 +1298,7 @@ public boolean finalizeVirtualMachineProfile(VirtualMachineProfile profile, Depl
13241298 buf .append (" dns2=" ).append (dc .getDns2 ());
13251299 }
13261300 if (VirtualMachine .Type .ConsoleProxy == profile .getVirtualMachine ().getType ()) {
1327- buf .append (" vncport=" ).append (getVncPort ());
1301+ buf .append (" vncport=" ).append (getVncPort (datacenterId ));
13281302 }
13291303 buf .append (" keystore_password=" ).append (VirtualMachineGuru .getEncodedString (PasswordGenerator .generateRandomPassword (16 )));
13301304 String bootArgs = buf .toString ();
@@ -1557,7 +1531,7 @@ public Pair<AfterScanAction, Object> scanPool(Long dataCenterId) {
15571531 vmInfo = new ConsoleProxyLoadInfo ();
15581532 }
15591533
1560- if (!checkCapacity (proxyInfo , vmInfo )) {
1534+ if (!checkCapacity (proxyInfo , vmInfo , dataCenterId )) {
15611535 if (logger .isDebugEnabled ()) {
15621536 logger .debug ("Expand console proxy standby capacity for zone " + proxyInfo .getName ());
15631537 }
@@ -1632,7 +1606,9 @@ public String getConfigComponentName() {
16321606
16331607 @ Override
16341608 public ConfigKey <?>[] getConfigKeys () {
1635- return new ConfigKey <?>[] { ConsoleProxySslEnabled , NoVncConsoleDefault , NoVncConsoleSourceIpCheckEnabled };
1609+ return new ConfigKey <?>[] { ConsoleProxySslEnabled , NoVncConsoleDefault , NoVncConsoleSourceIpCheckEnabled ,
1610+ ConsoleProxyCapacityStandby , ConsoleProxyCapacityScanInterval , ConsoleProxyCmdPort , ConsoleProxyRestart , ConsoleProxyUrlDomain , ConsoleProxySessionMax , ConsoleProxySessionTimeout , ConsoleProxyDisableRpFilter , ConsoleProxyLaunchMax ,
1611+ ConsoleProxyManagementLastState , ConsoleProxyServiceManagementState };
16361612 }
16371613
16381614 protected ConsoleProxyStatus parseJsonToConsoleProxyStatus (String json ) throws JsonParseException {
@@ -1666,4 +1642,18 @@ protected void updateConsoleProxyStatus(String statusInfo, Long proxyVmId) {
16661642
16671643 consoleProxyDao .update (proxyVmId , count , DateUtil .currentGMTTime (), details );
16681644 }
1645+
1646+ private boolean isSslEnabled (Long dataCenterId ) {
1647+ boolean sslEnabled = ConsoleProxySslEnabled .valueIn (dataCenterId );
1648+ String consoleProxyUrlDomain = ConsoleProxyUrlDomain .valueIn (dataCenterId );
1649+ if ( sslEnabled && (consoleProxyUrlDomain == null || consoleProxyUrlDomain .isEmpty ())) {
1650+ logger .warn ("Empty console proxy domain, explicitly disabling SSL" );
1651+ sslEnabled = false ;
1652+ }
1653+ return sslEnabled ;
1654+ }
1655+
1656+ private Integer getStandbyCapacity (Long datacenterId ) {
1657+ return Integer .parseInt (ConsoleProxyCapacityStandby .valueIn (datacenterId ));
1658+ }
16691659}
0 commit comments