Search in sources :

Example 1 with PowerManagement

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

the class HostMapper method map.

@Mapping(from = PowerManagement.class, to = VdsStatic.class)
public static VdsStatic map(PowerManagement model, VdsStatic template) {
    VdsStatic entity = template != null ? template : new VdsStatic();
    if (model.isSetEnabled()) {
        entity.setPmEnabled(model.isEnabled());
    }
    if (model.isSetAutomaticPmEnabled()) {
        entity.setDisablePowerManagementPolicy(!model.isAutomaticPmEnabled());
    }
    if (model.isSetPmProxies()) {
        List<FenceProxySourceType> fenceProxySources = model.getPmProxies().getPmProxies().stream().map(pmProxy -> FenceProxySourceType.forValue(pmProxy.getType().toString())).collect(toCollection(LinkedList::new));
        entity.setFenceProxySources(fenceProxySources);
    }
    if (model.isSetKdumpDetection()) {
        entity.setPmKdumpDetection(model.isKdumpDetection());
    }
    return entity;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) TransparentHugePages(org.ovirt.engine.api.model.TransparentHugePages) VERSION_NOT_SET(org.ovirt.engine.core.compat.Version.VERSION_NOT_SET) Host(org.ovirt.engine.api.model.Host) ExternalNetworkProviderConfiguration(org.ovirt.engine.api.model.ExternalNetworkProviderConfiguration) SpmStatus(org.ovirt.engine.api.model.SpmStatus) Hook(org.ovirt.engine.api.model.Hook) PowerManagement(org.ovirt.engine.api.model.PowerManagement) Cluster(org.ovirt.engine.api.model.Cluster) SshAuthenticationMethod(org.ovirt.engine.api.model.SshAuthenticationMethod) VdsTransparentHugePagesState(org.ovirt.engine.core.common.businessentities.VdsTransparentHugePagesState) SeLinuxMode(org.ovirt.engine.api.model.SeLinuxMode) Ksm(org.ovirt.engine.api.model.Ksm) BigDecimal(java.math.BigDecimal) PmProxyType(org.ovirt.engine.api.model.PmProxyType) Ssh(org.ovirt.engine.api.model.Ssh) CertificateSubjectHelper(org.ovirt.engine.core.utils.CertificateSubjectHelper) Map(java.util.Map) OS(org.ovirt.engine.core.utils.OS) Version(org.ovirt.engine.api.model.Version) HostType(org.ovirt.engine.api.model.HostType) User(org.ovirt.engine.api.model.User) PmProxy(org.ovirt.engine.api.model.PmProxy) SeLinux(org.ovirt.engine.api.model.SeLinux) Certificate(org.ovirt.engine.api.model.Certificate) IscsiDetails(org.ovirt.engine.api.model.IscsiDetails) Hooks(org.ovirt.engine.api.model.Hooks) FenceProxySourceType(org.ovirt.engine.core.common.businessentities.pm.FenceProxySourceType) VdsSpmStatus(org.ovirt.engine.core.common.businessentities.VdsSpmStatus) HostedEngine(org.ovirt.engine.api.model.HostedEngine) Objects(java.util.Objects) VdsOperationActionParameters(org.ovirt.engine.core.common.action.VdsOperationActionParameters) AutoNumaBalanceStatus(org.ovirt.engine.core.common.businessentities.AutoNumaBalanceStatus) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Action(org.ovirt.engine.api.model.Action) Display(org.ovirt.engine.api.model.Display) KdumpStatus(org.ovirt.engine.api.model.KdumpStatus) VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) HostProtocol(org.ovirt.engine.api.model.HostProtocol) Guid(org.ovirt.engine.core.compat.Guid) HashMap(java.util.HashMap) HostDevicePassthrough(org.ovirt.engine.api.model.HostDevicePassthrough) OperatingSystem(org.ovirt.engine.api.model.OperatingSystem) GuidUtils(org.ovirt.engine.api.restapi.utils.GuidUtils) Collectors.toCollection(java.util.stream.Collectors.toCollection) ExternalStatus(org.ovirt.engine.api.model.ExternalStatus) Option(org.ovirt.engine.api.model.Option) HardwareInformation(org.ovirt.engine.api.model.HardwareInformation) LinkedList(java.util.LinkedList) OsType(org.ovirt.engine.api.model.OsType) CpuTopology(org.ovirt.engine.api.model.CpuTopology) PmProxies(org.ovirt.engine.api.model.PmProxies) VDSType(org.ovirt.engine.core.common.businessentities.VDSType) AutoNumaStatus(org.ovirt.engine.api.model.AutoNumaStatus) Cpu(org.ovirt.engine.api.model.Cpu) ExternalHostProvider(org.ovirt.engine.api.model.ExternalHostProvider) Spm(org.ovirt.engine.api.model.Spm) VmSummary(org.ovirt.engine.api.model.VmSummary) Options(org.ovirt.engine.api.model.Options) VDS(org.ovirt.engine.core.common.businessentities.VDS) HostStatus(org.ovirt.engine.api.model.HostStatus) VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) FenceProxySourceType(org.ovirt.engine.core.common.businessentities.pm.FenceProxySourceType)

Example 2 with PowerManagement

use of org.ovirt.engine.api.model.PowerManagement 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 3 with PowerManagement

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

the class V3PowerManagementInAdapter method adapt.

@Override
public PowerManagement adapt(V3PowerManagement from) {
    PowerManagement to = new PowerManagement();
    if (from.isSetAddress()) {
        to.setAddress(from.getAddress());
    }
    if (from.isSetAgents()) {
        to.setAgents(new Agents());
        to.getAgents().getAgents().addAll(adaptIn(from.getAgents().getAgents()));
    }
    if (from.isSetAutomaticPmEnabled()) {
        to.setAutomaticPmEnabled(from.isAutomaticPmEnabled());
    }
    if (from.isSetEnabled()) {
        to.setEnabled(from.isEnabled());
    }
    if (from.isSetKdumpDetection()) {
        to.setKdumpDetection(from.isKdumpDetection());
    }
    if (from.isSetOptions()) {
        to.setOptions(new Options());
        to.getOptions().getOptions().addAll(adaptIn(from.getOptions().getOptions()));
    }
    if (from.isSetPassword()) {
        to.setPassword(from.getPassword());
    }
    if (from.isSetPmProxies()) {
        to.setPmProxies(new PmProxies());
        to.getPmProxies().getPmProxies().addAll(adaptIn(from.getPmProxies().getPmProxy()));
    }
    if (from.isSetStatus() && from.getStatus().isSetState()) {
        to.setStatus(PowerManagementStatus.fromValue(from.getStatus().getState()));
    }
    if (from.isSetType()) {
        to.setType(from.getType());
    }
    if (from.isSetUsername()) {
        to.setUsername(from.getUsername());
    }
    return to;
}
Also used : PowerManagement(org.ovirt.engine.api.model.PowerManagement) V3PowerManagement(org.ovirt.engine.api.v3.types.V3PowerManagement) Options(org.ovirt.engine.api.model.Options) Agents(org.ovirt.engine.api.model.Agents) PmProxies(org.ovirt.engine.api.model.PmProxies)

Example 4 with PowerManagement

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

the class HostMapper method map.

@Mapping(from = VDS.class, to = PowerManagement.class)
public static PowerManagement map(VDS entity, PowerManagement template) {
    PowerManagement model = template != null ? template : new PowerManagement();
    if (entity.getFenceProxySources() != null) {
        PmProxies pmProxies = new PmProxies();
        for (FenceProxySourceType fenceProxySource : entity.getFenceProxySources()) {
            PmProxy pmProxy = new PmProxy();
            pmProxy.setType(map(fenceProxySource, null));
            pmProxies.getPmProxies().add(pmProxy);
        }
        model.setPmProxies(pmProxies);
    }
    model.setKdumpDetection(entity.isPmKdumpDetection());
    model.setEnabled(entity.isPmEnabled());
    model.setAutomaticPmEnabled(!entity.isDisablePowerManagementPolicy());
    return model;
}
Also used : PowerManagement(org.ovirt.engine.api.model.PowerManagement) FenceProxySourceType(org.ovirt.engine.core.common.businessentities.pm.FenceProxySourceType) PmProxies(org.ovirt.engine.api.model.PmProxies) PmProxy(org.ovirt.engine.api.model.PmProxy)

Example 5 with PowerManagement

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

the class BackendHostResource method getFenceStatus.

private Response getFenceStatus(Action action) {
    FenceOperationResult result = getEntity(FenceOperationResult.class, QueryType.GetVdsFenceStatus, new IdQueryParameters(guid), guid.toString());
    if (result.getStatus() == Status.SUCCESS) {
        PowerManagement pm = new PowerManagement();
        pm.setStatus(convertPowerStatus(result.getPowerStatus()));
        action.setPowerManagement(pm);
        return actionSuccess(action);
    } else {
        return handleFailure(action, result.getMessage());
    }
}
Also used : PowerManagement(org.ovirt.engine.api.model.PowerManagement) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) FenceOperationResult(org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult)

Aggregations

PowerManagement (org.ovirt.engine.api.model.PowerManagement)5 BigDecimal (java.math.BigDecimal)2 Certificate (org.ovirt.engine.api.model.Certificate)2 Cluster (org.ovirt.engine.api.model.Cluster)2 Cpu (org.ovirt.engine.api.model.Cpu)2 CpuTopology (org.ovirt.engine.api.model.CpuTopology)2 Display (org.ovirt.engine.api.model.Display)2 ExternalHostProvider (org.ovirt.engine.api.model.ExternalHostProvider)2 ExternalStatus (org.ovirt.engine.api.model.ExternalStatus)2 HardwareInformation (org.ovirt.engine.api.model.HardwareInformation)2 Host (org.ovirt.engine.api.model.Host)2 HostDevicePassthrough (org.ovirt.engine.api.model.HostDevicePassthrough)2 HostStatus (org.ovirt.engine.api.model.HostStatus)2 HostType (org.ovirt.engine.api.model.HostType)2 IscsiDetails (org.ovirt.engine.api.model.IscsiDetails)2 Ksm (org.ovirt.engine.api.model.Ksm)2 Options (org.ovirt.engine.api.model.Options)2 PmProxies (org.ovirt.engine.api.model.PmProxies)2 SeLinux (org.ovirt.engine.api.model.SeLinux)2 Spm (org.ovirt.engine.api.model.Spm)2