Search in sources :

Example 1 with DatadiskTO

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

the class VolumeOrchestrator method allocateTemplatedVolumes.

@Override
public List<DiskProfile> allocateTemplatedVolumes(Type type, String name, DiskOffering offering, Long rootDisksize, Long minIops, Long maxIops, VirtualMachineTemplate template, VirtualMachine vm, Account owner) {
    int volumesNumber = 1;
    List<DatadiskTO> templateAsIsDisks = null;
    String configurationId = null;
    boolean deployVmAsIs = false;
    if (template.isDeployAsIs() && vm.getType() != VirtualMachine.Type.SecondaryStorageVm) {
        List<SecondaryStorageVmVO> runningSSVMs = secondaryStorageVmDao.getSecStorageVmListInStates(null, vm.getDataCenterId(), State.Running);
        if (CollectionUtils.isEmpty(runningSSVMs)) {
            s_logger.info("Could not find a running SSVM in datacenter " + vm.getDataCenterId() + " for deploying VM as is, " + "not deploying VM " + vm.getInstanceName() + " as-is");
        } else {
            UserVmDetailVO configurationDetail = userVmDetailsDao.findDetail(vm.getId(), VmDetailConstants.DEPLOY_AS_IS_CONFIGURATION);
            if (configurationDetail != null) {
                configurationId = configurationDetail.getValue();
            }
            templateAsIsDisks = _tmpltMgr.getTemplateDisksOnImageStore(template.getId(), DataStoreRole.Image, configurationId);
            if (CollectionUtils.isNotEmpty(templateAsIsDisks)) {
                templateAsIsDisks = templateAsIsDisks.stream().filter(x -> !x.isIso()).sorted(Comparator.comparing(DatadiskTO::getDiskNumber)).collect(Collectors.toList());
            }
            volumesNumber = templateAsIsDisks.size();
            deployVmAsIs = true;
        }
    }
    if (volumesNumber < 1) {
        throw new CloudRuntimeException("Unable to create any volume from template " + template.getName());
    }
    List<DiskProfile> profiles = new ArrayList<>();
    for (int number = 0; number < volumesNumber; number++) {
        String volumeName = name;
        Long volumeSize = rootDisksize;
        long deviceId = type.equals(Type.ROOT) ? 0L : 1L;
        if (deployVmAsIs) {
            int volumeNameSuffix = templateAsIsDisks.get(number).getDiskNumber();
            volumeName = String.format("%s-%d", volumeName, volumeNameSuffix);
            volumeSize = templateAsIsDisks.get(number).getVirtualSize();
            deviceId = templateAsIsDisks.get(number).getDiskNumber();
        }
        s_logger.info(String.format("adding disk object %s to %s", volumeName, vm.getInstanceName()));
        DiskProfile diskProfile = allocateTemplatedVolume(type, volumeName, offering, volumeSize, minIops, maxIops, template, vm, owner, deviceId, configurationId);
        profiles.add(diskProfile);
    }
    handleRootDiskControllerTpeForDeployAsIs(templateAsIsDisks, vm);
    return profiles;
}
Also used : UserVmCloneSettingVO(com.cloud.vm.UserVmCloneSettingVO) UsageEventUtils(com.cloud.event.UsageEventUtils) HostDao(com.cloud.host.dao.HostDao) VolumeService(org.apache.cloudstack.engine.subsystem.api.storage.VolumeService) Pod(com.cloud.dc.Pod) Transaction(com.cloud.utils.db.Transaction) NoTransitionException(com.cloud.utils.fsm.NoTransitionException) TemplateDataStoreDao(org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao) StringUtils(org.apache.commons.lang3.StringUtils) VirtualMachineTemplate(com.cloud.template.VirtualMachineTemplate) SnapshotDao(com.cloud.storage.dao.SnapshotDao) DiskOffering(com.cloud.offering.DiskOffering) Map(java.util.Map) StoragePoolAllocator(org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator) Storage(com.cloud.storage.Storage) StorageStrategyFactory(org.apache.cloudstack.engine.subsystem.api.storage.StorageStrategyFactory) CapacityManager(com.cloud.capacity.CapacityManager) VolumeOrchestrationService(org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService) DataTO(com.cloud.agent.api.to.DataTO) TransactionStatus(com.cloud.utils.db.TransactionStatus) DiskProfile(com.cloud.vm.DiskProfile) Set(java.util.Set) ScopeType(com.cloud.storage.ScopeType) MigrateVolumeCmd(org.apache.cloudstack.api.command.user.volume.MigrateVolumeCmd) ServiceOffering(com.cloud.offering.ServiceOffering) SnapshotDataStoreVO(org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO) AsyncCallFuture(org.apache.cloudstack.framework.async.AsyncCallFuture) ManagerBase(com.cloud.utils.component.ManagerBase) InsufficientStorageCapacityException(com.cloud.exception.InsufficientStorageCapacityException) PrimaryDataStore(org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore) SnapshotStrategy(org.apache.cloudstack.engine.subsystem.api.storage.SnapshotStrategy) AsyncJobVO(org.apache.cloudstack.framework.jobs.impl.AsyncJobVO) StorageUnavailableException(com.cloud.exception.StorageUnavailableException) ArrayList(java.util.ArrayList) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) TemplateInfo(org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo) TemplateDataStoreVO(org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO) REQUEST_TEMPLATE_RELOAD(com.cloud.storage.resource.StorageProcessor.REQUEST_TEMPLATE_RELOAD) DiskOfferingDetailsDao(org.apache.cloudstack.resourcedetail.dao.DiskOfferingDetailsDao) SecondaryStorageVmVO(com.cloud.vm.SecondaryStorageVmVO) UserVmDetailVO(com.cloud.vm.UserVmDetailVO) StorageAccessException(com.cloud.exception.StorageAccessException) VmWorkTakeVolumeSnapshot(com.cloud.vm.VmWorkTakeVolumeSnapshot) HypervisorType(com.cloud.hypervisor.Hypervisor.HypervisorType) VMTemplateStorageResourceAssoc(com.cloud.storage.VMTemplateStorageResourceAssoc) UserVm(com.cloud.uservm.UserVm) DatadiskTO(com.cloud.agent.api.to.DatadiskTO) UserVmCloneSettingDao(com.cloud.vm.dao.UserVmCloneSettingDao) UserVmDao(com.cloud.vm.dao.UserVmDao) DB(com.cloud.utils.db.DB) SnapshotService(org.apache.cloudstack.engine.subsystem.api.storage.SnapshotService) ClusterManager(com.cloud.cluster.ClusterManager) ExecutionException(java.util.concurrent.ExecutionException) VolumeDataFactory(org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory) PrimaryDataStoreDriver(org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver) SnapshotManager(com.cloud.storage.snapshot.SnapshotManager) SnapshotInfo(org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo) Host(com.cloud.host.Host) ImageFormat(com.cloud.storage.Storage.ImageFormat) PodAllocator(com.cloud.agent.manager.allocator.PodAllocator) ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) DataObject(org.apache.cloudstack.engine.subsystem.api.storage.DataObject) StorageManager(com.cloud.storage.StorageManager) DataStoreDriver(org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver) TemplateDataFactory(org.apache.cloudstack.engine.subsystem.api.storage.TemplateDataFactory) TemplateManager(com.cloud.template.TemplateManager) Date(java.util.Date) SnapshotDataFactory(org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory) StoragePool(com.cloud.storage.StoragePool) ConfigDepot(org.apache.cloudstack.framework.config.ConfigDepot) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ResourceType(com.cloud.configuration.Resource.ResourceType) Cluster(com.cloud.org.Cluster) Type(com.cloud.storage.Volume.Type) Logger(org.apache.log4j.Logger) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) SnapshotDataStoreDao(org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao) CommandResult(org.apache.cloudstack.storage.command.CommandResult) VolumeDetailVO(com.cloud.storage.VolumeDetailVO) SnapshotOperation(org.apache.cloudstack.engine.subsystem.api.storage.SnapshotStrategy.SnapshotOperation) ResourceLimitService(com.cloud.user.ResourceLimitService) VolumeDetailsDao(com.cloud.storage.dao.VolumeDetailsDao) TransactionCallbackNoReturn(com.cloud.utils.db.TransactionCallbackNoReturn) VmWorkSerializer(com.cloud.vm.VmWorkSerializer) PrimaryDataStoreDao(org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao) VMInstanceVO(com.cloud.vm.VMInstanceVO) TransactionCallback(com.cloud.utils.db.TransactionCallback) StateMachine2(com.cloud.utils.fsm.StateMachine2) State(com.cloud.vm.VirtualMachine.State) DeployDestination(com.cloud.deploy.DeployDestination) Account(com.cloud.user.Account) UUID(java.util.UUID) Pair(com.cloud.utils.Pair) Collectors(java.util.stream.Collectors) VirtualMachineProfileImpl(com.cloud.vm.VirtualMachineProfileImpl) VmWorkMigrateVolume(com.cloud.vm.VmWorkMigrateVolume) List(java.util.List) MigrateVolumeCmdByAdmin(org.apache.cloudstack.api.command.admin.volume.MigrateVolumeCmdByAdmin) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) Optional(java.util.Optional) StoragePoolType(com.cloud.storage.Storage.StoragePoolType) VirtualMachine(com.cloud.vm.VirtualMachine) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) AsyncJobManager(org.apache.cloudstack.framework.jobs.AsyncJobManager) EntityManager(com.cloud.utils.db.EntityManager) VolumeApiService(com.cloud.storage.VolumeApiService) DataStoreManager(org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager) DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) HashMap(java.util.HashMap) ConfigurationException(javax.naming.ConfigurationException) EventTypes(com.cloud.event.EventTypes) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ConfigKey(org.apache.cloudstack.framework.config.ConfigKey) VmDetailConstants(com.cloud.vm.VmDetailConstants) DataStoreCapabilities(org.apache.cloudstack.engine.subsystem.api.storage.DataStoreCapabilities) CollectionUtils(org.apache.commons.collections.CollectionUtils) UserVmDetailsDao(com.cloud.vm.dao.UserVmDetailsDao) ChapInfo(org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo) Configurable(org.apache.cloudstack.framework.config.Configurable) VolumeDao(com.cloud.storage.dao.VolumeDao) Snapshot(com.cloud.storage.Snapshot) DataCenter(com.cloud.dc.DataCenter) VmWorkAttachVolume(com.cloud.vm.VmWorkAttachVolume) HostVO(com.cloud.host.HostVO) MapUtils(org.apache.commons.collections.MapUtils) VirtualMachineTO(com.cloud.agent.api.to.VirtualMachineTO) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo) DiskTO(com.cloud.agent.api.to.DiskTO) NumbersUtil.toHumanReadableSize(com.cloud.utils.NumbersUtil.toHumanReadableSize) TemplateService(org.apache.cloudstack.engine.subsystem.api.storage.TemplateService) UserVmVO(com.cloud.vm.UserVmVO) MigrateVMCmd(org.apache.cloudstack.api.command.admin.vm.MigrateVMCmd) DataStoreRole(com.cloud.storage.DataStoreRole) VolumeApiResult(org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult) DiskOfferingDetailVO(org.apache.cloudstack.resourcedetail.DiskOfferingDetailVO) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) VMTemplateDetailsDao(com.cloud.storage.dao.VMTemplateDetailsDao) SecondaryStorageVmDao(com.cloud.vm.dao.SecondaryStorageVmDao) Volume(com.cloud.storage.Volume) Comparator(java.util.Comparator) VolumeVO(com.cloud.storage.VolumeVO) SecondaryStorageVmVO(com.cloud.vm.SecondaryStorageVmVO) ArrayList(java.util.ArrayList) DiskProfile(com.cloud.vm.DiskProfile) UserVmDetailVO(com.cloud.vm.UserVmDetailVO) DatadiskTO(com.cloud.agent.api.to.DatadiskTO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 2 with DatadiskTO

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

the class NfsSecondaryStorageResource method execute.

public Answer execute(GetDatadisksCommand cmd) {
    DataTO srcData = cmd.getData();
    String configurationId = cmd.getConfigurationId();
    TemplateObjectTO template = (TemplateObjectTO) srcData;
    DataStoreTO srcStore = srcData.getDataStore();
    if (!(srcStore instanceof NfsTO)) {
        return new CreateDatadiskTemplateAnswer("Unsupported protocol");
    }
    NfsTO nfsImageStore = (NfsTO) srcStore;
    String secondaryStorageUrl = nfsImageStore.getUrl();
    assert (secondaryStorageUrl != null);
    String templateUrl = secondaryStorageUrl + File.separator + srcData.getPath();
    Pair<String, String> templateInfo = decodeTemplateRelativePathAndNameFromUrl(secondaryStorageUrl, templateUrl, template.getName());
    String templateRelativeFolderPath = templateInfo.first();
    try {
        String secondaryMountPoint = getRootDir(secondaryStorageUrl, _nfsVersion);
        s_logger.info("MDOVE Secondary storage mount point: " + secondaryMountPoint);
        String srcOVAFileName = getTemplateOnSecStorageFilePath(secondaryMountPoint, templateRelativeFolderPath, templateInfo.second(), ImageFormat.OVA.getFileExtension());
        String ovfFilePath = getOVFFilePath(srcOVAFileName);
        if (ovfFilePath == null) {
            Script command = new Script("tar", 0, s_logger);
            command.add("--no-same-owner");
            command.add("--no-same-permissions");
            command.add("-xf", srcOVAFileName);
            command.setWorkDir(secondaryMountPoint + File.separator + templateRelativeFolderPath);
            s_logger.info("Executing command: " + command.toString());
            String result = command.execute();
            if (result != null) {
                String msg = "Unable to unpack snapshot OVA file at: " + srcOVAFileName;
                s_logger.error(msg);
                throw new Exception(msg);
            }
            command = new Script("chmod", 0, s_logger);
            command.add("-R");
            command.add("666", secondaryMountPoint + File.separator + templateRelativeFolderPath);
            result = command.execute();
            if (result != null) {
                s_logger.warn("Unable to set permissions for " + secondaryMountPoint + File.separator + templateRelativeFolderPath + " due to " + result);
            }
        }
        Script command = new Script("cp", _timeout, s_logger);
        command.add(ovfFilePath);
        command.add(ovfFilePath + ORIGINAL_FILE_EXTENSION);
        String result = command.execute();
        if (result != null) {
            String msg = "Unable to rename original OVF, error msg: " + result;
            s_logger.error(msg);
        }
        s_logger.debug("Reading OVF " + ovfFilePath + " to retrive the number of disks present in OVA");
        OVFHelper ovfHelper = new OVFHelper();
        List<DatadiskTO> disks = ovfHelper.getOVFVolumeInfoFromFile(ovfFilePath, configurationId);
        return new GetDatadisksAnswer(disks);
    } catch (Exception e) {
        String msg = "Get Datadisk Template Count failed due to " + e.getMessage();
        s_logger.error(msg, e);
        return new GetDatadisksAnswer(msg);
    }
}
Also used : Script(com.cloud.utils.script.Script) DataStoreTO(com.cloud.agent.api.to.DataStoreTO) GetDatadisksAnswer(com.cloud.agent.api.storage.GetDatadisksAnswer) NfsTO(com.cloud.agent.api.to.NfsTO) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) InternalErrorException(com.cloud.exception.InternalErrorException) ConfigurationException(javax.naming.ConfigurationException) DataTO(com.cloud.agent.api.to.DataTO) DatadiskTO(com.cloud.agent.api.to.DatadiskTO) CreateDatadiskTemplateAnswer(com.cloud.agent.api.storage.CreateDatadiskTemplateAnswer) TemplateObjectTO(org.apache.cloudstack.storage.to.TemplateObjectTO) OVFHelper(com.cloud.agent.api.storage.OVFHelper)

Example 3 with DatadiskTO

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

the class OVFHelper method generateDiskTO.

private DatadiskTO generateDiskTO(OVFFile file, OVFDisk disk, String ovfParentPath, int diskNumber, OVFVirtualHardwareItemTO diskItem) throws InternalErrorException {
    String path = file != null ? ovfParentPath + File.separator + file._href : null;
    if (StringUtils.isNotBlank(path)) {
        File f = new File(path);
        if (!f.exists() || f.isDirectory()) {
            s_logger.error("One of the attached disk or iso does not exists " + path);
            throw new InternalErrorException("One of the attached disk or iso as stated on OVF does not exists " + path);
        }
    }
    Long capacity = disk != null ? disk._capacity : file._size;
    Long fileSize = file != null ? file._size : 0L;
    String controller = "";
    String controllerSubType = "";
    if (disk != null) {
        OVFDiskController cDiskController = disk._controller;
        controller = cDiskController == null ? "" : disk._controller._name;
        controllerSubType = cDiskController == null ? "" : disk._controller._subType;
    }
    boolean isIso = file != null && file.isIso;
    boolean bootable = file != null && file._bootable;
    String diskId = disk == null ? file._id : disk._diskId;
    String configuration = diskItem != null ? diskItem.getConfigurationIds() : null;
    return new DatadiskTO(path, capacity, fileSize, diskId, isIso, bootable, controller, controllerSubType, diskNumber, configuration);
}
Also used : DatadiskTO(com.cloud.agent.api.to.DatadiskTO) InternalErrorException(com.cloud.exception.InternalErrorException) File(java.io.File)

Example 4 with DatadiskTO

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

the class OVFHelper method getOVFVolumeInfoFromFile.

public List<DatadiskTO> getOVFVolumeInfoFromFile(String ovfFilePath, Document doc, String configurationId) throws InternalErrorException {
    if (StringUtils.isBlank(ovfFilePath)) {
        return null;
    }
    File ovfFile = new File(ovfFilePath);
    List<OVFVirtualHardwareItemTO> hardwareItems = getVirtualHardwareItemsFromDocumentTree(doc);
    List<OVFFile> files = extractFilesFromOvfDocumentTree(ovfFile, doc);
    List<OVFDisk> disks = extractDisksFromOvfDocumentTree(doc);
    List<OVFVirtualHardwareItemTO> diskHardwareItems = hardwareItems.stream().filter(x -> x.getResourceType() == OVFVirtualHardwareItemTO.HardwareResourceType.DiskDrive && hardwareItemContainsConfiguration(x, configurationId)).collect(Collectors.toList());
    return matchHardwareItemsToDiskAndFilesInformation(diskHardwareItems, files, disks, ovfFile.getParent());
}
Also used : OVFPropertyTO(com.cloud.agent.api.to.deployasis.OVFPropertyTO) Transformer(javax.xml.transform.Transformer) DOMSource(javax.xml.transform.dom.DOMSource) Arrays(java.util.Arrays) TransformerException(javax.xml.transform.TransformerException) StreamResult(javax.xml.transform.stream.StreamResult) InternalErrorException(com.cloud.exception.InternalErrorException) HashMap(java.util.HashMap) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) NumberUtils(org.apache.commons.lang.math.NumberUtils) ResourceType(com.cloud.configuration.Resource.ResourceType) Logger(org.apache.log4j.Logger) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) CollectionUtils(org.apache.commons.collections.CollectionUtils) Document(org.w3c.dom.Document) Map(java.util.Map) Node(org.w3c.dom.Node) LinkedList(java.util.LinkedList) OVFVirtualHardwareSectionTO(com.cloud.agent.api.to.deployasis.OVFVirtualHardwareSectionTO) PrintWriter(java.io.PrintWriter) DatadiskTO(com.cloud.agent.api.to.DatadiskTO) NodeList(org.w3c.dom.NodeList) StringWriter(java.io.StringWriter) IOException(java.io.IOException) Pair(com.cloud.utils.Pair) Collectors(java.util.stream.Collectors) File(java.io.File) OVFEulaSectionTO(com.cloud.agent.api.to.deployasis.OVFEulaSectionTO) OVFVirtualHardwareItemTO(com.cloud.agent.api.to.deployasis.OVFVirtualHardwareItemTO) OVFConfigurationTO(com.cloud.agent.api.to.deployasis.OVFConfigurationTO) CompressionUtil(com.cloud.utils.compression.CompressionUtil) List(java.util.List) Element(org.w3c.dom.Element) DocumentTraversal(org.w3c.dom.traversal.DocumentTraversal) NodeIterator(org.w3c.dom.traversal.NodeIterator) SAXException(org.xml.sax.SAXException) TransformerFactory(javax.xml.transform.TransformerFactory) NodeFilter(org.w3c.dom.traversal.NodeFilter) Collections(java.util.Collections) OVFNetworkTO(com.cloud.agent.api.to.deployasis.OVFNetworkTO) OVFVirtualHardwareItemTO(com.cloud.agent.api.to.deployasis.OVFVirtualHardwareItemTO) File(java.io.File)

Example 5 with DatadiskTO

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

the class OVFHelper method matchHardwareItemsToDiskAndFilesInformation.

private List<DatadiskTO> matchHardwareItemsToDiskAndFilesInformation(List<OVFVirtualHardwareItemTO> diskHardwareItems, List<OVFFile> files, List<OVFDisk> disks, String ovfParentPath) throws InternalErrorException {
    List<DatadiskTO> diskTOs = new LinkedList<>();
    int diskNumber = 0;
    for (OVFVirtualHardwareItemTO diskItem : diskHardwareItems) {
        if (StringUtils.isBlank(diskItem.getHostResource())) {
            s_logger.error("Missing disk information for hardware item " + diskItem.getElementName() + " " + diskItem.getInstanceId());
            continue;
        }
        String diskId = extractDiskIdFromDiskHostResource(diskItem.getHostResource());
        OVFDisk diskDefinition = getDiskDefinitionFromDiskId(diskId, disks);
        if (diskDefinition == null) {
            s_logger.error("Missing disk definition for disk ID " + diskId);
        }
        OVFFile fileDefinition = getFileDefinitionFromDiskDefinition(diskDefinition._fileRef, files);
        DatadiskTO datadiskTO = generateDiskTO(fileDefinition, diskDefinition, ovfParentPath, diskNumber, diskItem);
        diskTOs.add(datadiskTO);
        diskNumber++;
    }
    List<OVFFile> isoFiles = files.stream().filter(x -> x.isIso).collect(Collectors.toList());
    for (OVFFile isoFile : isoFiles) {
        DatadiskTO isoTO = generateDiskTO(isoFile, null, ovfParentPath, diskNumber, null);
        diskTOs.add(isoTO);
        diskNumber++;
    }
    return diskTOs;
}
Also used : OVFPropertyTO(com.cloud.agent.api.to.deployasis.OVFPropertyTO) Transformer(javax.xml.transform.Transformer) DOMSource(javax.xml.transform.dom.DOMSource) Arrays(java.util.Arrays) TransformerException(javax.xml.transform.TransformerException) StreamResult(javax.xml.transform.stream.StreamResult) InternalErrorException(com.cloud.exception.InternalErrorException) HashMap(java.util.HashMap) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) NumberUtils(org.apache.commons.lang.math.NumberUtils) ResourceType(com.cloud.configuration.Resource.ResourceType) Logger(org.apache.log4j.Logger) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) CollectionUtils(org.apache.commons.collections.CollectionUtils) Document(org.w3c.dom.Document) Map(java.util.Map) Node(org.w3c.dom.Node) LinkedList(java.util.LinkedList) OVFVirtualHardwareSectionTO(com.cloud.agent.api.to.deployasis.OVFVirtualHardwareSectionTO) PrintWriter(java.io.PrintWriter) DatadiskTO(com.cloud.agent.api.to.DatadiskTO) NodeList(org.w3c.dom.NodeList) StringWriter(java.io.StringWriter) IOException(java.io.IOException) Pair(com.cloud.utils.Pair) Collectors(java.util.stream.Collectors) File(java.io.File) OVFEulaSectionTO(com.cloud.agent.api.to.deployasis.OVFEulaSectionTO) OVFVirtualHardwareItemTO(com.cloud.agent.api.to.deployasis.OVFVirtualHardwareItemTO) OVFConfigurationTO(com.cloud.agent.api.to.deployasis.OVFConfigurationTO) CompressionUtil(com.cloud.utils.compression.CompressionUtil) List(java.util.List) Element(org.w3c.dom.Element) DocumentTraversal(org.w3c.dom.traversal.DocumentTraversal) NodeIterator(org.w3c.dom.traversal.NodeIterator) SAXException(org.xml.sax.SAXException) TransformerFactory(javax.xml.transform.TransformerFactory) NodeFilter(org.w3c.dom.traversal.NodeFilter) Collections(java.util.Collections) OVFNetworkTO(com.cloud.agent.api.to.deployasis.OVFNetworkTO) OVFVirtualHardwareItemTO(com.cloud.agent.api.to.deployasis.OVFVirtualHardwareItemTO) DatadiskTO(com.cloud.agent.api.to.DatadiskTO) LinkedList(java.util.LinkedList)

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