|
155 | 155 | // |
156 | 156 | @Local(value = { ConsoleProxyManager.class, ConsoleProxyService.class }) |
157 | 157 | public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxyManager, |
158 | | - VirtualMachineGuru, SystemVmLoadScanHandler<Long>, ResourceStateAdapter { |
| 158 | +VirtualMachineGuru, SystemVmLoadScanHandler<Long>, ResourceStateAdapter { |
159 | 159 | private static final Logger s_logger = Logger.getLogger(ConsoleProxyManagerImpl.class); |
160 | 160 |
|
161 | 161 | private static final int DEFAULT_CAPACITY_SCAN_INTERVAL = 30000; // 30 seconds |
@@ -558,7 +558,7 @@ public ConsoleProxyVO startProxy(long proxyVmId) { |
558 | 558 |
|
559 | 559 | // For VMs that are in Stopping, Starting, Migrating state, let client to wait by returning null |
560 | 560 | // as sooner or later, Starting/Migrating state will be transited to Running and Stopping will be transited |
561 | | -// to |
| 561 | + // to |
562 | 562 | // Stopped to allow |
563 | 563 | // Starting of it |
564 | 564 | s_logger.warn("Console proxy is not in correct state to be started: " + proxy.getState()); |
@@ -661,7 +661,7 @@ public ConsoleProxyVO startNew(long dataCenterId) throws ConcurrentOperationExce |
661 | 661 | HypervisorType availableHypervisor = _resourceMgr.getAvailableHypervisor(dataCenterId); |
662 | 662 | template = _templateDao.findSystemVMReadyTemplate(dataCenterId, availableHypervisor); |
663 | 663 | if (template == null) { |
664 | | - throw new CloudRuntimeException("Not able to find the System templates or not downloaded in zone " + dataCenterId); |
| 664 | + throw new CloudRuntimeException("Not able to find the System templates or not downloaded in zone " + dataCenterId); |
665 | 665 | } |
666 | 666 |
|
667 | 667 | Map<String, Object> context = createProxyInstance(dataCenterId, template); |
@@ -707,18 +707,18 @@ protected Map<String, Object> createProxyInstance(long dataCenterId, VMTemplateV |
707 | 707 | } |
708 | 708 | defaultNetwork = networks.get(0); |
709 | 709 | } else { |
710 | | - TrafficType defaultTrafficType = TrafficType.Public; |
711 | | - if (dc.getNetworkType() == NetworkType.Basic || dc.isSecurityGroupEnabled()) { |
712 | | - defaultTrafficType = TrafficType.Guest; |
713 | | - } |
714 | | - List<NetworkVO> defaultNetworks = _networkDao.listByZoneAndTrafficType(dataCenterId, defaultTrafficType); |
| 710 | + TrafficType defaultTrafficType = TrafficType.Public; |
| 711 | + if (dc.getNetworkType() == NetworkType.Basic || dc.isSecurityGroupEnabled()) { |
| 712 | + defaultTrafficType = TrafficType.Guest; |
| 713 | + } |
| 714 | + List<NetworkVO> defaultNetworks = _networkDao.listByZoneAndTrafficType(dataCenterId, defaultTrafficType); |
715 | 715 |
|
716 | 716 | // api should never allow this situation to happen |
717 | | - if (defaultNetworks.size() != 1) { |
| 717 | + if (defaultNetworks.size() != 1) { |
718 | 718 | throw new CloudRuntimeException("Found " + defaultNetworks.size() + " networks of type " |
719 | | - + defaultTrafficType + " when expect to find 1"); |
| 719 | + + defaultTrafficType + " when expect to find 1"); |
720 | 720 | } |
721 | | - defaultNetwork = defaultNetworks.get(0); |
| 721 | + defaultNetwork = defaultNetworks.get(0); |
722 | 722 | } |
723 | 723 |
|
724 | 724 | List<? extends NetworkOffering> offerings = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemControlNetwork, NetworkOffering.SystemManagementNetwork); |
@@ -951,7 +951,13 @@ public boolean isZoneReady(Map<Long, ZoneHostInfo> zoneHostInfoMap, long dataCen |
951 | 951 | ZoneHostInfo zoneHostInfo = zoneHostInfoMap.get(dataCenterId); |
952 | 952 | if (zoneHostInfo != null && isZoneHostReady(zoneHostInfo)) { |
953 | 953 | VMTemplateVO template = _templateDao.findSystemVMReadyTemplate(dataCenterId, HypervisorType.Any); |
954 | | - TemplateDataStoreVO templateHostRef = _vmTemplateStoreDao.findByTemplateZoneDownloadStatus(template.getId(), dataCenterId, |
| 954 | + if (template == null) { |
| 955 | + if (s_logger.isDebugEnabled()) { |
| 956 | + s_logger.debug("System vm template is not ready at data center " + dataCenterId + ", wait until it is ready to launch console proxy vm"); |
| 957 | + } |
| 958 | + return false; |
| 959 | + } |
| 960 | + TemplateDataStoreVO templateHostRef = this._vmTemplateStoreDao.findByTemplateZoneDownloadStatus(template.getId(), dataCenterId, |
955 | 961 | Status.DOWNLOADED); |
956 | 962 |
|
957 | 963 | if (templateHostRef != null) { |
@@ -1282,8 +1288,9 @@ public boolean configure(String name, Map<String, Object> params) throws Configu |
1282 | 1288 | String cpvmSrvcOffIdStr = configs.get(Config.ConsoleProxyServiceOffering.key()); |
1283 | 1289 | if (cpvmSrvcOffIdStr != null) { |
1284 | 1290 | DiskOffering diskOffering = _diskOfferingDao.findByUuid(cpvmSrvcOffIdStr); |
1285 | | - if (diskOffering == null) |
| 1291 | + if (diskOffering == null) { |
1286 | 1292 | diskOffering = _diskOfferingDao.findById(Long.parseLong(cpvmSrvcOffIdStr)); |
| 1293 | + } |
1287 | 1294 | if (diskOffering != null) { |
1288 | 1295 | _serviceOffering = _offeringDao.findById(diskOffering.getId()); |
1289 | 1296 | } else { |
@@ -1517,7 +1524,7 @@ public String getScanHandlerName() { |
1517 | 1524 | @Override |
1518 | 1525 | public void onScanStart() { |
1519 | 1526 | // to reduce possible number of DB queries for capacity scan, we run following aggregated queries in preparation |
1520 | | -// stage |
| 1527 | + // stage |
1521 | 1528 | _zoneHostInfoMap = getZoneHostInfo(); |
1522 | 1529 |
|
1523 | 1530 | _zoneProxyCountMap = new HashMap<Long, ConsoleProxyLoadInfo>(); |
|
0 commit comments