Refactor deploy as is constants

This commit is contained in:
nvazquez 2020-09-14 12:12:35 -03:00 committed by Harikrishna Patnala
parent bb4ce2118d
commit f73830acbb
4 changed files with 13 additions and 13 deletions

View File

@ -18,10 +18,10 @@ package com.cloud.deployasis;
public interface DeployAsIsConstants {
String ACS_PROPERTY_PREFIX = "ACS-property-";
String REQUIRED_NETWORK_PREFIX = "ACS-network-";
String OVF_HARDWARE_CONFIGURATION_PREFIX = "ACS-configuration-";
String OVF_HARDWARE_ITEM_PREFIX = "ACS-hardware-item-";
String OVF_EULA_SECTION_PREFIX = "ACS-eula-";
String PROPERTY_PREFIX = "property-";
String NETWORK_PREFIX = "network-";
String CONFIGURATION_PREFIX = "configuration-";
String HARDWARE_ITEM_PREFIX = "hardware-item-";
String EULA_PREFIX = "eula-";
}

View File

@ -46,7 +46,7 @@ public class TemplateDeployAsIsDetailsDaoImpl extends ResourceDetailsDaoBase<Tem
public OVFPropertyTO findPropertyByTemplateAndKey(long templateId, String key) {
SearchCriteria<TemplateDeployAsIsDetailVO> sc = createSearchCriteria();
sc.addAnd("templateId", SearchCriteria.Op.EQ, templateId);
sc.addAnd("name", SearchCriteria.Op.EQ, key.startsWith(DeployAsIsConstants.ACS_PROPERTY_PREFIX) ? key : DeployAsIsConstants.ACS_PROPERTY_PREFIX + key);
sc.addAnd("name", SearchCriteria.Op.EQ, key.startsWith(DeployAsIsConstants.PROPERTY_PREFIX) ? key : DeployAsIsConstants.PROPERTY_PREFIX + key);
OVFPropertyTO property = null;
TemplateDeployAsIsDetailVO detail = findOneBy(sc);
if (detail != null) {
@ -66,7 +66,7 @@ public class TemplateDeployAsIsDetailsDaoImpl extends ResourceDetailsDaoBase<Tem
@Override
public List<OVFNetworkTO> listNetworkRequirementsByTemplateId(long templateId) {
List<TemplateDeployAsIsDetailVO> networkDetails = listDetailsByTemplateIdMatchingPrefix(templateId, DeployAsIsConstants.REQUIRED_NETWORK_PREFIX);
List<TemplateDeployAsIsDetailVO> networkDetails = listDetailsByTemplateIdMatchingPrefix(templateId, DeployAsIsConstants.NETWORK_PREFIX);
List<OVFNetworkTO> networkPrereqs = new ArrayList<>();
for (TemplateDeployAsIsDetailVO property : networkDetails) {
OVFNetworkTO ovfPropertyTO = gson.fromJson(property.getValue(), OVFNetworkTO.class);

View File

@ -176,18 +176,18 @@ public class DeployAsIsHelperImpl implements DeployAsIsHelper {
private String getKeyFromInformationTO(TemplateDeployAsIsInformationTO informationTO) {
if (informationTO instanceof OVFPropertyTO) {
return DeployAsIsConstants.ACS_PROPERTY_PREFIX + ((OVFPropertyTO) informationTO).getKey();
return DeployAsIsConstants.PROPERTY_PREFIX + ((OVFPropertyTO) informationTO).getKey();
} else if (informationTO instanceof OVFNetworkTO) {
return DeployAsIsConstants.REQUIRED_NETWORK_PREFIX + ((OVFNetworkTO) informationTO).getName();
return DeployAsIsConstants.NETWORK_PREFIX + ((OVFNetworkTO) informationTO).getName();
} else if (informationTO instanceof OVFConfigurationTO) {
return DeployAsIsConstants.OVF_HARDWARE_CONFIGURATION_PREFIX +
return DeployAsIsConstants.CONFIGURATION_PREFIX +
((OVFConfigurationTO) informationTO).getIndex() + "-" + ((OVFConfigurationTO) informationTO).getId();
} else if (informationTO instanceof OVFVirtualHardwareItemTO) {
String key = ((OVFVirtualHardwareItemTO) informationTO).getResourceType().getName().trim().replaceAll("\\s","")
+ "-" + ((OVFVirtualHardwareItemTO) informationTO).getInstanceId();
return DeployAsIsConstants.OVF_HARDWARE_ITEM_PREFIX + key;
return DeployAsIsConstants.HARDWARE_ITEM_PREFIX + key;
} else if (informationTO instanceof OVFEulaSectionTO) {
return DeployAsIsConstants.OVF_EULA_SECTION_PREFIX + ((OVFEulaSectionTO) informationTO).getIndex() +
return DeployAsIsConstants.EULA_PREFIX + ((OVFEulaSectionTO) informationTO).getIndex() +
"-" + ((OVFEulaSectionTO) informationTO).getInfo();
}
return null;

View File

@ -283,7 +283,7 @@ public class TemplateJoinDaoImpl extends GenericDaoBaseWithTagInformation<Templa
if (template.isDeployAsIs()) {
List<TemplateDeployAsIsDetailVO> deployAsIsDetails = templateDeployAsIsDetailsDao.listDetails(template.getId());
for (TemplateDeployAsIsDetailVO deployAsIsDetailVO : deployAsIsDetails) {
if (deployAsIsDetailVO.getName().startsWith(DeployAsIsConstants.OVF_HARDWARE_ITEM_PREFIX)) {
if (deployAsIsDetailVO.getName().startsWith(DeployAsIsConstants.HARDWARE_ITEM_PREFIX)) {
//Do not list hardware items
continue;
}