Search in sources :

Example 1 with ExternalHostGroup

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

the class BackendExternalHostGroupResource method get.

@Override
public ExternalHostGroup 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.GetHostGroupsFromExternalProvider, parameters);
    List<org.ovirt.engine.core.common.businessentities.ExternalHostGroup> entities = result.getReturnValue();
    if (entities != null) {
        for (org.ovirt.engine.core.common.businessentities.ExternalHostGroup entity : entities) {
            if (name.equals(entity.getName())) {
                return addLinks(populate(map(entity), entity));
            }
        }
    }
    // No luck:
    return notFound();
}
Also used : ProviderQueryParameters(org.ovirt.engine.core.common.queries.ProviderQueryParameters) ExternalHostGroup(org.ovirt.engine.api.model.ExternalHostGroup) 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 ExternalHostGroup

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

the class ExternalHostGroupMapper method map.

@Mapping(from = org.ovirt.engine.core.common.businessentities.ExternalHostGroup.class, to = ExternalHostGroup.class)
public static ExternalHostGroup map(org.ovirt.engine.core.common.businessentities.ExternalHostGroup entity, ExternalHostGroup template) {
    ExternalHostGroup model = template != null ? template : new ExternalHostGroup();
    String name = entity.getName();
    if (name != null) {
        model.setId(string2hex(name));
        model.setName(name);
    }
    if (entity.getArchitectureName() != null) {
        model.setArchitectureName(entity.getArchitectureName());
    }
    if (entity.getOperatingsystemName() != null) {
        model.setOperatingSystemName(entity.getOperatingsystemName());
    }
    if (entity.getDomainName() != null) {
        model.setDomainName(entity.getDomainName());
    }
    if (entity.getSubnetName() != null) {
        model.setSubnetName(entity.getSubnetName());
    }
    return model;
}
Also used : ExternalHostGroup(org.ovirt.engine.api.model.ExternalHostGroup) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Aggregations

ExternalHostGroup (org.ovirt.engine.api.model.ExternalHostGroup)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