Search in sources :

Example 1 with ExternalComputeResource

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();
}
Also used : ExternalComputeResource(org.ovirt.engine.api.model.ExternalComputeResource) ProviderQueryParameters(org.ovirt.engine.core.common.queries.ProviderQueryParameters) ExternalHostProvider(org.ovirt.engine.api.model.ExternalHostProvider) Provider(org.ovirt.engine.core.common.businessentities.Provider) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue)

Example 2 with ExternalComputeResource

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;
}
Also used : ExternalComputeResource(org.ovirt.engine.api.model.ExternalComputeResource) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Aggregations

ExternalComputeResource (org.ovirt.engine.api.model.ExternalComputeResource)2 ExternalHostProvider (org.ovirt.engine.api.model.ExternalHostProvider)1 Mapping (org.ovirt.engine.api.restapi.types.Mapping)1 Provider (org.ovirt.engine.core.common.businessentities.Provider)1 ProviderQueryParameters (org.ovirt.engine.core.common.queries.ProviderQueryParameters)1 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)1