|
27 | 27 | import javax.inject.Inject; |
28 | 28 | import javax.naming.ConfigurationException; |
29 | 29 |
|
| 30 | +import com.cloud.configuration.ConfigurationManagerImpl; |
30 | 31 | import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; |
31 | 32 | import org.apache.cloudstack.framework.config.dao.ConfigurationDao; |
32 | 33 | import org.apache.cloudstack.lb.ApplicationLoadBalancerRuleVO; |
@@ -376,15 +377,15 @@ public boolean configure(String name, Map<String, Object> params) throws Configu |
376 | 377 |
|
377 | 378 | //if offering wasn't set, try to get the default one |
378 | 379 | if (_internalLbVmOfferingId == 0L) { |
379 | | - boolean useLocalStorage = Boolean.parseBoolean(configs.get(DataCenter.SystemVMUseLocalStorageCK)); |
380 | | - ServiceOfferingVO newOff = |
381 | | - new ServiceOfferingVO("System Offering For Internal LB VM", 1, InternalLoadBalancerVMManager.DEFAULT_INTERNALLB_VM_RAMSIZE, |
| 380 | + List<ServiceOfferingVO> offerings = _serviceOfferingDao.createSystemServiceOfferings("System Offering For Internal LB VM", |
| 381 | + ServiceOffering.internalLbVmDefaultOffUniqueName, 1, InternalLoadBalancerVMManager.DEFAULT_INTERNALLB_VM_RAMSIZE, |
382 | 382 | InternalLoadBalancerVMManager.DEFAULT_INTERNALLB_VM_CPU_MHZ, null, null, true, null, |
383 | | - Storage.ProvisioningType.THIN, useLocalStorage, true, null, true, |
384 | | - VirtualMachine.Type.InternalLoadBalancerVm, true); |
385 | | - newOff.setUniqueName(ServiceOffering.internalLbVmDefaultOffUniqueName); |
386 | | - newOff = _serviceOfferingDao.persistSystemServiceOffering(newOff); |
387 | | - _internalLbVmOfferingId = newOff.getId(); |
| 383 | + Storage.ProvisioningType.THIN, true, null, true, VirtualMachine.Type.InternalLoadBalancerVm, true); |
| 384 | + if (offerings == null || offerings.size() < 2) { |
| 385 | + String msg = "Data integrity problem : System Offering For Internal LB VM has been removed?"; |
| 386 | + s_logger.error(msg); |
| 387 | + throw new ConfigurationException(msg); |
| 388 | + } |
388 | 389 | } |
389 | 390 |
|
390 | 391 | _itMgr.registerGuru(VirtualMachine.Type.InternalLoadBalancerVm, this); |
@@ -616,9 +617,14 @@ protected List<DomainRouterVO> findOrDeployInternalLbVm(Network guestNetwork, Ip |
616 | 617 | } |
617 | 618 |
|
618 | 619 | LinkedHashMap<Network, List<? extends NicProfile>> networks = createInternalLbVmNetworks(guestNetwork, plan, requestedGuestIp); |
| 620 | + long internalLbVmOfferingId = _internalLbVmOfferingId; |
| 621 | + if (internalLbVmOfferingId == 0L) { |
| 622 | + ServiceOfferingVO serviceOffering = _serviceOfferingDao.findDefaultSystemOffering(ServiceOffering.internalLbVmDefaultOffUniqueName, ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId())); |
| 623 | + internalLbVmOfferingId = serviceOffering.getId(); |
| 624 | + } |
619 | 625 | //Pass startVm=false as we are holding the network lock that needs to be released at the end of vm allocation |
620 | 626 | DomainRouterVO internalLbVm = |
621 | | - deployInternalLbVm(owner, dest, plan, params, internalLbProviderId, _internalLbVmOfferingId, guestNetwork.getVpcId(), networks, false); |
| 627 | + deployInternalLbVm(owner, dest, plan, params, internalLbProviderId, internalLbVmOfferingId, guestNetwork.getVpcId(), networks, false); |
622 | 628 | if (internalLbVm != null) { |
623 | 629 | _internalLbVmDao.addRouterToGuestNetwork(internalLbVm, guestNetwork); |
624 | 630 | internalLbVms.add(internalLbVm); |
|
0 commit comments