use of org.ovirt.engine.api.v3.types.V3Host in project ovirt-engine by oVirt.
the class V3HostInAdapter method adapt.
@Override
public Host adapt(V3Host from) {
Host to = new Host();
if (from.isSetLinks()) {
to.getLinks().addAll(adaptIn(from.getLinks()));
}
if (from.isSetActions()) {
to.setActions(adaptIn(from.getActions()));
}
if (from.isSetAddress()) {
to.setAddress(from.getAddress());
}
if (from.isSetAutoNumaStatus()) {
to.setAutoNumaStatus(AutoNumaStatus.fromValue(from.getAutoNumaStatus()));
}
if (from.isSetCertificate()) {
to.setCertificate(adaptIn(from.getCertificate()));
}
if (from.isSetCluster()) {
to.setCluster(adaptIn(from.getCluster()));
}
if (from.isSetComment()) {
to.setComment(from.getComment());
}
if (from.isSetCpu()) {
to.setCpu(adaptIn(from.getCpu()));
}
if (from.isSetDescription()) {
to.setDescription(from.getDescription());
}
if (from.isSetDevicePassthrough()) {
to.setDevicePassthrough(adaptIn(from.getDevicePassthrough()));
}
if (from.isSetDisplay()) {
to.setDisplay(adaptIn(from.getDisplay()));
}
if (from.isSetExternalHostProvider()) {
to.setExternalHostProvider(adaptIn(from.getExternalHostProvider()));
}
if (from.isSetExternalStatus() && from.getExternalStatus().isSetState()) {
to.setExternalStatus(ExternalStatus.fromValue(from.getExternalStatus().getState()));
}
if (from.isSetHardwareInformation()) {
to.setHardwareInformation(adaptIn(from.getHardwareInformation()));
}
if (from.isSetHooks()) {
to.setHooks(new Hooks());
to.getHooks().getHooks().addAll(adaptIn(from.getHooks().getHooks()));
}
if (from.isSetHostedEngine()) {
to.setHostedEngine(adaptIn(from.getHostedEngine()));
}
if (from.isSetId()) {
to.setId(from.getId());
}
if (from.isSetHref()) {
to.setHref(from.getHref());
}
if (from.isSetIscsi()) {
to.setIscsi(adaptIn(from.getIscsi()));
}
if (from.isSetKatelloErrata()) {
to.setKatelloErrata(new KatelloErrata());
to.getKatelloErrata().getKatelloErrata().addAll(adaptIn(from.getKatelloErrata().getKatelloErrata()));
}
if (from.isSetKdumpStatus()) {
to.setKdumpStatus(KdumpStatus.fromValue(from.getKdumpStatus()));
}
if (from.isSetKsm()) {
to.setKsm(adaptIn(from.getKsm()));
}
if (from.isSetLibvirtVersion()) {
to.setLibvirtVersion(adaptIn(from.getLibvirtVersion()));
}
if (from.isSetMaxSchedulingMemory()) {
to.setMaxSchedulingMemory(from.getMaxSchedulingMemory());
}
if (from.isSetMemory()) {
to.setMemory(from.getMemory());
}
if (from.isSetName()) {
to.setName(from.getName());
}
if (from.isSetNumaSupported()) {
to.setNumaSupported(from.isNumaSupported());
}
if (from.isSetOs()) {
to.setOs(adaptIn(from.getOs()));
}
if (from.isSetOverrideIptables()) {
to.setOverrideIptables(from.isOverrideIptables());
}
if (from.isSetPort()) {
to.setPort(from.getPort());
}
if (from.isSetPowerManagement()) {
to.setPowerManagement(adaptIn(from.getPowerManagement()));
}
if (from.isSetRootPassword()) {
to.setRootPassword(from.getRootPassword());
}
if (from.isSetSelinux()) {
to.setSeLinux(adaptIn(from.getSelinux()));
}
// This is for the old and deprecated "storage_manager" element:
V3StorageManager storageManager = from.getStorageManager();
if (storageManager != null) {
Spm spm = new Spm();
Boolean value = storageManager.isValue();
if (value != null) {
spm.setStatus(value ? SpmStatus.SPM : SpmStatus.NONE);
}
Integer priority = spm.getPriority();
if (storageManager.getPriority() != null) {
spm.setPriority(priority);
}
to.setSpm(spm);
}
// element to override the old element when both are provided):
if (from.isSetSpm()) {
to.setSpm(adaptIn(from.getSpm()));
}
if (from.isSetSsh()) {
to.setSsh(adaptIn(from.getSsh()));
}
if (from.isSetStatistics()) {
to.setStatistics(new Statistics());
to.getStatistics().getStatistics().addAll(adaptIn(from.getStatistics().getStatistics()));
}
V3Status status = from.getStatus();
if (status != null) {
if (status.isSetState()) {
to.setStatus(HostStatus.fromValue(status.getState()));
}
if (status.isSetDetail()) {
to.setStatusDetail(status.getDetail());
}
}
if (from.isSetStorageConnectionExtensions()) {
to.setStorageConnectionExtensions(new StorageConnectionExtensions());
to.getStorageConnectionExtensions().getStorageConnectionExtensions().addAll(adaptIn(from.getStorageConnectionExtensions().getStorageConnectionExtension()));
}
if (from.isSetSummary()) {
to.setSummary(adaptIn(from.getSummary()));
}
if (from.isSetTransparentHugepages()) {
to.setTransparentHugepages(adaptIn(from.getTransparentHugepages()));
}
if (from.isSetType()) {
// In version 3 of the API the string for the RHEV_H value was "rhev-h", with a dash instead of an
// underscore, and we need to accept that for backwards compatibility:
String fromType = from.getType();
HostType toType = fromType.equalsIgnoreCase("rhev-h") ? HostType.RHEV_H : HostType.fromValue(fromType);
to.setType(toType);
}
if (from.isSetUpdateAvailable()) {
to.setUpdateAvailable(from.isUpdateAvailable());
}
if (from.isSetVersion()) {
to.setVersion(adaptIn(from.getVersion()));
}
return to;
}
use of org.ovirt.engine.api.v3.types.V3Host in project ovirt-engine by oVirt.
the class V3HostOutAdapter method adapt.
@Override
public V3Host adapt(Host from) {
V3Host to = new V3Host();
// Remove the links for "rels" that are new in version 4 of the API:
if (from.isSetLinks()) {
List<Link> links = from.getLinks().stream().filter(link -> !RELS_TO_REMOVE.contains(link.getRel())).collect(toList());
to.getLinks().addAll(adaptOut(links));
}
if (from.isSetActions()) {
to.setActions(adaptOut(from.getActions()));
}
if (from.isSetAddress()) {
to.setAddress(from.getAddress());
}
if (from.isSetAutoNumaStatus()) {
to.setAutoNumaStatus(from.getAutoNumaStatus().value());
}
if (from.isSetCertificate()) {
to.setCertificate(adaptOut(from.getCertificate()));
}
if (from.isSetCluster()) {
to.setCluster(adaptOut(from.getCluster()));
}
if (from.isSetComment()) {
to.setComment(from.getComment());
}
if (from.isSetCpu()) {
to.setCpu(adaptOut(from.getCpu()));
}
if (from.isSetDescription()) {
to.setDescription(from.getDescription());
}
if (from.isSetDevicePassthrough()) {
to.setDevicePassthrough(adaptOut(from.getDevicePassthrough()));
}
if (from.isSetDisplay()) {
to.setDisplay(adaptOut(from.getDisplay()));
}
if (from.isSetExternalHostProvider()) {
to.setExternalHostProvider(adaptOut(from.getExternalHostProvider()));
}
if (from.isSetExternalStatus()) {
V3Status status = new V3Status();
status.setState(from.getExternalStatus().value());
to.setExternalStatus(status);
}
if (from.isSetHardwareInformation()) {
to.setHardwareInformation(adaptOut(from.getHardwareInformation()));
}
if (from.isSetHooks()) {
to.setHooks(new V3Hooks());
to.getHooks().getHooks().addAll(adaptOut(from.getHooks().getHooks()));
}
if (from.isSetHostedEngine()) {
to.setHostedEngine(adaptOut(from.getHostedEngine()));
}
if (from.isSetId()) {
to.setId(from.getId());
}
if (from.isSetHref()) {
to.setHref(from.getHref());
}
if (from.isSetIscsi()) {
to.setIscsi(adaptOut(from.getIscsi()));
}
if (from.isSetKatelloErrata()) {
to.setKatelloErrata(new V3KatelloErrata());
to.getKatelloErrata().getKatelloErrata().addAll(adaptOut(from.getKatelloErrata().getKatelloErrata()));
}
if (from.isSetKdumpStatus()) {
to.setKdumpStatus(from.getKdumpStatus().value());
}
if (from.isSetKsm()) {
to.setKsm(adaptOut(from.getKsm()));
}
if (from.isSetLibvirtVersion()) {
to.setLibvirtVersion(adaptOut(from.getLibvirtVersion()));
}
// All hosts support live snapshots now
to.setLiveSnapshotSupport(true);
if (from.isSetMaxSchedulingMemory()) {
to.setMaxSchedulingMemory(from.getMaxSchedulingMemory());
}
if (from.isSetMemory()) {
to.setMemory(from.getMemory());
}
if (from.isSetName()) {
to.setName(from.getName());
}
if (from.isSetNumaSupported()) {
to.setNumaSupported(from.isNumaSupported());
}
if (from.isSetOs()) {
to.setOs(adaptOut(from.getOs()));
}
if (from.isSetOverrideIptables()) {
to.setOverrideIptables(from.isOverrideIptables());
}
if (from.isSetPort()) {
to.setPort(from.getPort());
}
if (from.isSetPowerManagement()) {
to.setPowerManagement(adaptOut(from.getPowerManagement()));
}
if (from.isSetProtocol()) {
to.setProtocol(from.getProtocol().value());
}
if (from.isSetRootPassword()) {
to.setRootPassword(from.getRootPassword());
}
if (from.isSetSeLinux()) {
to.setSelinux(adaptOut(from.getSeLinux()));
}
Spm spm = from.getSpm();
if (spm != null) {
// This is for the old and deprecated "storage_manager" element:
V3StorageManager storageManager = new V3StorageManager();
SpmStatus status = spm.getStatus();
if (status != null) {
storageManager.setValue(status == SpmStatus.SPM);
}
if (spm.isSetPriority()) {
storageManager.setPriority(spm.getPriority());
}
to.setStorageManager(storageManager);
// This is for the new and recommended "spm" element (the order here isn't relevant, as we are populating
// both output elements):
to.setSpm(adaptOut(spm));
}
if (from.isSetSsh()) {
to.setSsh(adaptOut(from.getSsh()));
}
if (from.isSetStatistics()) {
to.setStatistics(new V3Statistics());
to.getStatistics().getStatistics().addAll(adaptOut(from.getStatistics().getStatistics()));
}
if (from.isSetStatus()) {
V3Status status = to.getStatus();
if (status == null) {
status = new V3Status();
to.setStatus(status);
}
status.setState(from.getStatus().value());
}
if (from.isSetStatusDetail()) {
V3Status status = to.getStatus();
if (status == null) {
status = new V3Status();
to.setStatus(status);
}
status.setDetail(from.getStatusDetail());
}
if (from.isSetStorageConnectionExtensions()) {
to.setStorageConnectionExtensions(new V3StorageConnectionExtensions());
to.getStorageConnectionExtensions().getStorageConnectionExtension().addAll(adaptOut(from.getStorageConnectionExtensions().getStorageConnectionExtensions()));
}
if (from.isSetSummary()) {
to.setSummary(adaptOut(from.getSummary()));
}
if (from.isSetTransparentHugepages()) {
to.setTransparentHugepages(adaptOut(from.getTransparentHugepages()));
}
if (from.isSetType()) {
// In version 3 of the API the string for the RHEV_H value was "rhev-h", with a dash instead of an
// underscore, and we need to preserve that for backwards compatibility:
HostType fromType = from.getType();
String toType = fromType == HostType.RHEV_H ? "rhev-h" : fromType.value();
to.setType(toType);
}
if (from.isSetUpdateAvailable()) {
to.setUpdateAvailable(from.isUpdateAvailable());
}
if (from.isSetVersion()) {
to.setVersion(adaptOut(from.getVersion()));
}
return to;
}
use of org.ovirt.engine.api.v3.types.V3Host in project ovirt-engine by oVirt.
the class V3VmPlacementPolicyOutAdapter method adapt.
@Override
public V3VmPlacementPolicy adapt(VmPlacementPolicy from) {
V3VmPlacementPolicy to = new V3VmPlacementPolicy();
if (from.isSetAffinity()) {
to.setAffinity(from.getAffinity().value());
}
if (from.isSetHosts()) {
to.setHosts(new V3Hosts());
to.getHosts().getHosts().addAll(adaptOut(from.getHosts().getHosts()));
// V3 allowed specifying only one host, using the "host" element instead of "hosts":
List<Host> hosts = from.getHosts().getHosts();
if (hosts.size() == 1) {
V3Host host = adaptOut(hosts.get(0));
to.setHost(host);
}
}
return to;
}
use of org.ovirt.engine.api.v3.types.V3Host in project ovirt-engine by oVirt.
the class V3HostServer method get.
@GET
public V3Host get(@Context HttpHeaders headers, @Context UriInfo ui) {
// V3 supported a "force" matrix parameter, that is equivalent to calling the "refresh" action:
boolean force = ParametersHelper.getBooleanParameter(headers, ui, "force", true, false);
if (force) {
try {
getDelegate().refresh(new Action());
} catch (WebApplicationException exception) {
throw adaptException(exception);
}
}
V3Host host = adaptGet(getDelegate()::get);
// In V3 hosts used to have the statistics inline by default:
V3HostHelper.addStatistics(host);
return host;
}
use of org.ovirt.engine.api.v3.types.V3Host in project ovirt-engine by oVirt.
the class V3StorageDomainServer method remove.
@DELETE
@Consumes({ "application/xml", "application/json" })
public Response remove(V3StorageDomain storageDomain) {
// to check if they are present in the body of the request and convert them into request parameters.
if (storageDomain != null) {
Map<String, String> parameters = CurrentManager.get().getParameters();
if (storageDomain.isSetFormat()) {
parameters.put("format", storageDomain.isFormat().toString());
}
if (storageDomain.isSetDestroy()) {
parameters.put("destroy", storageDomain.isDestroy().toString());
}
V3Host host = storageDomain.getHost();
if (host != null) {
if (host.isSetId()) {
parameters.put("host", host.getId());
} else if (host.isSetName()) {
parameters.put("host", host.getName());
}
}
}
return adaptRemove(getDelegate()::remove);
}
Aggregations