Search in sources :

Example 1 with DataCenter

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

the class AbstractBackendCpuProfilesResource method handleQosDataCenterLinks.

/**
 * used to set qos's href (requires dc id).
 */
private void handleQosDataCenterLinks(Map<Guid, Qos> qosMap) {
    if (!qosMap.isEmpty()) {
        List<CpuQos> list = getBackendCollection(CpuQos.class, QueryType.GetAllQosByType, new QosQueryParameterBase(null, QosType.CPU));
        for (CpuQos cpuQos : list) {
            Qos qos = qosMap.get(cpuQos.getId());
            if (qos != null) {
                qos.setDataCenter(new DataCenter());
                qos.getDataCenter().setId(cpuQos.getStoragePoolId().toString());
            }
        }
    }
}
Also used : QosQueryParameterBase(org.ovirt.engine.core.common.queries.QosQueryParameterBase) DataCenter(org.ovirt.engine.api.model.DataCenter) Qos(org.ovirt.engine.api.model.Qos) CpuQos(org.ovirt.engine.core.common.businessentities.qos.CpuQos) CpuQos(org.ovirt.engine.core.common.businessentities.qos.CpuQos)

Example 2 with DataCenter

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

the class AbstractBackendDiskProfileResource method addLinks.

@Override
protected DiskProfile addLinks(DiskProfile model, Class<? extends BaseResource> suggestedParent, String... subCollectionMembersToExclude) {
    if (model.isSetQos() && model.getQos().isSetId()) {
        QosBase qos = getEntity(QosBase.class, QueryType.GetQosById, new IdQueryParameters(asGuid(model.getQos().getId())), "qos");
        model.getQos().setDataCenter(new DataCenter());
        model.getQos().getDataCenter().setId(qos.getStoragePoolId().toString());
    }
    return super.addLinks(model, suggestedParent, subCollectionMembersToExclude);
}
Also used : QosBase(org.ovirt.engine.core.common.businessentities.qos.QosBase) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) DataCenter(org.ovirt.engine.api.model.DataCenter)

Example 3 with DataCenter

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

the class AbstractBackendDiskProfilesResource method handleQosDataCenterLinks.

/**
 * used to set qos's href (requires dc id).
 */
private void handleQosDataCenterLinks(Map<Guid, Qos> qosMap) {
    if (!qosMap.isEmpty()) {
        List<StorageQos> list = getBackendCollection(StorageQos.class, QueryType.GetAllQosByType, new QosQueryParameterBase(null, QosType.STORAGE));
        for (StorageQos storageQos : list) {
            Qos qos = qosMap.get(storageQos.getId());
            if (qos != null) {
                qos.setDataCenter(new DataCenter());
                qos.getDataCenter().setId(storageQos.getStoragePoolId().toString());
            }
        }
    }
}
Also used : StorageQos(org.ovirt.engine.core.common.businessentities.qos.StorageQos) QosQueryParameterBase(org.ovirt.engine.core.common.queries.QosQueryParameterBase) DataCenter(org.ovirt.engine.api.model.DataCenter) Qos(org.ovirt.engine.api.model.Qos) StorageQos(org.ovirt.engine.core.common.businessentities.qos.StorageQos)

Example 4 with DataCenter

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

the class AbstractBackendVnicProfilesResource method handleQosDataCenterLinks.

/**
 * used to set qos's href (requires dc id).
 */
private void handleQosDataCenterLinks(Map<Guid, Qos> qosMap) {
    if (!qosMap.isEmpty()) {
        List<NetworkQoS> list = getBackendCollection(NetworkQoS.class, QueryType.GetAllQosByType, new QosQueryParameterBase(null, QosType.NETWORK));
        for (NetworkQoS networkQoS : list) {
            Qos qos = qosMap.get(networkQoS.getId());
            if (qos != null) {
                qos.setDataCenter(new DataCenter());
                qos.getDataCenter().setId(networkQoS.getStoragePoolId().toString());
            }
        }
    }
}
Also used : QosQueryParameterBase(org.ovirt.engine.core.common.queries.QosQueryParameterBase) DataCenter(org.ovirt.engine.api.model.DataCenter) Qos(org.ovirt.engine.api.model.Qos) NetworkQoS(org.ovirt.engine.core.common.businessentities.network.NetworkQoS)

Example 5 with DataCenter

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

the class StorageDomainHelper method addAttachedDataCenterReferences.

/**
 * Adds to the given Storage Domain the references to the Data Centers it is attached to.
 *
 * @param resource the resource that will be used to run the required queries
 * @param model the model of the Storage Domain where the references will be added
 */
public static void addAttachedDataCenterReferences(BackendResource resource, StorageDomain model) {
    // Note that this implementation is far from efficient, as we are retrieving all the content of the Storage
    // Domains and immediately discarding everything but the identifiers of the Data Centers. It would be better to
    // have a query that returns only the identifiers.
    Guid id = Guid.createGuidFromString(model.getId());
    QueryReturnValue result = resource.runQuery(QueryType.GetStorageDomainListById, new IdQueryParameters(id));
    if (result != null && result.getSucceeded()) {
        List<org.ovirt.engine.core.common.businessentities.StorageDomain> storageDomains = result.getReturnValue();
        if (CollectionUtils.isNotEmpty(storageDomains)) {
            DataCenters dataCenters = new DataCenters();
            for (org.ovirt.engine.core.common.businessentities.StorageDomain storageDomain : storageDomains) {
                DataCenter dataCenter = new DataCenter();
                dataCenter.setId(storageDomain.getStoragePoolId().toString());
                dataCenters.getDataCenters().add(dataCenter);
            }
            model.setDataCenters(dataCenters);
        }
    }
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) StorageDomain(org.ovirt.engine.api.model.StorageDomain) DataCenters(org.ovirt.engine.api.model.DataCenters) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) DataCenter(org.ovirt.engine.api.model.DataCenter)

Aggregations

DataCenter (org.ovirt.engine.api.model.DataCenter)42 Test (org.junit.Test)10 WebApplicationException (javax.ws.rs.WebApplicationException)6 Network (org.ovirt.engine.api.model.Network)6 StorageDomain (org.ovirt.engine.api.model.StorageDomain)5 Response (javax.ws.rs.core.Response)4 Qos (org.ovirt.engine.api.model.Qos)4 Quota (org.ovirt.engine.api.model.Quota)4 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)4 Guid (org.ovirt.engine.core.compat.Guid)4 Cluster (org.ovirt.engine.api.model.Cluster)3 Permission (org.ovirt.engine.api.model.Permission)3 Role (org.ovirt.engine.api.model.Role)3 AddNetworkStoragePoolParameters (org.ovirt.engine.core.common.action.AddNetworkStoragePoolParameters)3 QosBase (org.ovirt.engine.core.common.businessentities.qos.QosBase)3 QosQueryParameterBase (org.ovirt.engine.core.common.queries.QosQueryParameterBase)3 Cpu (org.ovirt.engine.api.model.Cpu)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1