Search in sources :

Example 1 with DataCenters

use of org.ovirt.engine.api.model.DataCenters 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)

Example 2 with DataCenters

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

the class V3StorageDomainInAdapter method adapt.

@Override
public StorageDomain adapt(V3StorageDomain from) {
    StorageDomain to = new StorageDomain();
    if (from.isSetLinks()) {
        to.getLinks().addAll(adaptIn(from.getLinks()));
    }
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetAvailable()) {
        to.setAvailable(from.getAvailable());
    }
    if (from.isSetComment()) {
        to.setComment(from.getComment());
    }
    if (from.isSetCommitted()) {
        to.setCommitted(from.getCommitted());
    }
    if (from.isSetCriticalSpaceActionBlocker()) {
        to.setCriticalSpaceActionBlocker(from.getCriticalSpaceActionBlocker());
    }
    if (from.isSetDataCenter()) {
        to.setDataCenter(adaptIn(from.getDataCenter()));
    }
    if (from.isSetDataCenters()) {
        to.setDataCenters(new DataCenters());
        to.getDataCenters().getDataCenters().addAll(adaptIn(from.getDataCenters().getDataCenters()));
    }
    if (from.isSetDescription()) {
        to.setDescription(from.getDescription());
    }
    if (from.isSetExternalStatus() && from.getExternalStatus().isSetState()) {
        to.setExternalStatus(ExternalStatus.fromValue(from.getExternalStatus().getState()));
    }
    if (from.isSetHost()) {
        to.setHost(adaptIn(from.getHost()));
    }
    if (from.isSetId()) {
        to.setId(from.getId());
    }
    if (from.isSetHref()) {
        to.setHref(from.getHref());
    }
    if (from.isSetImport()) {
        to.setImport(from.isImport());
    }
    if (from.isSetMaster()) {
        to.setMaster(from.isMaster());
    }
    if (from.isSetName()) {
        to.setName(from.getName());
    }
    if (from.isSetStatus() && from.getStatus().isSetState()) {
        to.setStatus(StorageDomainStatus.fromValue(from.getStatus().getState()));
    }
    if (from.isSetStorage()) {
        to.setStorage(adaptIn(from.getStorage()));
    }
    if (from.isSetStorageFormat()) {
        to.setStorageFormat(StorageFormat.fromValue(from.getStorageFormat()));
    }
    if (from.isSetType()) {
        to.setType(StorageDomainType.fromValue(from.getType()));
    }
    if (from.isSetUsed()) {
        to.setUsed(from.getUsed());
    }
    if (from.isSetWarningLowSpaceIndicator()) {
        to.setWarningLowSpaceIndicator(from.getWarningLowSpaceIndicator());
    }
    if (from.isSetWipeAfterDelete()) {
        to.setWipeAfterDelete(from.isWipeAfterDelete());
    }
    return to;
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) V3StorageDomain(org.ovirt.engine.api.v3.types.V3StorageDomain) DataCenters(org.ovirt.engine.api.model.DataCenters)

Example 3 with DataCenters

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

the class V3DataCentersInAdapter method adapt.

@Override
public DataCenters adapt(V3DataCenters from) {
    DataCenters to = new DataCenters();
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetActive()) {
        to.setActive(from.getActive());
    }
    if (from.isSetSize()) {
        to.setSize(from.getSize());
    }
    if (from.isSetTotal()) {
        to.setTotal(from.getTotal());
    }
    to.getDataCenters().addAll(adaptIn(from.getDataCenters()));
    return to;
}
Also used : DataCenters(org.ovirt.engine.api.model.DataCenters) V3DataCenters(org.ovirt.engine.api.v3.types.V3DataCenters)

Aggregations

DataCenters (org.ovirt.engine.api.model.DataCenters)3 StorageDomain (org.ovirt.engine.api.model.StorageDomain)2 DataCenter (org.ovirt.engine.api.model.DataCenter)1 V3DataCenters (org.ovirt.engine.api.v3.types.V3DataCenters)1 V3StorageDomain (org.ovirt.engine.api.v3.types.V3StorageDomain)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)1 Guid (org.ovirt.engine.core.compat.Guid)1