Search in sources :

Example 1 with ExternalDiscoveredHost

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

the class ExternalDiscoveredHostMapper method map.

@Mapping(from = org.ovirt.engine.core.common.businessentities.ExternalDiscoveredHost.class, to = ExternalDiscoveredHost.class)
public static ExternalDiscoveredHost map(org.ovirt.engine.core.common.businessentities.ExternalDiscoveredHost entity, ExternalDiscoveredHost template) {
    ExternalDiscoveredHost model = template != null ? template : new ExternalDiscoveredHost();
    String name = entity.getName();
    if (name != null) {
        model.setId(string2hex(name));
        model.setName(name);
    }
    if (entity.getMac() != null) {
        model.setMac(entity.getMac());
    }
    if (entity.getIp() != null) {
        model.setIp(entity.getIp());
    }
    if (entity.getSubnetName() != null) {
        model.setSubnetName(entity.getSubnetName());
    }
    if (entity.getLastReport() != null) {
        model.setLastReport(entity.getLastReport());
    }
    return model;
}
Also used : ExternalDiscoveredHost(org.ovirt.engine.api.model.ExternalDiscoveredHost) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Example 2 with ExternalDiscoveredHost

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

the class BackendExternalDiscoveredHostResource method get.

@Override
public ExternalDiscoveredHost get() {
    // Convert the resource identifier to the host group name:
    String name = hex2string(id);
    // The backend doesn't have a way to retrieve a host by ide, so we have to iterate them:
    Provider provider = BackendExternalProviderHelper.getProvider(this, providerId);
    ProviderQueryParameters parameters = new ProviderQueryParameters();
    parameters.setProvider(provider);
    QueryReturnValue result = runQuery(QueryType.GetDiscoveredHostListFromExternalProvider, parameters);
    List<org.ovirt.engine.core.common.businessentities.ExternalDiscoveredHost> entities = result.getReturnValue();
    if (entities != null) {
        for (org.ovirt.engine.core.common.businessentities.ExternalDiscoveredHost entity : entities) {
            if (name.equals(entity.getName())) {
                return addLinks(populate(map(entity), entity));
            }
        }
    }
    // No luck:
    return notFound();
}
Also used : ExternalDiscoveredHost(org.ovirt.engine.api.model.ExternalDiscoveredHost) 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)

Aggregations

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