use of org.ovirt.engine.api.model.Cpu 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;
}
use of org.ovirt.engine.api.model.Cpu in project ovirt-engine by oVirt.
the class BackendClustersResourceTest method getModel.
static org.ovirt.engine.api.model.Cluster getModel(int index) {
org.ovirt.engine.api.model.Cluster model = new org.ovirt.engine.api.model.Cluster();
model.setName(NAMES[index]);
model.setDescription(DESCRIPTIONS[index]);
model.setDataCenter(new DataCenter());
model.setCpu(new Cpu());
model.getCpu().setType("Intel Xeon");
return model;
}
use of org.ovirt.engine.api.model.Cpu in project ovirt-engine by oVirt.
the class NumaMapper method map.
@Mapping(from = VdsNumaNode.class, to = NumaNode.class)
public static NumaNode map(VdsNumaNode entity, NumaNode template) {
NumaNode model = template != null ? template : new NumaNode();
if (entity.getId() != null) {
model.setId(entity.getId().toString());
}
model.setIndex(entity.getIndex());
model.setMemory(entity.getMemTotal());
if (entity.getCpuIds() != null && entity.getCpuIds().size() > 0) {
Cpu cpu = new Cpu();
Cores cores = new Cores();
for (int id : entity.getCpuIds()) {
Core core = new Core();
core.setIndex(id);
cores.getCores().add(core);
}
cpu.setCores(cores);
model.setCpu(cpu);
}
if (entity.getNumaNodeDistances() != null && entity.getNumaNodeDistances().size() > 0) {
model.setNodeDistance(StringUtils.join(entity.getNumaNodeDistances().values(), " "));
}
return model;
}
use of org.ovirt.engine.api.model.Cpu in project ovirt-engine by oVirt.
the class V3CPUInAdapter method adapt.
@Override
public Cpu adapt(V3CPU from) {
Cpu to = new Cpu();
if (from.isSetArchitecture()) {
to.setArchitecture(Architecture.fromValue(from.getArchitecture()));
}
if (from.isSetCores()) {
to.setCores(new Cores());
to.getCores().getCores().addAll(adaptIn(from.getCores().getCore()));
}
if (from.isSetCpuTune()) {
to.setCpuTune(adaptIn(from.getCpuTune()));
}
if (from.isSetLevel()) {
to.setLevel(from.getLevel());
}
if (from.isSetMode()) {
try {
to.setMode(CpuMode.fromValue(from.getMode()));
} catch (InvalidEnumValueException exception) {
// In version 3 of the API invalid values were accepted, and they meant "disable passthrough". We need
// to preserve that, but we also need to pass to version 4 a valid value, as otherwise it won't do any
// update to the attribute. As both "custom" and "host_model" mean exactly the same we can use any of
// them.
to.setMode(CpuMode.CUSTOM);
}
}
if (from.isSetName()) {
to.setName(from.getName());
}
if (from.isSetSpeed()) {
to.setSpeed(from.getSpeed());
}
if (from.isSetTopology()) {
to.setTopology(adaptIn(from.getTopology()));
}
if (from.isSetId()) {
to.setType(from.getId());
}
return to;
}
use of org.ovirt.engine.api.model.Cpu in project ovirt-engine by oVirt.
the class CPUMapper method map.
@Mapping(from = ServerCpu.class, to = Cpu.class)
public static Cpu map(ServerCpu entity, Cpu template) {
Cpu model = template != null ? template : new Cpu();
model.setName(entity.getCpuName());
model.setLevel(entity.getLevel());
model.setArchitecture(map(entity.getArchitecture(), null));
return model;
}
Aggregations