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;
}
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;
}
}
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;
}
Aggregations