use of org.ovirt.engine.api.model.ExternalComputeResource in project ovirt-engine by oVirt.
the class BackendExternalComputeResourceResource method get.
@Override
public ExternalComputeResource get() {
// Convert the resource identifier to the host group name:
String name = hex2string(id);
// The backend query that retrieves the list of hosts groups needs a complete provider instance, the id isn't
// enough:
Provider provider = BackendExternalProviderHelper.getProvider(this, providerId);
// The backend doesn't have a way to retrieve a host by ide, so we have to iterate them:
ProviderQueryParameters parameters = new ProviderQueryParameters();
parameters.setProvider(provider);
QueryReturnValue result = runQuery(QueryType.GetComputeResourceFromExternalProvider, parameters);
List<org.ovirt.engine.core.common.businessentities.ExternalComputeResource> entities = result.getReturnValue();
if (entities != null) {
for (org.ovirt.engine.core.common.businessentities.ExternalComputeResource entity : entities) {
if (name.equals(entity.getName())) {
return addLinks(populate(map(entity), entity));
}
}
}
// No luck:
return notFound();
}
use of org.ovirt.engine.api.model.ExternalComputeResource in project ovirt-engine by oVirt.
the class ExternalComputeResourceMapper method map.
@Mapping(from = org.ovirt.engine.core.common.businessentities.ExternalComputeResource.class, to = ExternalComputeResource.class)
public static ExternalComputeResource map(org.ovirt.engine.core.common.businessentities.ExternalComputeResource entity, ExternalComputeResource template) {
ExternalComputeResource model = template != null ? template : new ExternalComputeResource();
String name = entity.getName();
if (name != null) {
model.setId(string2hex(name));
model.setName(name);
}
if (entity.getProvider() != null) {
model.setProvider(entity.getProvider());
}
if (entity.getUser() != null) {
model.setUser(entity.getUser());
}
if (entity.getUrl() != null) {
model.setUrl(entity.getUrl());
}
return model;
}
Aggregations