Search in sources :

Example 1 with TemplateDeployAsIsDetailVO

use of com.cloud.deployasis.TemplateDeployAsIsDetailVO in project cloudstack by apache.

the class TemplateDeployAsIsDetailsDaoImpl method findPropertyByTemplateAndKey.

@Override
public OVFPropertyTO findPropertyByTemplateAndKey(long templateId, String key) {
    SearchCriteria<TemplateDeployAsIsDetailVO> sc = createSearchCriteria();
    sc.addAnd("resourceId", SearchCriteria.Op.EQ, templateId);
    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) {
        property = gson.fromJson(detail.getValue(), OVFPropertyTO.class);
    }
    return property;
}
Also used : TemplateDeployAsIsDetailVO(com.cloud.deployasis.TemplateDeployAsIsDetailVO) OVFPropertyTO(com.cloud.agent.api.to.deployasis.OVFPropertyTO)

Example 2 with TemplateDeployAsIsDetailVO

use of com.cloud.deployasis.TemplateDeployAsIsDetailVO in project cloudstack by apache.

the class TemplateDeployAsIsDetailsDaoImpl method listNetworkRequirementsByTemplateId.

@Override
public List<OVFNetworkTO> listNetworkRequirementsByTemplateId(long templateId) {
    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);
        networkPrereqs.add(ovfPropertyTO);
    }
    networkPrereqs.sort(new Comparator<OVFNetworkTO>() {

        @Override
        public int compare(OVFNetworkTO o1, OVFNetworkTO o2) {
            return o1.getInstanceID() - o2.getInstanceID();
        }
    });
    return networkPrereqs;
}
Also used : ArrayList(java.util.ArrayList) TemplateDeployAsIsDetailVO(com.cloud.deployasis.TemplateDeployAsIsDetailVO) OVFNetworkTO(com.cloud.agent.api.to.deployasis.OVFNetworkTO)

Example 3 with TemplateDeployAsIsDetailVO

use of com.cloud.deployasis.TemplateDeployAsIsDetailVO in project cloudstack by apache.

the class DeployAsIsHelperImpl method saveTemplateDeployAsIsPropertyAttribute.

private void saveTemplateDeployAsIsPropertyAttribute(long templateId, String key, String value) {
    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace(String.format("Saving property %s for template %d as detail", key, templateId));
    }
    if (templateDeployAsIsDetailsDao.findDetail(templateId, key) != null) {
        LOGGER.debug(String.format("Detail '%s' existed for template %d, deleting.", key, templateId));
        templateDeployAsIsDetailsDao.removeDetail(templateId, key);
    }
    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace(String.format("Template detail for template %d to save is '%s': '%s'", templateId, key, value));
    }
    TemplateDeployAsIsDetailVO detailVO = new TemplateDeployAsIsDetailVO(templateId, key, value);
    LOGGER.debug("Persisting template details " + detailVO.getName() + " from OVF properties for template " + templateId);
    templateDeployAsIsDetailsDao.persist(detailVO);
}
Also used : TemplateDeployAsIsDetailVO(com.cloud.deployasis.TemplateDeployAsIsDetailVO)

Aggregations

TemplateDeployAsIsDetailVO (com.cloud.deployasis.TemplateDeployAsIsDetailVO)3 OVFNetworkTO (com.cloud.agent.api.to.deployasis.OVFNetworkTO)1 OVFPropertyTO (com.cloud.agent.api.to.deployasis.OVFPropertyTO)1 ArrayList (java.util.ArrayList)1