use of org.ovirt.engine.core.common.businessentities.VmEntityType in project ovirt-engine by oVirt.
the class DiskListModel method updateCopyAndMoveCommandAvailability.
private void updateCopyAndMoveCommandAvailability(List<Disk> disks) {
boolean isCopyAllowed = true;
boolean isMoveAllowed = true;
if (disks == null || disks.isEmpty() || disks.get(0).getDiskStorageType() != DiskStorageType.IMAGE) {
disableMoveAndCopyCommands();
return;
}
Guid datacenterId = ((DiskImage) disks.get(0)).getStoragePoolId();
boolean foundTemplateDisk = false;
boolean foundVmDisk = false;
boolean foundUnattachedDisk = false;
for (Disk disk : disks) {
if ((!isCopyAllowed && !isMoveAllowed) || disk.getDiskStorageType() != DiskStorageType.IMAGE) {
disableMoveAndCopyCommands();
return;
}
DiskImage diskImage = (DiskImage) disk;
if (diskImage.getImageStatus() != ImageStatus.OK || !datacenterId.equals(diskImage.getStoragePoolId()) || diskImage.isOvfStore()) {
disableMoveAndCopyCommands();
return;
}
VmEntityType vmEntityType = disk.getVmEntityType();
if (vmEntityType == null) {
foundUnattachedDisk = true;
} else if (vmEntityType.isTemplateType()) {
foundTemplateDisk = true;
} else if (vmEntityType.isVmType()) {
foundVmDisk = true;
}
if (foundTemplateDisk && (foundUnattachedDisk || foundVmDisk)) {
isCopyAllowed = false;
}
if (vmEntityType != null && vmEntityType.isTemplateType()) {
isMoveAllowed = false;
}
}
getCopyCommand().setIsExecutionAllowed(isCopyAllowed);
getMoveCommand().setIsExecutionAllowed(isMoveAllowed);
}
use of org.ovirt.engine.core.common.businessentities.VmEntityType in project ovirt-engine by oVirt.
the class AbstractDiskRowMapper method handleEntityType.
private static void handleEntityType(String entityType, Disk entity) {
if (entityType != null && !entityType.isEmpty()) {
VmEntityType vmEntityType = VmEntityType.valueOf(entityType);
entity.setVmEntityType(vmEntityType);
}
}
use of org.ovirt.engine.core.common.businessentities.VmEntityType in project ovirt-engine by oVirt.
the class OvfUtils method analyzeOvfFile.
private void analyzeOvfFile(List<UnregisteredDisk> unregisteredDisks, Guid storageDomainId, List<OvfEntityData> ovfEntityDataFromTar, Entry<String, ByteBuffer> fileEntry) {
String ovfData = new String(fileEntry.getValue().array());
VmEntityType vmType = getVmEntityType(ovfData);
ArchitectureType archType = null;
Guid entityId = getEntityId(fileEntry.getKey());
String vmName = getEntityName(ovfData);
try {
XmlDocument xmlDocument = new XmlDocument(ovfData);
archType = getOsSection(xmlDocument);
if (isExternalVM(xmlDocument)) {
log.warn("Retrieve an external OVF Entity from storage domain ID '{}' for entity ID '{}'," + " entity name '{}' and VM Type of '{}'." + " This OVF will be ignored since external VMs should not be restored.", storageDomainId, getEntityId(fileEntry.getKey()), getEntityName(ovfData), vmType.name());
return;
}
updateUnregisteredDisksWithVMs(unregisteredDisks, entityId, vmName, xmlDocument);
} catch (Exception e) {
log.error("Could not parse VM's disks or architecture, file name: {}, content size: {}, error: {}", fileEntry.getKey(), ovfData.length(), e.getMessage());
log.debug("Exception", e);
return;
}
// Creates an OVF entity data.
OvfEntityData ovfEntityData = createOvfEntityData(storageDomainId, ovfData, vmType, vmName, archType, entityId);
log.info("Retrieve OVF Entity from storage domain ID '{}' for entity ID '{}', entity name '{}' and VM Type of '{}'", storageDomainId, getEntityId(fileEntry.getKey()), getEntityName(ovfData), vmType.name());
ovfEntityDataFromTar.add(ovfEntityData);
}
use of org.ovirt.engine.core.common.businessentities.VmEntityType in project ovirt-engine by oVirt.
the class OvfUtils method getVmEntityType.
private static VmEntityType getVmEntityType(String ovfData) {
VmEntityType vmEntityType = VmEntityType.VM;
int indexOfEntityType = ovfData.indexOf(TEMPLATE_ENTITY_TYPE);
if (indexOfEntityType != -1) {
vmEntityType = VmEntityType.TEMPLATE;
}
return vmEntityType;
}
Aggregations