Search in sources :

Example 1 with GlusterVolume

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

the class BackendGlusterBricksResource method addParents.

@Override
protected GlusterBrick addParents(GlusterBrick glusterBrick) {
    GlusterVolume volume = new GlusterVolume();
    parent.addParents(volume);
    glusterBrick.setGlusterVolume(volume);
    return glusterBrick;
}
Also used : GlusterVolume(org.ovirt.engine.api.model.GlusterVolume)

Example 2 with GlusterVolume

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

the class BackendGlusterVolumesResource method add.

@Override
public Response add(GlusterVolume volume) {
    validateParameters(volume, "name", "volumeType", "bricks");
    GlusterVolumeEntity volumeEntity = getMapper(GlusterVolume.class, GlusterVolumeEntity.class).map(volume, null);
    volumeEntity.setClusterId(asGuid(parent.get().getId()));
    mapBricks(volume, volumeEntity);
    return performCreate(ActionType.CreateGlusterVolume, new CreateGlusterVolumeParameters(volumeEntity, isForce()), new QueryIdResolver<Guid>(QueryType.GetGlusterVolumeById, IdQueryParameters.class), true);
}
Also used : GlusterVolume(org.ovirt.engine.api.model.GlusterVolume) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) CreateGlusterVolumeParameters(org.ovirt.engine.core.common.action.gluster.CreateGlusterVolumeParameters) Guid(org.ovirt.engine.core.compat.Guid)

Example 3 with GlusterVolume

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

the class V3GlusterVolumeInAdapter method adapt.

@Override
public GlusterVolume adapt(V3GlusterVolume from) {
    GlusterVolume to = new GlusterVolume();
    if (from.isSetLinks()) {
        to.getLinks().addAll(adaptIn(from.getLinks()));
    }
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetBricks()) {
        to.setBricks(new GlusterBricks());
        to.getBricks().getGlusterBricks().addAll(adaptIn(from.getBricks().getGlusterBricks()));
    }
    if (from.isSetCluster()) {
        to.setCluster(adaptIn(from.getCluster()));
    }
    if (from.isSetComment()) {
        to.setComment(from.getComment());
    }
    if (from.isSetDescription()) {
        to.setDescription(from.getDescription());
    }
    if (from.isSetDisperseCount()) {
        to.setDisperseCount(from.getDisperseCount());
    }
    if (from.isSetId()) {
        to.setId(from.getId());
    }
    if (from.isSetHref()) {
        to.setHref(from.getHref());
    }
    if (from.isSetName()) {
        to.setName(from.getName());
    }
    if (from.isSetOptions()) {
        to.setOptions(new Options());
        to.getOptions().getOptions().addAll(adaptIn(from.getOptions().getOptions()));
    }
    if (from.isSetRedundancyCount()) {
        to.setRedundancyCount(from.getRedundancyCount());
    }
    if (from.isSetReplicaCount()) {
        to.setReplicaCount(from.getReplicaCount());
    }
    if (from.isSetStatus() && from.getStatus().isSetState()) {
        to.setStatus(GlusterVolumeStatus.fromValue(from.getStatus().getState()));
    }
    if (from.isSetStripeCount()) {
        to.setStripeCount(from.getStripeCount());
    }
    if (from.isSetTransportTypes()) {
        to.setTransportTypes(new GlusterVolume.TransportTypesList());
        to.getTransportTypes().getTransportTypes().addAll(adaptTransportTypes(from));
    }
    if (from.isSetVolumeType()) {
        to.setVolumeType(GlusterVolumeType.fromValue(from.getVolumeType()));
    }
    return to;
}
Also used : Options(org.ovirt.engine.api.model.Options) V3GlusterVolume(org.ovirt.engine.api.v3.types.V3GlusterVolume) GlusterVolume(org.ovirt.engine.api.model.GlusterVolume) GlusterBricks(org.ovirt.engine.api.model.GlusterBricks)

Example 4 with GlusterVolume

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

the class GlusterBrickMapper method map.

@Mapping(from = GlusterBrickEntity.class, to = GlusterBrick.class)
public static GlusterBrick map(GlusterBrickEntity fromBrick, GlusterBrick toBrick) {
    GlusterBrick brick = (toBrick == null) ? new GlusterBrick() : toBrick;
    if (fromBrick.getId() != null) {
        brick.setId(fromBrick.getId().toString());
    }
    if (fromBrick.getServerId() != null) {
        brick.setServerId(fromBrick.getServerId().toString());
    }
    if (StringUtils.isNotEmpty(fromBrick.getQualifiedName())) {
        brick.setName(fromBrick.getQualifiedName());
    }
    if (fromBrick.getBrickDirectory() != null) {
        brick.setBrickDir(fromBrick.getBrickDirectory());
    }
    if (fromBrick.getStatus() != null) {
        brick.setStatus(mapBrickStatus(fromBrick.getStatus()));
    }
    if (fromBrick.getVolumeId() != null) {
        brick.setGlusterVolume(new GlusterVolume());
        brick.getGlusterVolume().setId(fromBrick.getVolumeId().toString());
    }
    return brick;
}
Also used : GlusterVolume(org.ovirt.engine.api.model.GlusterVolume) GlusterBrick(org.ovirt.engine.api.model.GlusterBrick)

Example 5 with GlusterVolume

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

the class GlusterVolumeMapper method map.

@Mapping(from = GlusterVolumeEntity.class, to = GlusterVolume.class)
public static GlusterVolume map(GlusterVolumeEntity fromVolume, GlusterVolume toVolume) {
    GlusterVolume volume = toVolume != null ? toVolume : new GlusterVolume();
    if (fromVolume.getId() != null) {
        volume.setId(fromVolume.getId().toString());
    }
    if (fromVolume.getName() != null) {
        volume.setName(fromVolume.getName());
    }
    if (fromVolume.getVolumeType() != null) {
        volume.setVolumeType(map(fromVolume.getVolumeType(), null));
    }
    if (fromVolume.getTransportTypes() != null) {
        ArrayList<TransportType> transportTypeList = new ArrayList<>();
        for (org.ovirt.engine.core.common.businessentities.gluster.TransportType transportType : fromVolume.getTransportTypes()) {
            transportTypeList.add(map(transportType, null));
        }
        volume.setTransportTypes(new GlusterVolume.TransportTypesList());
        volume.getTransportTypes().getTransportTypes().addAll(transportTypeList);
    }
    volume.setReplicaCount(fromVolume.getReplicaCount());
    volume.setStripeCount(fromVolume.getStripeCount());
    volume.setDisperseCount(fromVolume.getDisperseCount());
    volume.setRedundancyCount(fromVolume.getRedundancyCount());
    if (fromVolume.getStatus() != null) {
        volume.setStatus(mapVolumeStatus(fromVolume.getStatus()));
    }
    if (fromVolume.getOptions() != null) {
        Options glusterOptions = new Options();
        List<Option> options = glusterOptions.getOptions();
        for (GlusterVolumeOptionEntity option : fromVolume.getOptions()) {
            options.add(mapOption(option));
        }
        volume.setOptions(glusterOptions);
    }
    return volume;
}
Also used : Options(org.ovirt.engine.api.model.Options) GlusterVolume(org.ovirt.engine.api.model.GlusterVolume) ArrayList(java.util.ArrayList) GlusterVolumeOptionEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity) Option(org.ovirt.engine.api.model.Option) TransportType(org.ovirt.engine.api.model.TransportType)

Aggregations

GlusterVolume (org.ovirt.engine.api.model.GlusterVolume)18 GlusterBrick (org.ovirt.engine.api.model.GlusterBrick)7 Test (org.junit.Test)6 GlusterBricks (org.ovirt.engine.api.model.GlusterBricks)6 AbstractBackendCollectionResourceTest (org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)6 Cluster (org.ovirt.engine.api.model.Cluster)5 Response (javax.ws.rs.core.Response)3 Action (org.ovirt.engine.api.model.Action)3 GlusterVolumeRemoveBricksParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters)3 UriInfo (javax.ws.rs.core.UriInfo)2 Options (org.ovirt.engine.api.model.Options)2 ClusterResource (org.ovirt.engine.api.resource.ClusterResource)2 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)2 ArrayList (java.util.ArrayList)1 Option (org.ovirt.engine.api.model.Option)1 TransportType (org.ovirt.engine.api.model.TransportType)1 V3GlusterVolume (org.ovirt.engine.api.v3.types.V3GlusterVolume)1 CreateGlusterVolumeParameters (org.ovirt.engine.core.common.action.gluster.CreateGlusterVolumeParameters)1 GlusterVolumeOptionEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1