Search in sources :

Example 6 with DatadiskTO

use of com.cloud.agent.api.to.DatadiskTO in project cloudstack by apache.

the class OVAProcessor method createOvfInformationTO.

private OVFInformationTO createOvfInformationTO(OVFHelper ovfHelper, Document doc, String ovfFilePath) throws InternalErrorException {
    OVFInformationTO ovfInformationTO = new OVFInformationTO();
    List<DatadiskTO> disks = ovfHelper.getOVFVolumeInfoFromFile(ovfFilePath, doc, null);
    if (CollectionUtils.isNotEmpty(disks)) {
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace(String.format("Found %d disks in template %s", disks.size(), ovfFilePath));
        }
        ovfInformationTO.setDisks(disks);
    }
    List<OVFNetworkTO> nets = ovfHelper.getNetPrerequisitesFromDocument(doc);
    if (CollectionUtils.isNotEmpty(nets)) {
        LOGGER.info("Found " + nets.size() + " prerequisite networks");
        ovfInformationTO.setNetworks(nets);
    } else if (LOGGER.isTraceEnabled()) {
        LOGGER.trace(String.format("no net prerequisites found in template %s", ovfFilePath));
    }
    List<OVFPropertyTO> ovfProperties = ovfHelper.getConfigurableOVFPropertiesFromDocument(doc);
    if (CollectionUtils.isNotEmpty(ovfProperties)) {
        LOGGER.info("Found " + ovfProperties.size() + " configurable OVF properties");
        ovfInformationTO.setProperties(ovfProperties);
    } else if (LOGGER.isTraceEnabled()) {
        LOGGER.trace(String.format("no ovf properties found in template %s", ovfFilePath));
    }
    OVFVirtualHardwareSectionTO hardwareSection = ovfHelper.getVirtualHardwareSectionFromDocument(doc);
    List<OVFConfigurationTO> configurations = hardwareSection.getConfigurations();
    if (CollectionUtils.isNotEmpty(configurations)) {
        LOGGER.info("Found " + configurations.size() + " deployment option configurations");
    }
    List<OVFVirtualHardwareItemTO> hardwareItems = hardwareSection.getCommonHardwareItems();
    if (CollectionUtils.isNotEmpty(hardwareItems)) {
        LOGGER.info("Found " + hardwareItems.size() + " virtual hardware items");
    }
    if (StringUtils.isNotBlank(hardwareSection.getMinimiumHardwareVersion())) {
        LOGGER.info("Found minimum hardware version " + hardwareSection.getMinimiumHardwareVersion());
    }
    ovfInformationTO.setHardwareSection(hardwareSection);
    List<OVFEulaSectionTO> eulaSections = ovfHelper.getEulaSectionsFromDocument(doc);
    if (CollectionUtils.isNotEmpty(eulaSections)) {
        LOGGER.info("Found " + eulaSections.size() + " license agreements");
        ovfInformationTO.setEulaSections(eulaSections);
    }
    Pair<String, String> guestOsPair = ovfHelper.getOperatingSystemInfoFromDocument(doc);
    if (guestOsPair != null) {
        LOGGER.info("Found guest OS information: " + guestOsPair.first() + " - " + guestOsPair.second());
        ovfInformationTO.setGuestOsInfo(guestOsPair);
    }
    return ovfInformationTO;
}
Also used : OVFInformationTO(com.cloud.agent.api.to.OVFInformationTO) OVFConfigurationTO(com.cloud.agent.api.to.deployasis.OVFConfigurationTO) OVFNetworkTO(com.cloud.agent.api.to.deployasis.OVFNetworkTO) OVFPropertyTO(com.cloud.agent.api.to.deployasis.OVFPropertyTO) OVFEulaSectionTO(com.cloud.agent.api.to.deployasis.OVFEulaSectionTO) OVFVirtualHardwareItemTO(com.cloud.agent.api.to.deployasis.OVFVirtualHardwareItemTO) DatadiskTO(com.cloud.agent.api.to.DatadiskTO) OVFVirtualHardwareSectionTO(com.cloud.agent.api.to.deployasis.OVFVirtualHardwareSectionTO)

Example 7 with DatadiskTO

use of com.cloud.agent.api.to.DatadiskTO in project cloudstack by apache.

the class TemplateServiceImpl method createOvaDataDiskTemplates.

@Override
public boolean createOvaDataDiskTemplates(TemplateInfo parentTemplate, boolean deployAsIs) {
    try {
        // Get Datadisk template (if any) for OVA
        List<DatadiskTO> dataDiskTemplates = new ArrayList<DatadiskTO>();
        ImageStoreEntity tmpltStore = (ImageStoreEntity) parentTemplate.getDataStore();
        dataDiskTemplates = tmpltStore.getDataDiskTemplates(parentTemplate, null);
        int diskCount = 0;
        VMTemplateVO templateVO = _templateDao.findById(parentTemplate.getId());
        _templateDao.loadDetails(templateVO);
        DataStore imageStore = parentTemplate.getDataStore();
        Map<String, String> details = parentTemplate.getDetails();
        if (details == null) {
            details = templateVO.getDetails();
            if (details == null) {
                details = new HashMap<>();
            }
        }
        for (DatadiskTO diskTemplate : dataDiskTemplates) {
            if (!deployAsIs) {
                if (!diskTemplate.isBootable()) {
                    createChildDataDiskTemplate(diskTemplate, templateVO, parentTemplate, imageStore, diskCount++);
                    if (!diskTemplate.isIso() && StringUtils.isEmpty(details.get(VmDetailConstants.DATA_DISK_CONTROLLER))) {
                        details.put(VmDetailConstants.DATA_DISK_CONTROLLER, getOvaDiskControllerDetails(diskTemplate, false));
                        details.put(VmDetailConstants.DATA_DISK_CONTROLLER + diskTemplate.getDiskId(), getOvaDiskControllerDetails(diskTemplate, false));
                    }
                } else {
                    finalizeParentTemplate(diskTemplate, templateVO, parentTemplate, imageStore, diskCount++);
                    if (StringUtils.isEmpty(VmDetailConstants.ROOT_DISK_CONTROLLER)) {
                        final String rootDiskController = getOvaDiskControllerDetails(diskTemplate, true);
                        if (StringUtils.isNotEmpty(rootDiskController)) {
                            details.put(VmDetailConstants.ROOT_DISK_CONTROLLER, rootDiskController);
                        }
                    }
                }
            }
        }
        templateVO.setDetails(details);
        _templateDao.saveDetails(templateVO);
        return true;
    } catch (CloudRuntimeException | InterruptedException | ExecutionException e) {
        return false;
    }
}
Also used : ArrayList(java.util.ArrayList) VMTemplateVO(com.cloud.storage.VMTemplateVO) EndPoint(org.apache.cloudstack.engine.subsystem.api.storage.EndPoint) DatadiskTO(com.cloud.agent.api.to.DatadiskTO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) ImageStoreEntity(org.apache.cloudstack.storage.image.datastore.ImageStoreEntity) ExecutionException(java.util.concurrent.ExecutionException)

Example 8 with DatadiskTO

use of com.cloud.agent.api.to.DatadiskTO in project cloudstack by apache.

the class BaseImageStoreDriverImpl method getDataDiskTemplates.

@Override
public List<DatadiskTO> getDataDiskTemplates(DataObject obj, String configurationId) {
    List<DatadiskTO> dataDiskDetails = new ArrayList<DatadiskTO>();
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Get the data disks present in the OVA template");
    }
    DataStore store = obj.getDataStore();
    GetDatadisksCommand cmd = new GetDatadisksCommand(obj.getTO(), configurationId);
    EndPoint ep = _defaultEpSelector.select(store);
    Answer answer = null;
    if (ep == null) {
        String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
        LOGGER.error(errMsg);
        answer = new Answer(cmd, false, errMsg);
    } else {
        answer = ep.sendMessage(cmd);
    }
    if (answer != null && answer.getResult()) {
        GetDatadisksAnswer getDatadisksAnswer = (GetDatadisksAnswer) answer;
        // Details - Disk path, virtual size
        dataDiskDetails = getDatadisksAnswer.getDataDiskDetails();
    } else {
        throw new CloudRuntimeException("Get Data disk command failed " + answer.getDetails());
    }
    return dataDiskDetails;
}
Also used : GetDatadisksAnswer(com.cloud.agent.api.storage.GetDatadisksAnswer) DownloadAnswer(com.cloud.agent.api.storage.DownloadAnswer) Answer(com.cloud.agent.api.Answer) DatadiskTO(com.cloud.agent.api.to.DatadiskTO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) ArrayList(java.util.ArrayList) GetDatadisksCommand(com.cloud.agent.api.storage.GetDatadisksCommand) EndPoint(org.apache.cloudstack.engine.subsystem.api.storage.EndPoint) GetDatadisksAnswer(com.cloud.agent.api.storage.GetDatadisksAnswer)

Aggregations

DatadiskTO (com.cloud.agent.api.to.DatadiskTO)8 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)6 ArrayList (java.util.ArrayList)5 InternalErrorException (com.cloud.exception.InternalErrorException)4 OVFConfigurationTO (com.cloud.agent.api.to.deployasis.OVFConfigurationTO)3 OVFEulaSectionTO (com.cloud.agent.api.to.deployasis.OVFEulaSectionTO)3 OVFNetworkTO (com.cloud.agent.api.to.deployasis.OVFNetworkTO)3 OVFPropertyTO (com.cloud.agent.api.to.deployasis.OVFPropertyTO)3 OVFVirtualHardwareItemTO (com.cloud.agent.api.to.deployasis.OVFVirtualHardwareItemTO)3 OVFVirtualHardwareSectionTO (com.cloud.agent.api.to.deployasis.OVFVirtualHardwareSectionTO)3 ResourceType (com.cloud.configuration.Resource.ResourceType)3 Pair (com.cloud.utils.Pair)3 File (java.io.File)3 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3 CollectionUtils (org.apache.commons.collections.CollectionUtils)3 GetDatadisksAnswer (com.cloud.agent.api.storage.GetDatadisksAnswer)2