Search in sources :

Example 6 with ArchitectureType

use of org.ovirt.engine.core.common.businessentities.ArchitectureType 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);
}
Also used : ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) OvfEntityData(org.ovirt.engine.core.common.businessentities.OvfEntityData) XmlDocument(org.ovirt.engine.core.utils.ovf.xml.XmlDocument) Guid(org.ovirt.engine.core.compat.Guid) VmEntityType(org.ovirt.engine.core.common.businessentities.VmEntityType) IOException(java.io.IOException)

Example 7 with ArchitectureType

use of org.ovirt.engine.core.common.businessentities.ArchitectureType in project ovirt-engine by oVirt.

the class OvfUtils method getOsSection.

private ArchitectureType getOsSection(XmlDocument xmlDocument) {
    ArchitectureType archType = null;
    XmlNode content = xmlDocument.selectSingleNode("//*/Content");
    XmlNodeList nodeList = content.selectNodes("Section");
    XmlNode selectedSection = null;
    if (nodeList != null) {
        for (XmlNode section : nodeList) {
            String value = section.attributes.get("xsi:type").getValue();
            if (value.equals("ovf:OperatingSystemSection_Type")) {
                selectedSection = section;
                break;
            }
        }
        if (selectedSection != null) {
            int osId = osRepository.getOsIdByUniqueName(selectedSection.innerText);
            archType = osRepository.getArchitectureFromOS(osId);
        }
    }
    return archType;
}
Also used : ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) XmlNode(org.ovirt.engine.core.utils.ovf.xml.XmlNode) XmlNodeList(org.ovirt.engine.core.utils.ovf.xml.XmlNodeList)

Example 8 with ArchitectureType

use of org.ovirt.engine.core.common.businessentities.ArchitectureType in project ovirt-engine by oVirt.

the class VmOverheadCalculatorImpl method getStaticOverheadInMb.

/**
 * Get the memory overhead QEMU imposes on the VM immediately.
 * The value contains the needed memory size for page tables and
 * memory hotplug structures + expected fixed overhead (shared libraries
 * and internal QEMU structures).
 *
 * @param vm the relevant VM
 * @return required amount of memory in MiB
 * @throws RuntimeException
 *             thrown in case the cluster architecture cannot be identified
 */
@Override
public int getStaticOverheadInMb(VM vm) {
    int vmRam = vm.getVmMemSizeMb();
    ArchitectureType architecture = vm.getClusterArch().getFamily();
    boolean onPpc = architecture == ArchitectureType.ppc;
    int fixedOverhead = onPpc ? 100 : 64;
    int pageTable;
    if (onPpc) {
        int maxRam = vmRam;
        if (FeatureSupported.hotPlugMemory(vm.getCompatibilityVersion(), vm.getClusterArch())) {
            maxRam = vm.getMaxMemorySizeMb();
        }
        int powerOf2 = Integer.highestOneBit(maxRam);
        pageTable = (maxRam > powerOf2 ? powerOf2 * 2 : powerOf2) / 64;
    } else {
        pageTable = vmRam / 512;
    }
    return pageTable + fixedOverhead;
}
Also used : ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType)

Example 9 with ArchitectureType

use of org.ovirt.engine.core.common.businessentities.ArchitectureType in project ovirt-engine by oVirt.

the class HandleVdsCpuFlagsOrClusterChangedCommand method updateMigrateOnError.

private void updateMigrateOnError(Cluster group) {
    ArchitectureType arch = getArchitecture(group);
    boolean isMigrationSupported = FeatureSupported.isMigrationSupported(arch, group.getCompatibilityVersion());
    if (!isMigrationSupported) {
        group.setMigrateOnError(MigrateOnErrorOptions.NO);
    }
}
Also used : ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType)

Example 10 with ArchitectureType

use of org.ovirt.engine.core.common.businessentities.ArchitectureType in project ovirt-engine by oVirt.

the class ClusterModel method populateCPUList.

private void populateCPUList(List<ServerCpu> cpus, boolean canChangeArchitecture) {
    // disable CPU Architecture-Type filtering
    getArchitecture().getSelectedItemChangedEvent().removeListener(this);
    ServerCpu oldSelectedCpu = getCPU().getSelectedItem();
    ArchitectureType oldSelectedArch = getArchitecture().getSelectedItem();
    getCPU().setItems(cpus);
    initSupportedArchitectures();
    getCPU().setSelectedItem(oldSelectedCpu != null ? Linq.firstOrNull(cpus, new Linq.ServerCpuPredicate(oldSelectedCpu.getCpuName())) : null);
    if (getCPU().getSelectedItem() == null || !isCPUinitialized) {
        initCPU();
    }
    if (getIsEdit()) {
        if (!canChangeArchitecture) {
            getArchitecture().setItems(new ArrayList<>(Collections.singletonList(getEntity().getArchitecture())));
        }
        if (oldSelectedArch != null) {
            getArchitecture().setSelectedItem(oldSelectedArch);
        } else {
            if (getEntity() != null) {
                getArchitecture().setSelectedItem(getEntity().getArchitecture());
            } else {
                getArchitecture().setSelectedItem(ArchitectureType.undefined);
            }
        }
    } else {
        getArchitecture().setSelectedItem(ArchitectureType.undefined);
    }
    // enable CPU Architecture-Type filtering
    initCpuArchTypeFiltering();
}
Also used : ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) Linq(org.ovirt.engine.ui.uicommonweb.Linq) ServerCpu(org.ovirt.engine.core.common.businessentities.ServerCpu)

Aggregations

ArchitectureType (org.ovirt.engine.core.common.businessentities.ArchitectureType)18 HashMap (java.util.HashMap)5 ServerCpu (org.ovirt.engine.core.common.businessentities.ServerCpu)4 Guid (org.ovirt.engine.core.compat.Guid)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Map (java.util.Map)3 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)3 QueryParametersBase (org.ovirt.engine.core.common.queries.QueryParametersBase)3 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)3 Linq (org.ovirt.engine.ui.uicommonweb.Linq)3 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)3 Quota (org.ovirt.engine.core.common.businessentities.Quota)2 QuotaEnforcementTypeEnum (org.ovirt.engine.core.common.businessentities.QuotaEnforcementTypeEnum)2 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)2 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 VM (org.ovirt.engine.core.common.businessentities.VM)2 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)2 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)2