mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-8301: Enable configuring local storage use for system VMs at zone level
Code cleanup, added helper method to get default system offering based on "system.vm.use.local.storage".
This commit is contained in:
parent
3f7e31ed05
commit
d423df66cc
@ -55,4 +55,6 @@ public interface ServiceOfferingDao extends GenericDao<ServiceOfferingVO, Long>
|
|||||||
boolean isDynamic(long serviceOfferingId);
|
boolean isDynamic(long serviceOfferingId);
|
||||||
|
|
||||||
ServiceOfferingVO getcomputeOffering(ServiceOfferingVO serviceOffering, Map<String, String> customParameters);
|
ServiceOfferingVO getcomputeOffering(ServiceOfferingVO serviceOffering, Map<String, String> customParameters);
|
||||||
|
|
||||||
|
ServiceOfferingVO findDefaultSystemOffering(String offeringName, Boolean useLocalStorage);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -276,4 +276,19 @@ public class ServiceOfferingDaoImpl extends GenericDaoBase<ServiceOfferingVO, Lo
|
|||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ServiceOfferingVO findDefaultSystemOffering(String offeringName, Boolean useLocalStorage) {
|
||||||
|
String name = offeringName;
|
||||||
|
if (useLocalStorage != null && useLocalStorage.booleanValue()) {
|
||||||
|
name += "-Local";
|
||||||
|
}
|
||||||
|
ServiceOfferingVO serviceOffering = findByName(name);
|
||||||
|
if (serviceOffering == null) {
|
||||||
|
String message = "System service offering " + name + " not found";
|
||||||
|
s_logger.error(message);
|
||||||
|
throw new CloudRuntimeException(message);
|
||||||
|
}
|
||||||
|
return serviceOffering;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -282,17 +282,7 @@ public class LoadBalanceRuleHandler {
|
|||||||
userId = _userDao.listByAccount(owner.getAccountId()).get(0).getId();
|
userId = _userDao.listByAccount(owner.getAccountId()).get(0).getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
String offeringName = ServiceOffering.elbVmDefaultOffUniqueName;
|
ServiceOfferingVO elasticLbVmOffering = _serviceOfferingDao.findDefaultSystemOffering(ServiceOffering.elbVmDefaultOffUniqueName, ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId()));
|
||||||
Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId());
|
|
||||||
if (useLocalStorage != null && useLocalStorage.booleanValue()) {
|
|
||||||
offeringName += "-Local";
|
|
||||||
}
|
|
||||||
ServiceOfferingVO elasticLbVmOffering = _serviceOfferingDao.findByName(offeringName);
|
|
||||||
if (elasticLbVmOffering == null) {
|
|
||||||
String message = "System service offering " + offeringName + " not found";
|
|
||||||
s_logger.error(message);
|
|
||||||
throw new CloudRuntimeException(message);
|
|
||||||
}
|
|
||||||
elbVm = new DomainRouterVO(id, elasticLbVmOffering.getId(), vrProvider.getId(), VirtualMachineName.getSystemVmName(id, _instance, ELB_VM_NAME_PREFIX),
|
elbVm = new DomainRouterVO(id, elasticLbVmOffering.getId(), vrProvider.getId(), VirtualMachineName.getSystemVmName(id, _instance, ELB_VM_NAME_PREFIX),
|
||||||
template.getId(), template.getHypervisorType(), template.getGuestOSId(), owner.getDomainId(), owner.getId(), userId, false, RedundantState.UNKNOWN,
|
template.getId(), template.getHypervisorType(), template.getGuestOSId(), owner.getDomainId(), owner.getId(), userId, false, RedundantState.UNKNOWN,
|
||||||
elasticLbVmOffering.getOfferHA(), false, null);
|
elasticLbVmOffering.getOfferHA(), false, null);
|
||||||
|
|||||||
@ -623,17 +623,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements In
|
|||||||
final LinkedHashMap<Network, List<? extends NicProfile>> networks = createInternalLbVmNetworks(guestNetwork, plan, requestedGuestIp);
|
final LinkedHashMap<Network, List<? extends NicProfile>> networks = createInternalLbVmNetworks(guestNetwork, plan, requestedGuestIp);
|
||||||
long internalLbVmOfferingId = _internalLbVmOfferingId;
|
long internalLbVmOfferingId = _internalLbVmOfferingId;
|
||||||
if (internalLbVmOfferingId == 0L) {
|
if (internalLbVmOfferingId == 0L) {
|
||||||
String offeringName = ServiceOffering.internalLbVmDefaultOffUniqueName;
|
ServiceOfferingVO serviceOffering = _serviceOfferingDao.findDefaultSystemOffering(ServiceOffering.internalLbVmDefaultOffUniqueName, ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId()));
|
||||||
Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId());
|
|
||||||
if (useLocalStorage != null && useLocalStorage.booleanValue()) {
|
|
||||||
offeringName += "-Local";
|
|
||||||
}
|
|
||||||
ServiceOfferingVO serviceOffering = _serviceOfferingDao.findByName(offeringName);
|
|
||||||
if (serviceOffering == null) {
|
|
||||||
String message = "System service offering " + offeringName + " not found";
|
|
||||||
s_logger.error(message);
|
|
||||||
throw new CloudRuntimeException(message);
|
|
||||||
}
|
|
||||||
internalLbVmOfferingId = serviceOffering.getId();
|
internalLbVmOfferingId = serviceOffering.getId();
|
||||||
}
|
}
|
||||||
//Pass startVm=false as we are holding the network lock that needs to be released at the end of vm allocation
|
//Pass startVm=false as we are holding the network lock that needs to be released at the end of vm allocation
|
||||||
|
|||||||
@ -718,17 +718,7 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
|
|||||||
|
|
||||||
ServiceOfferingVO serviceOffering = _serviceOffering;
|
ServiceOfferingVO serviceOffering = _serviceOffering;
|
||||||
if (serviceOffering == null) {
|
if (serviceOffering == null) {
|
||||||
String offeringName = ServiceOffering.consoleProxyDefaultOffUniqueName;
|
serviceOffering = _offeringDao.findDefaultSystemOffering(ServiceOffering.consoleProxyDefaultOffUniqueName, ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId));
|
||||||
Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId);
|
|
||||||
if (useLocalStorage != null && useLocalStorage.booleanValue()) {
|
|
||||||
offeringName += "-Local";
|
|
||||||
}
|
|
||||||
serviceOffering = _offeringDao.findByName(offeringName);
|
|
||||||
if (serviceOffering == null) {
|
|
||||||
String message = "System service offering " + offeringName + " not found";
|
|
||||||
s_logger.error(message);
|
|
||||||
throw new CloudRuntimeException(message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ConsoleProxyVO proxy =
|
ConsoleProxyVO proxy =
|
||||||
new ConsoleProxyVO(id, serviceOffering.getId(), name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId,
|
new ConsoleProxyVO(id, serviceOffering.getId(), name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId,
|
||||||
|
|||||||
@ -360,15 +360,7 @@ public class RouterDeploymentDefinition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void findDefaultServiceOfferingId() {
|
protected void findDefaultServiceOfferingId() {
|
||||||
String offeringName = ServiceOffering.routerDefaultOffUniqueName;
|
ServiceOfferingVO serviceOffering = serviceOfferingDao.findDefaultSystemOffering(ServiceOffering.routerDefaultOffUniqueName, ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId()));
|
||||||
Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId());
|
|
||||||
if (useLocalStorage != null && useLocalStorage.booleanValue()) {
|
|
||||||
offeringName += "-Local";
|
|
||||||
}
|
|
||||||
ServiceOfferingVO serviceOffering = serviceOfferingDao.findByName(offeringName);
|
|
||||||
if (serviceOffering == null) {
|
|
||||||
throw new CloudRuntimeException("System service offering " + offeringName + " not found");
|
|
||||||
}
|
|
||||||
serviceOfferingId = serviceOffering.getId();
|
serviceOfferingId = serviceOffering.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -658,7 +658,7 @@ public class RouterDeploymentDefinitionTest extends RouterDeploymentDefinitionTe
|
|||||||
when(mockNw.getNetworkOfferingId()).thenReturn(OFFERING_ID);
|
when(mockNw.getNetworkOfferingId()).thenReturn(OFFERING_ID);
|
||||||
when(mockNetworkOfferingDao.findById(OFFERING_ID)).thenReturn(mockNwOfferingVO);
|
when(mockNetworkOfferingDao.findById(OFFERING_ID)).thenReturn(mockNwOfferingVO);
|
||||||
when(mockNwOfferingVO.getServiceOfferingId()).thenReturn(null);
|
when(mockNwOfferingVO.getServiceOfferingId()).thenReturn(null);
|
||||||
when(mockServiceOfferingDao.findByName(Matchers.anyString())).thenReturn(mockSvcOfferingVO);
|
when(mockServiceOfferingDao.findDefaultSystemOffering(Matchers.anyString(), Matchers.anyBoolean())).thenReturn(mockSvcOfferingVO);
|
||||||
when(mockSvcOfferingVO.getId()).thenReturn(DEFAULT_OFFERING_ID);
|
when(mockSvcOfferingVO.getId()).thenReturn(DEFAULT_OFFERING_ID);
|
||||||
|
|
||||||
// Execute
|
// Execute
|
||||||
|
|||||||
@ -184,7 +184,7 @@ public class VpcRouterDeploymentDefinitionTest extends RouterDeploymentDefinitio
|
|||||||
final VpcOfferingVO vpcOffering = mock(VpcOfferingVO.class);
|
final VpcOfferingVO vpcOffering = mock(VpcOfferingVO.class);
|
||||||
when(mockVpcOffDao.findById(VPC_OFFERING_ID)).thenReturn(vpcOffering);
|
when(mockVpcOffDao.findById(VPC_OFFERING_ID)).thenReturn(vpcOffering);
|
||||||
when(vpcOffering.getServiceOfferingId()).thenReturn(null);
|
when(vpcOffering.getServiceOfferingId()).thenReturn(null);
|
||||||
when(mockServiceOfferingDao.findByName(Matchers.anyString())).thenReturn(mockSvcOfferingVO);
|
when(mockServiceOfferingDao.findDefaultSystemOffering(Matchers.anyString(), Matchers.anyBoolean())).thenReturn(mockSvcOfferingVO);
|
||||||
when(mockSvcOfferingVO.getId()).thenReturn(DEFAULT_OFFERING_ID);
|
when(mockSvcOfferingVO.getId()).thenReturn(DEFAULT_OFFERING_ID);
|
||||||
|
|
||||||
// Execute
|
// Execute
|
||||||
|
|||||||
@ -578,17 +578,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
|
|||||||
|
|
||||||
ServiceOfferingVO serviceOffering = _serviceOffering;
|
ServiceOfferingVO serviceOffering = _serviceOffering;
|
||||||
if (serviceOffering == null) {
|
if (serviceOffering == null) {
|
||||||
String offeringName = ServiceOffering.ssvmDefaultOffUniqueName;
|
serviceOffering = _offeringDao.findDefaultSystemOffering(ServiceOffering.ssvmDefaultOffUniqueName, ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId));
|
||||||
Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId);
|
|
||||||
if (useLocalStorage != null && useLocalStorage.booleanValue()) {
|
|
||||||
offeringName += "-Local";
|
|
||||||
}
|
|
||||||
serviceOffering = _offeringDao.findByName(offeringName);
|
|
||||||
if (serviceOffering == null) {
|
|
||||||
String message = "System service offering " + offeringName + " not found";
|
|
||||||
s_logger.error(message);
|
|
||||||
throw new CloudRuntimeException(message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
SecondaryStorageVmVO secStorageVm =
|
SecondaryStorageVmVO secStorageVm =
|
||||||
new SecondaryStorageVmVO(id, serviceOffering.getId(), name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId,
|
new SecondaryStorageVmVO(id, serviceOffering.getId(), name, template.getId(), template.getHypervisorType(), template.getGuestOSId(), dataCenterId,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user