use of org.ovirt.engine.core.common.queries.NameQueryParameters in project ovirt-engine by oVirt.
the class BackendExternalVmImportsResource method getClusterId.
private Guid getClusterId(ExternalVmImport vmImport) {
if (vmImport.getCluster().isSetId()) {
return asGuid(vmImport.getCluster().getId());
} else /* if (vmImport.getCluster().isSetName()) */
{
String clusterName = vmImport.getCluster().getName();
Cluster cluster = getEntity(Cluster.class, QueryType.GetClusterByName, new NameQueryParameters(clusterName), clusterName, true);
return cluster.getId();
}
}
use of org.ovirt.engine.core.common.queries.NameQueryParameters in project ovirt-engine by oVirt.
the class BackendOpenStackNetworkResource method getDataCenterIdByName.
private Guid getDataCenterIdByName(String dataCenterName) {
NameQueryParameters parameters = new NameQueryParameters(dataCenterName);
QueryReturnValue result = runQuery(QueryType.GetStoragePoolByDatacenterName, parameters);
checkResultAndThrowExceptionIfFailed(result);
List<StoragePool> dataCenters = result.getReturnValue();
if (dataCenters.isEmpty()) {
// This will always throw a WebApplicationException
notFound();
}
return dataCenters.get(0).getId();
}
use of org.ovirt.engine.core.common.queries.NameQueryParameters 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;
}
use of org.ovirt.engine.core.common.queries.NameQueryParameters in project ovirt-engine by oVirt.
the class AsyncDataProvider method isVmNameUnique.
public void isVmNameUnique(AsyncQuery<Boolean> aQuery, String name, Guid datacenterId) {
aQuery.converterCallback = source -> source != null && !(Boolean) source;
NameQueryParameters params = new NameQueryParameters(name);
params.setDatacenterId(datacenterId);
Frontend.getInstance().runQuery(QueryType.IsVmWithSameNameExist, params, aQuery);
}
use of org.ovirt.engine.core.common.queries.NameQueryParameters in project ovirt-engine by oVirt.
the class VmHandler method isVmWithSameNameExistStatic.
/**
* Checks if VM with same name exists in the given DC. If no DC provided, check all VMs in the database.
*/
public boolean isVmWithSameNameExistStatic(String vmName, Guid storagePoolId) {
NameQueryParameters params = new NameQueryParameters(vmName);
params.setDatacenterId(storagePoolId);
QueryReturnValue result = backend.runInternalQuery(QueryType.IsVmWithSameNameExist, params);
return (Boolean) result.getReturnValue();
}
Aggregations