@@ -230,8 +230,6 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
230230
231231 private ConsoleProxyListener consoleProxyListener ;
232232
233- private ServiceOfferingVO serviceOfferingVO ;
234-
235233 private long capacityScanInterval = DEFAULT_CAPACITY_SCAN_INTERVAL_IN_MILLISECONDS ;
236234
237235 private boolean useStorageVm ;
@@ -557,7 +555,7 @@ public ConsoleProxyVO assignProxyFromStoppedPool(long dataCenterId) {
557555 return null ;
558556 }
559557
560- public ConsoleProxyVO startNew (long dataCenterId ) throws ConcurrentOperationException {
558+ public ConsoleProxyVO startNew (long dataCenterId ) throws ConcurrentOperationException , ConfigurationException {
561559
562560 if (logger .isDebugEnabled ()) {
563561 logger .debug ("Assign console proxy from a newly started instance for request from data center : " + dataCenterId );
@@ -689,7 +687,7 @@ protected ConsoleProxyVO createOrUpdateConsoleProxy(ConsoleProxyVO proxy, long d
689687 return proxy ;
690688 }
691689
692- protected Map <String , Object > createProxyInstance (long dataCenterId , List <VMTemplateVO > templates ) throws ConcurrentOperationException {
690+ protected Map <String , Object > createProxyInstance (long dataCenterId , List <VMTemplateVO > templates ) throws ConcurrentOperationException , ConfigurationException {
693691
694692 long id = consoleProxyDao .getNextInSequence (Long .class , "id" );
695693 String name = VirtualMachineName .getConsoleProxyName (id , instance );
@@ -714,7 +712,7 @@ protected Map<String, Object> createProxyInstance(long dataCenterId, List<VMTemp
714712 networks .put (networkOrchestrationService .setupNetwork (systemAcct , offering , plan , null , null , false ).get (0 ), new ArrayList <>());
715713 }
716714
717- ServiceOfferingVO serviceOffering = serviceOfferingVO ;
715+ ServiceOfferingVO serviceOffering = getConsoleProxyServiceOffering ( dataCenterId ) ;
718716 if (serviceOffering == null ) {
719717 serviceOffering = serviceOfferingDao .findDefaultSystemOffering (ServiceOffering .consoleProxyDefaultOffUniqueName , ConfigurationManagerImpl .SystemVMUseLocalStorage .valueIn (dataCenterId ));
720718 }
@@ -841,7 +839,7 @@ private void allocCapacity(long dataCenterId) {
841839 if (allocProxyLock .lock (ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC_IN_SECONDS )) {
842840 try {
843841 proxy = startNew (dataCenterId );
844- } catch (ConcurrentOperationException e ) {
842+ } catch (ConcurrentOperationException | ConfigurationException e ) {
845843 logger .warn ("Unable to start new console proxy on zone [{}] due to [{}]." , zone , e .getMessage (), e );
846844 } finally {
847845 allocProxyLock .unlock ();
@@ -1131,9 +1129,6 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
11311129 }
11321130
11331131 Map <String , String > configs = configurationDao .getConfiguration ("management-server" , params );
1134- for (Map .Entry <String , String > entry : configs .entrySet ()) {
1135- logger .info ("PEARL - Configure console proxy manager : " + entry .getKey () + " = " + entry .getValue ());
1136- }
11371132
11381133 String value = ConsoleProxyCapacityScanInterval .value ();
11391134 capacityScanInterval = NumbersUtil .parseLong (value , DEFAULT_CAPACITY_SCAN_INTERVAL_IN_MILLISECONDS );
@@ -1164,37 +1159,6 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
11641159
11651160 virtualMachineManager .registerGuru (VirtualMachine .Type .ConsoleProxy , this );
11661161
1167- String configKey = Config .ConsoleProxyServiceOffering .key ();
1168- String cpvmSrvcOffIdStr = configs .get (configKey );
1169- if (cpvmSrvcOffIdStr != null ) {
1170- serviceOfferingVO = serviceOfferingDao .findByUuid (cpvmSrvcOffIdStr );
1171- if (serviceOfferingVO == null ) {
1172- try {
1173- logger .debug (String .format ("Unable to find a service offering by the UUID for console proxy VM with the value [%s] set in the configuration [%s]. Trying to find by the ID." , cpvmSrvcOffIdStr , configKey ));
1174- serviceOfferingVO = serviceOfferingDao .findById (Long .parseLong (cpvmSrvcOffIdStr ));
1175- } catch (NumberFormatException ex ) {
1176- logger .warn (String .format ("Unable to find a service offering by the ID for console proxy VM with the value [%s] set in the configuration [%s]. The value is not a valid integer number. Error: [%s]." , cpvmSrvcOffIdStr , configKey , ex .getMessage ()), ex );
1177- }
1178- }
1179- if (serviceOfferingVO == null ) {
1180- logger .warn (String .format ("Unable to find a service offering by the UUID or ID for console proxy VM with the value [%s] set in the configuration [%s]" , cpvmSrvcOffIdStr , configKey ));
1181- }
1182- }
1183-
1184- if (serviceOfferingVO == null || !serviceOfferingVO .isSystemUse ()) {
1185- int ramSize = NumbersUtil .parseInt (configurationDao .getValue ("console.ram.size" ), DEFAULT_PROXY_VM_RAMSIZE );
1186- int cpuFreq = NumbersUtil .parseInt (configurationDao .getValue ("console.cpu.mhz" ), DEFAULT_PROXY_VM_CPUMHZ );
1187- List <ServiceOfferingVO > offerings = serviceOfferingDao .createSystemServiceOfferings ("System Offering For Console Proxy" ,
1188- ServiceOffering .consoleProxyDefaultOffUniqueName , 1 , ramSize , cpuFreq , 0 , 0 , false , null ,
1189- Storage .ProvisioningType .THIN , true , null , true , VirtualMachine .Type .ConsoleProxy , true );
1190-
1191- if (offerings == null || offerings .size () < 2 ) {
1192- String msg = "Data integrity problem : System Offering For Console Proxy has been removed?" ;
1193- logger .error (msg );
1194- throw new ConfigurationException (msg );
1195- }
1196- }
1197-
11981162 loadScanner = new SystemVmLoadScanner <>(this );
11991163 loadScanner .initScan (STARTUP_DELAY_IN_MILLISECONDS , capacityScanInterval );
12001164 resourceManager .registerResourceStateAdapter (this .getClass ().getSimpleName (), this );
@@ -1656,4 +1620,40 @@ private boolean isSslEnabled(Long dataCenterId) {
16561620 private Integer getStandbyCapacity (Long datacenterId ) {
16571621 return Integer .parseInt (ConsoleProxyCapacityStandby .valueIn (datacenterId ));
16581622 }
1623+
1624+ private ServiceOfferingVO getConsoleProxyServiceOffering (Long datacenterId ) throws ConfigurationException {
1625+ String configKey = ConsoleProxyServiceOffering .key ();
1626+ String cpvmSrvcOffIdStr = ConsoleProxyServiceOffering .valueIn (datacenterId );
1627+ String warningMessage = String .format ("Unable to find a service offering by the UUID or ID for console proxy VM with the value [%s] set in the configuration [%s]" , cpvmSrvcOffIdStr , configKey );
1628+ ServiceOfferingVO serviceOfferingVO = null ;
1629+ if (cpvmSrvcOffIdStr != null ) {
1630+ serviceOfferingVO = serviceOfferingDao .findByUuid (cpvmSrvcOffIdStr );
1631+ if (serviceOfferingVO == null ) {
1632+ try {
1633+ logger .debug (warningMessage );
1634+ serviceOfferingVO = serviceOfferingDao .findById (Long .parseLong (cpvmSrvcOffIdStr ));
1635+ } catch (NumberFormatException ex ) {
1636+ logger .warn (String .format ("Unable to find a service offering by the ID for console proxy VM with the value [%s] set in the configuration [%s]. The value is not a valid integer number. Error: [%s]." , cpvmSrvcOffIdStr , configKey , ex .getMessage ()), ex );
1637+ }
1638+ }
1639+ if (serviceOfferingVO == null ) {
1640+ logger .warn (warningMessage );
1641+ }
1642+ }
1643+
1644+ if (serviceOfferingVO == null || !serviceOfferingVO .isSystemUse ()) {
1645+ int ramSize = NumbersUtil .parseInt (configurationDao .getValue ("console.ram.size" ), DEFAULT_PROXY_VM_RAMSIZE );
1646+ int cpuFreq = NumbersUtil .parseInt (configurationDao .getValue ("console.cpu.mhz" ), DEFAULT_PROXY_VM_CPUMHZ );
1647+ List <ServiceOfferingVO > offerings = serviceOfferingDao .createSystemServiceOfferings ("System Offering For Console Proxy" ,
1648+ ServiceOffering .consoleProxyDefaultOffUniqueName , 1 , ramSize , cpuFreq , 0 , 0 , false , null ,
1649+ Storage .ProvisioningType .THIN , true , null , true , VirtualMachine .Type .ConsoleProxy , true );
1650+
1651+ if (offerings == null || offerings .size () < 2 ) {
1652+ String msg = "Data integrity problem : System Offering For Console Proxy has been removed?" ;
1653+ logger .error (msg );
1654+ throw new ConfigurationException (msg );
1655+ }
1656+ }
1657+ return serviceOfferingVO ;
1658+ }
16591659}
0 commit comments