Skip to content

Commit b8c2c3b

Browse files
committed
move consoleproxy service offering to zone level
1 parent 317696f commit b8c2c3b

File tree

3 files changed

+43
-51
lines changed

3 files changed

+43
-51
lines changed

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,6 @@ public enum Config {
403403
"service monitoring in router enable/disable option, default false", null),
404404

405405

406-
// Console Proxy
407-
408-
409406
// Snapshots
410407

411408
SnapshotPollInterval(
@@ -1499,14 +1496,6 @@ public enum Config {
14991496
"false",
15001497
"Should be set to true, if there will be multiple NetScaler devices providing EIP service in a zone",
15011498
null),
1502-
ConsoleProxyServiceOffering(
1503-
"Advanced",
1504-
ManagementServer.class,
1505-
String.class,
1506-
"consoleproxy.service.offering",
1507-
null,
1508-
"Uuid of the service offering used by console proxy; if NULL - system offering will be used",
1509-
null),
15101499
SecondaryStorageServiceOffering(
15111500
"Advanced",
15121501
ManagementServer.class,

server/src/main/java/com/cloud/consoleproxy/ConsoleProxyManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ public interface ConsoleProxyManager extends Manager, ConsoleProxyService {
5656
ConfigKey<Boolean> NoVncConsoleSourceIpCheckEnabled = new ConfigKey<>(ConfigKey.CATEGORY_ADVANCED, Boolean.class, "novnc.console.sourceip.check.enabled", "false",
5757
"If true, The source IP to access novnc console must be same as the IP in request to management server for console URL. Needs to reconnect CPVM to management server when this changes (via restart CPVM, or management server, or cloud service in CPVM)", false);
5858

59+
ConfigKey<String> ConsoleProxyServiceOffering = new ConfigKey<>(String.class, "consoleproxy.service.offering", "Console Proxy", null,
60+
"Uuid of the service offering used by console proxy; if NULL - system offering will be used", false, ConfigKey.Scope.Zone, null);
61+
5962
ConfigKey<String> ConsoleProxyCapacityStandby = new ConfigKey<>(String.class, "consoleproxy.capacity.standby", "Console Proxy", String.valueOf(DEFAULT_STANDBY_CAPACITY),
6063
"The minimal number of console proxy viewer sessions that system is able to serve immediately(standby capacity)", false, ConfigKey.Scope.Zone, null);
6164

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

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)