Search in sources :

Example 1 with MalformedIdException

use of org.ovirt.engine.api.restapi.utils.MalformedIdException in project ovirt-engine by oVirt.

the class BackendDataCenterResource method getStoragePool.

/**
 * Get the storage pool (i.e. datacenter entity) associated with the given
 * cluster.
 */
@SuppressWarnings("unchecked")
public static StoragePool getStoragePool(DataCenter dataCenter, AbstractBackendResource parent) {
    StoragePool pool = null;
    if (dataCenter.isSetId()) {
        String id = dataCenter.getId();
        Guid guid;
        try {
            // can't use asGuid() because the method is static.
            guid = new Guid(id);
        } catch (IllegalArgumentException e) {
            throw new MalformedIdException(e);
        }
        pool = parent.getEntity(StoragePool.class, QueryType.GetStoragePoolById, new IdQueryParameters(guid), "Datacenter: id=" + id);
    } else {
        String clusterName = dataCenter.getName();
        pool = parent.getEntity(StoragePool.class, QueryType.GetStoragePoolByDatacenterName, new NameQueryParameters(clusterName), "Datacenter: name=" + clusterName);
        dataCenter.setId(pool.getId().toString());
    }
    return pool;
}
Also used : MalformedIdException(org.ovirt.engine.api.restapi.utils.MalformedIdException) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Guid(org.ovirt.engine.core.compat.Guid) NameQueryParameters(org.ovirt.engine.core.common.queries.NameQueryParameters)

Aggregations

MalformedIdException (org.ovirt.engine.api.restapi.utils.MalformedIdException)1 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1 NameQueryParameters (org.ovirt.engine.core.common.queries.NameQueryParameters)1 Guid (org.ovirt.engine.core.compat.Guid)1