Search in sources :

Example 1 with Display

use of org.ovirt.engine.api.model.Display in project ovirt-engine by oVirt.

the class HostMapper method map.

@Mapping(from = VDS.class, to = Host.class)
public static Host map(VDS entity, Host template) {
    Host model = template != null ? template : new Host();
    model.setId(entity.getId().toString());
    model.setName(entity.getName());
    model.setComment(entity.getComment());
    if (entity.getClusterId() != null) {
        Cluster cluster = new Cluster();
        cluster.setId(entity.getClusterId().toString());
        model.setCluster(cluster);
    }
    model.setAddress(entity.getHostName());
    if (entity.getPort() > 0) {
        model.setPort(entity.getPort());
    }
    // We return always STOMP because support for XML-RPC was removed in version 4.1 of the engine.
    model.setProtocol(HostProtocol.STOMP);
    HostStatus status = map(entity.getStatus(), null);
    model.setStatus(status);
    if (entity.getExternalStatus() != null) {
        ExternalStatus externalStatus = ExternalStatusMapper.map(entity.getExternalStatus());
        model.setExternalStatus(externalStatus);
    }
    if (status == HostStatus.NON_OPERATIONAL) {
        model.setStatusDetail(entity.getNonOperationalReason().name().toLowerCase());
    } else if (status == HostStatus.MAINTENANCE || status == HostStatus.PREPARING_FOR_MAINTENANCE) {
        model.setStatusDetail(entity.getMaintenanceReason());
    }
    Spm spm = new Spm();
    spm.setPriority(entity.getVdsSpmPriority());
    if (entity.getSpmStatus() != null) {
        spm.setStatus(mapSpmStatus(entity.getSpmStatus()));
    }
    model.setSpm(spm);
    if (entity.getVersion() != null && entity.getVersion().getMajor() != -1 && entity.getVersion().getMinor() != -1 && entity.getVersion().getRevision() != -1 && entity.getVersion().getBuild() != -1) {
        Version version = new Version();
        version.setMajor(entity.getVersion().getMajor());
        version.setMinor(entity.getVersion().getMinor());
        version.setRevision(entity.getVersion().getRevision());
        version.setBuild(entity.getVersion().getBuild());
        version.setFullVersion(entity.getVersion().getRpmName());
        model.setVersion(version);
    }
    model.setOs(mapOperatingSystem(entity));
    model.setKsm(new Ksm());
    model.getKsm().setEnabled(Boolean.TRUE.equals(entity.getKsmState()));
    model.setTransparentHugepages(new TransparentHugePages());
    model.getTransparentHugepages().setEnabled(!(entity.getTransparentHugePagesState() == null || entity.getTransparentHugePagesState() == VdsTransparentHugePagesState.Never));
    if (entity.getIScsiInitiatorName() != null) {
        model.setIscsi(new IscsiDetails());
        model.getIscsi().setInitiator(entity.getIScsiInitiatorName());
    }
    model.setPowerManagement(map(entity, (PowerManagement) null));
    model.setHardwareInformation(map(entity, (HardwareInformation) null));
    model.setSsh(map(entity.getStaticData(), null));
    Cpu cpu = new Cpu();
    CpuTopology cpuTopology = new CpuTopology();
    if (entity.getCpuSockets() != null) {
        cpuTopology.setSockets(entity.getCpuSockets());
        if (entity.getCpuCores() != null) {
            cpuTopology.setCores(entity.getCpuCores() / entity.getCpuSockets());
            if (entity.getCpuThreads() != null) {
                cpuTopology.setThreads(entity.getCpuThreads() / entity.getCpuCores());
            }
        }
    }
    cpu.setTopology(cpuTopology);
    cpu.setName(entity.getCpuModel());
    if (entity.getCpuSpeedMh() != null) {
        cpu.setSpeed(new BigDecimal(entity.getCpuSpeedMh()));
    }
    model.setCpu(cpu);
    VmSummary vmSummary = new VmSummary();
    vmSummary.setActive(entity.getVmActive());
    vmSummary.setMigrating(entity.getVmMigrating());
    vmSummary.setTotal(entity.getVmCount());
    model.setSummary(vmSummary);
    if (entity.getVdsType() != null) {
        HostType type = map(entity.getVdsType(), null);
        model.setType(type);
    }
    model.setMemory(Long.valueOf(entity.getPhysicalMemMb() == null ? 0 : entity.getPhysicalMemMb() * BYTES_IN_MEGABYTE));
    model.setMaxSchedulingMemory((int) entity.getMaxSchedulingMemory() * BYTES_IN_MEGABYTE);
    if (entity.getLibvirtVersion() != null && entity.getLibvirtVersion().getMajor() != -1 && entity.getLibvirtVersion().getMinor() != -1 && entity.getLibvirtVersion().getRevision() != -1 && entity.getLibvirtVersion().getBuild() != -1) {
        Version version = new Version();
        version.setMajor(entity.getLibvirtVersion().getMajor());
        version.setMinor(entity.getLibvirtVersion().getMinor());
        version.setRevision(entity.getLibvirtVersion().getRevision());
        version.setBuild(entity.getLibvirtVersion().getBuild());
        version.setFullVersion(entity.getLibvirtVersion().getRpmName());
        model.setLibvirtVersion(version);
    }
    if (entity.getConsoleAddress() != null && !"".equals(entity.getConsoleAddress())) {
        model.setDisplay(new Display());
        model.getDisplay().setAddress(entity.getConsoleAddress());
    }
    model.setKdumpStatus(map(entity.getKdumpStatus(), null));
    model.setSeLinux(map(entity, (SeLinux) null));
    model.setAutoNumaStatus(map(entity.getAutoNumaBalancing(), null));
    model.setNumaSupported(entity.isNumaSupport());
    if (entity.getHostProviderId() != null) {
        model.setExternalHostProvider(new ExternalHostProvider());
        model.getExternalHostProvider().setId(entity.getHostProviderId().toString());
    }
    model.setUpdateAvailable(entity.isUpdateAvailable());
    HostDevicePassthrough devicePassthrough = model.getDevicePassthrough();
    if (devicePassthrough == null) {
        devicePassthrough = new HostDevicePassthrough();
        model.setDevicePassthrough(devicePassthrough);
    }
    devicePassthrough.setEnabled(entity.isHostDevicePassthroughEnabled());
    if (entity.getHostName() != null) {
        String subject = CertificateSubjectHelper.getCertificateSubject(entity.getHostName());
        model.setCertificate(new Certificate());
        model.getCertificate().setSubject(subject);
        model.getCertificate().setOrganization(subject.split(",")[0].replace("O=", ""));
    }
    return model;
}
Also used : ExternalHostProvider(org.ovirt.engine.api.model.ExternalHostProvider) Ksm(org.ovirt.engine.api.model.Ksm) IscsiDetails(org.ovirt.engine.api.model.IscsiDetails) HostDevicePassthrough(org.ovirt.engine.api.model.HostDevicePassthrough) TransparentHugePages(org.ovirt.engine.api.model.TransparentHugePages) Cluster(org.ovirt.engine.api.model.Cluster) Cpu(org.ovirt.engine.api.model.Cpu) Host(org.ovirt.engine.api.model.Host) HardwareInformation(org.ovirt.engine.api.model.HardwareInformation) BigDecimal(java.math.BigDecimal) ExternalStatus(org.ovirt.engine.api.model.ExternalStatus) CpuTopology(org.ovirt.engine.api.model.CpuTopology) Spm(org.ovirt.engine.api.model.Spm) PowerManagement(org.ovirt.engine.api.model.PowerManagement) HostType(org.ovirt.engine.api.model.HostType) VmSummary(org.ovirt.engine.api.model.VmSummary) Version(org.ovirt.engine.api.model.Version) HostStatus(org.ovirt.engine.api.model.HostStatus) SeLinux(org.ovirt.engine.api.model.SeLinux) Display(org.ovirt.engine.api.model.Display) Certificate(org.ovirt.engine.api.model.Certificate)

Example 2 with Display

use of org.ovirt.engine.api.model.Display in project ovirt-engine by oVirt.

the class VmPoolMapper method map.

@Mapping(from = org.ovirt.engine.core.common.businessentities.VmPool.class, to = VmPool.class)
public static VmPool map(org.ovirt.engine.core.common.businessentities.VmPool entity, VmPool template) {
    VmPool model = template != null ? template : new VmPool();
    model.setId(entity.getVmPoolId().toString());
    model.setName(entity.getName());
    model.setDescription(entity.getVmPoolDescription());
    model.setComment(entity.getComment());
    model.setSize(entity.getAssignedVmsCount());
    model.setPrestartedVms(entity.getPrestartedVms());
    if (entity.getClusterId() != null || entity.getClusterName() != null) {
        model.setCluster(new Cluster());
        model.getCluster().setId(entity.getClusterId().toString());
    }
    model.setMaxUserVms(entity.getMaxAssignedVmsPerUser());
    if (StringUtils.isNotBlank(entity.getSpiceProxy())) {
        Display display = new Display();
        display.setProxy(entity.getSpiceProxy());
        model.setDisplay(display);
    }
    model.setType(map(entity.getVmPoolType(), null));
    model.setStateful(entity.isStateful());
    model.setAutoStorageSelect(entity.isAutoStorageSelect());
    return model;
}
Also used : VmPool(org.ovirt.engine.api.model.VmPool) Cluster(org.ovirt.engine.api.model.Cluster) Display(org.ovirt.engine.api.model.Display)

Example 3 with Display

use of org.ovirt.engine.api.model.Display in project ovirt-engine by oVirt.

the class BackendVmDeviceHelper method setCertificateInfo.

public static void setCertificateInfo(BackendResource resouce, Vm vm) {
    QueryReturnValue result = resouce.runQuery(QueryType.GetVdsCertificateSubjectByVmId, new IdQueryParameters(resouce.asGuid(vm.getId())));
    if (result != null && result.getSucceeded() && result.getReturnValue() != null) {
        if (!vm.isSetDisplay()) {
            vm.setDisplay(new Display());
        }
        vm.getDisplay().setCertificate(new Certificate());
        vm.getDisplay().getCertificate().setSubject(result.getReturnValue().toString());
    }
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Display(org.ovirt.engine.api.model.Display) Certificate(org.ovirt.engine.api.model.Certificate)

Example 4 with Display

use of org.ovirt.engine.api.model.Display in project ovirt-engine by oVirt.

the class VmMapper method map.

public static Vm map(org.ovirt.engine.core.common.businessentities.VM entity, Vm template, boolean showDynamicInfo) {
    Vm model = template != null ? template : new Vm();
    mapVmBaseEntityToModel(model, entity.getStaticData());
    if (entity.getVmtGuid() != null) {
        model.setTemplate(new Template());
        model.getTemplate().setId(entity.getVmtGuid().toString());
        // otherwise the value of this property is meaningless and misleading
        if (entity.isStateless()) {
            model.setUseLatestTemplateVersion(entity.isUseLatestVersion());
        }
    }
    if (entity.getOriginalTemplateGuid() != null) {
        model.setOriginalTemplate(new Template());
        model.getOriginalTemplate().setId(entity.getOriginalTemplateGuid().toString());
    }
    if (entity.getInstanceTypeId() != null) {
        model.setInstanceType(new InstanceType());
        model.getInstanceType().setId(entity.getInstanceTypeId().toString());
    }
    if (entity.getStatus() != null) {
        model.setStatus(mapVmStatus(entity.getStatus()));
        if (entity.getStatus() == VMStatus.Paused) {
            model.setStatusDetail(entity.getVmPauseStatus().name().toLowerCase());
        } else if (entity.getStatus() == VMStatus.Down && entity.getBackgroundOperationDescription() != null) {
            model.setStatusDetail(entity.getBackgroundOperationDescription());
        }
    }
    if (entity.getStopReason() != null) {
        model.setStopReason(entity.getStopReason());
    }
    if (entity.getBootSequence() != null || entity.getKernelUrl() != null || entity.getInitrdUrl() != null || entity.getKernelParams() != null) {
        OperatingSystem os = new OperatingSystem();
        os.setType(SimpleDependencyInjector.getInstance().get(OsRepository.class).getUniqueOsNames().get(entity.getVmOsId()));
        os.setKernel(entity.getKernelUrl());
        os.setInitrd(entity.getInitrdUrl());
        os.setCmdline(entity.getKernelParams());
        model.setOs(os);
    }
    if (entity.isUseHostCpuFlags()) {
        model.getCpu().setMode(CpuMode.HOST_PASSTHROUGH);
    }
    model.getCpu().setCpuTune(stringToCpuTune(entity.getCpuPinning()));
    model.getCpu().setArchitecture(CPUMapper.map(entity.getClusterArch(), null));
    if (entity.getVmPoolId() != null) {
        VmPool pool = new VmPool();
        pool.setId(entity.getVmPoolId().toString());
        model.setVmPool(pool);
    }
    model.setDisplay(new Display());
    // and dynamic value (current/last run value, that can be different in case of run-once or edit while running)
    if (showDynamicInfo && entity.getDynamicData() != null && entity.getStatus().isRunningOrPaused()) {
        if (model.getOs() != null && entity.getBootSequence() != null) {
            Boot boot = map(entity.getBootSequence(), null);
            model.getOs().setBoot(boot);
        }
    } else {
        if (model.getOs() != null) {
            Boot boot = map(entity.getDefaultBootSequence(), null);
            model.getOs().setBoot(boot);
        }
    }
    if (entity.hasIllegalImages()) {
        model.setHasIllegalImages(true);
    }
    // fill dynamic data
    if (entity.getDynamicData() != null && !entity.getStatus().isNotRunning()) {
        if (entity.getRunOnVds() != null) {
            model.setHost(new Host());
            model.getHost().setId(entity.getRunOnVds().toString());
        }
        final boolean hasFqdn = entity.getFqdn() != null && !entity.getFqdn().isEmpty();
        if (hasFqdn) {
            model.setFqdn(entity.getFqdn());
        }
        final boolean hasGuestOsVersion = entity.getGuestOsVersion() != null && !entity.getGuestOsVersion().isEmpty();
        if (hasGuestOsVersion) {
            GuestOperatingSystem os = model.getGuestOperatingSystem();
            if (os == null) {
                os = new GuestOperatingSystem();
                model.setGuestOperatingSystem(os);
            }
            os.setArchitecture(entity.getGuestOsArch().name());
            os.setCodename(entity.getGuestOsCodename());
            os.setDistribution(entity.getGuestOsDistribution());
            String kernelVersionString = entity.getGuestOsKernelVersion();
            if (StringUtils.isNotEmpty(kernelVersionString)) {
                org.ovirt.engine.api.model.Version kernelVersion = VersionMapper.fromVersionString(kernelVersionString);
                if (kernelVersion != null) {
                    if (os.getKernel() == null) {
                        os.setKernel(new Kernel());
                    }
                    os.getKernel().setVersion(kernelVersion);
                    os.getKernel().getVersion().setFullVersion(entity.getGuestOsKernelVersion());
                }
            }
            String osVersionString = entity.getGuestOsVersion();
            if (StringUtils.isNotEmpty(osVersionString)) {
                os.setVersion(VersionMapper.fromVersionString(osVersionString));
                if (os.getVersion() != null) {
                    os.getVersion().setFullVersion(entity.getGuestOsVersion());
                }
            }
            os.setFamily(entity.getGuestOsType().name());
        }
        final boolean hasTimezoneName = entity.getGuestOsTimezoneName() != null && !entity.getGuestOsTimezoneName().isEmpty();
        if (hasTimezoneName) {
            TimeZone guestTz = model.getGuestTimeZone();
            if (guestTz == null) {
                guestTz = new TimeZone();
                model.setGuestTimeZone(guestTz);
            }
            guestTz.setName(entity.getGuestOsTimezoneName());
            guestTz.setUtcOffset(TimeZoneMapper.mapUtcOffsetToDisplayString(entity.getGuestOsTimezoneOffset()));
        }
        if (entity.getLastStartTime() != null) {
            model.setStartTime(DateMapper.map(entity.getLastStartTime(), null));
        }
        model.setRunOnce(entity.isRunOnce());
        org.ovirt.engine.core.common.businessentities.GraphicsType graphicsType = deriveGraphicsType(entity.getGraphicsInfos());
        if (graphicsType != null) {
            model.getDisplay().setType(DisplayMapper.map(graphicsType, null));
            GraphicsInfo graphicsInfo = entity.getGraphicsInfos().get(graphicsType);
            model.getDisplay().setAddress(graphicsInfo == null ? null : graphicsInfo.getIp());
            Integer displayPort = graphicsInfo == null ? null : graphicsInfo.getPort();
            model.getDisplay().setPort(displayPort == null || displayPort.equals(-1) ? null : displayPort);
            Integer displaySecurePort = graphicsInfo == null ? null : graphicsInfo.getTlsPort();
            model.getDisplay().setSecurePort(displaySecurePort == null || displaySecurePort.equals(-1) ? null : displaySecurePort);
        }
    }
    if (entity.getLastStopTime() != null) {
        model.setStopTime(DateMapper.map(entity.getLastStopTime(), null));
    }
    model.getDisplay().setMonitors(entity.getNumOfMonitors());
    model.getDisplay().setSingleQxlPci(entity.getSingleQxlPci());
    model.getDisplay().setAllowOverride(entity.getAllowConsoleReconnect());
    model.getDisplay().setSmartcardEnabled(entity.isSmartcardEnabled());
    model.getDisplay().setKeyboardLayout(entity.getDefaultVncKeyboardLayout());
    model.getDisplay().setFileTransferEnabled(entity.isSpiceFileTransferEnabled());
    model.getDisplay().setCopyPasteEnabled(entity.isSpiceCopyPasteEnabled());
    model.getDisplay().setProxy(getEffectiveSpiceProxy(entity));
    model.getDisplay().setDisconnectAction(map(entity.getConsoleDisconnectAction(), null).toString());
    model.setStateless(entity.isStateless());
    model.setDeleteProtected(entity.isDeleteProtected());
    model.setSso(SsoMapper.map(entity.getSsoMethod(), null));
    model.setHighAvailability(new HighAvailability());
    model.getHighAvailability().setEnabled(entity.isAutoStartup());
    model.getHighAvailability().setPriority(entity.getPriority());
    if (entity.getOrigin() != null) {
        model.setOrigin(map(entity.getOrigin(), null));
    }
    if (entity.getVmInit() != null) {
        model.setInitialization(InitializationMapper.map(entity.getVmInit(), null));
    }
    model.setNextRunConfigurationExists(entity.isNextRunConfigurationExists());
    model.setNumaTuneMode(map(entity.getNumaTuneMode(), null));
    if (entity.getProviderId() != null) {
        model.setExternalHostProvider(new ExternalHostProvider());
        model.getExternalHostProvider().setId(entity.getProviderId().toString());
    }
    return model;
}
Also used : GuestOperatingSystem(org.ovirt.engine.api.model.GuestOperatingSystem) OperatingSystem(org.ovirt.engine.api.model.OperatingSystem) ExternalHostProvider(org.ovirt.engine.api.model.ExternalHostProvider) OsRepository(org.ovirt.engine.core.common.osinfo.OsRepository) GraphicsInfo(org.ovirt.engine.core.common.businessentities.GraphicsInfo) Boot(org.ovirt.engine.api.model.Boot) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Template(org.ovirt.engine.api.model.Template) Vm(org.ovirt.engine.api.model.Vm) InstanceType(org.ovirt.engine.api.model.InstanceType) Kernel(org.ovirt.engine.api.model.Kernel) GuestOperatingSystem(org.ovirt.engine.api.model.GuestOperatingSystem) Host(org.ovirt.engine.api.model.Host) HighAvailability(org.ovirt.engine.api.model.HighAvailability) TimeZone(org.ovirt.engine.api.model.TimeZone) VmPool(org.ovirt.engine.api.model.VmPool) Display(org.ovirt.engine.api.model.Display)

Example 5 with Display

use of org.ovirt.engine.api.model.Display in project ovirt-engine by oVirt.

the class BackendVmResource method setCertificateInfo.

public void setCertificateInfo(Vm model) {
    QueryReturnValue result = runQuery(QueryType.GetVdsCertificateSubjectByVmId, new IdQueryParameters(asGuid(model.getId())));
    if (result != null && result.getSucceeded() && result.getReturnValue() != null) {
        if (!model.isSetDisplay()) {
            model.setDisplay(new Display());
        }
        model.getDisplay().setCertificate(new Certificate());
        model.getDisplay().getCertificate().setSubject(result.getReturnValue().toString());
    }
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Display(org.ovirt.engine.api.model.Display) Certificate(org.ovirt.engine.api.model.Certificate)

Aggregations

Display (org.ovirt.engine.api.model.Display)8 Certificate (org.ovirt.engine.api.model.Certificate)3 Cluster (org.ovirt.engine.api.model.Cluster)2 ExternalHostProvider (org.ovirt.engine.api.model.ExternalHostProvider)2 Host (org.ovirt.engine.api.model.Host)2 Vm (org.ovirt.engine.api.model.Vm)2 VmPool (org.ovirt.engine.api.model.VmPool)2 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)2 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)2 BigDecimal (java.math.BigDecimal)1 Action (org.ovirt.engine.api.model.Action)1 Boot (org.ovirt.engine.api.model.Boot)1 Cpu (org.ovirt.engine.api.model.Cpu)1 CpuTopology (org.ovirt.engine.api.model.CpuTopology)1 DisplayType (org.ovirt.engine.api.model.DisplayType)1 ExternalStatus (org.ovirt.engine.api.model.ExternalStatus)1 GuestOperatingSystem (org.ovirt.engine.api.model.GuestOperatingSystem)1 HardwareInformation (org.ovirt.engine.api.model.HardwareInformation)1 HighAvailability (org.ovirt.engine.api.model.HighAvailability)1 HostDevicePassthrough (org.ovirt.engine.api.model.HostDevicePassthrough)1