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;
}
Aggregations