Search in sources :

Example 6 with GlusterBrick

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

the class V3GlusterBrickInAdapter method adapt.

@Override
public GlusterBrick adapt(V3GlusterBrick from) {
    GlusterBrick to = new GlusterBrick();
    if (from.isSetLinks()) {
        to.getLinks().addAll(adaptIn(from.getLinks()));
    }
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetBrickDir()) {
        to.setBrickDir(from.getBrickDir());
    }
    if (from.isSetComment()) {
        to.setComment(from.getComment());
    }
    if (from.isSetDescription()) {
        to.setDescription(from.getDescription());
    }
    if (from.isSetDevice()) {
        to.setDevice(from.getDevice());
    }
    if (from.isSetFsName()) {
        to.setFsName(from.getFsName());
    }
    if (from.isSetGlusterClients()) {
        to.setGlusterClients(new GlusterClients());
        to.getGlusterClients().getGlusterClients().addAll(adaptIn(from.getGlusterClients().getGlusterClients()));
    }
    if (from.isSetGlusterVolume()) {
        to.setGlusterVolume(adaptIn(from.getGlusterVolume()));
    }
    if (from.isSetId()) {
        to.setId(from.getId());
    }
    if (from.isSetHref()) {
        to.setHref(from.getHref());
    }
    if (from.isSetMemoryPools()) {
        to.setMemoryPools(new GlusterMemoryPools());
        to.getMemoryPools().getGlusterMemoryPools().addAll(adaptIn(from.getMemoryPools().getGlusterMemoryPools()));
    }
    if (from.isSetMntOptions()) {
        to.setMntOptions(from.getMntOptions());
    }
    if (from.isSetName()) {
        to.setName(from.getName());
    }
    if (from.isSetPid()) {
        to.setPid(from.getPid());
    }
    if (from.isSetPort()) {
        to.setPort(from.getPort());
    }
    if (from.isSetServerId()) {
        to.setServerId(from.getServerId());
    }
    if (from.isSetStatus() && from.getStatus().isSetState()) {
        to.setStatus(GlusterBrickStatus.fromValue(from.getStatus().getState()));
    }
    return to;
}
Also used : GlusterMemoryPools(org.ovirt.engine.api.model.GlusterMemoryPools) GlusterClients(org.ovirt.engine.api.model.GlusterClients) V3GlusterBrick(org.ovirt.engine.api.v3.types.V3GlusterBrick) GlusterBrick(org.ovirt.engine.api.model.GlusterBrick)

Example 7 with GlusterBrick

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

the class GlusterBrickDetailMapper method map.

@Mapping(from = GlusterVolumeAdvancedDetails.class, to = GlusterBrick.class)
public static GlusterBrick map(GlusterVolumeAdvancedDetails fromEntity, GlusterBrick toModel) {
    GlusterBrick model = (toModel == null) ? new GlusterBrick() : toModel;
    if (fromEntity.getBrickDetails() == null) {
        return model;
    }
    // Since the getDetails call is for a single brick the list size will always be 1 - so get the first element
    BrickDetails detail = (fromEntity.getBrickDetails().size() > 0) ? fromEntity.getBrickDetails().get(0) : null;
    if (detail == null) {
        return model;
    }
    model = mapBrickProperties(detail, model);
    if (detail.getClients() != null) {
        model.setGlusterClients(new GlusterClients());
        for (GlusterClientInfo clientEntity : detail.getClients()) {
            model.getGlusterClients().getGlusterClients().add(map(clientEntity));
        }
    }
    if (detail.getMemoryStatus() != null && detail.getMemoryStatus().getMemPools() != null) {
        model.setMemoryPools(new GlusterMemoryPools());
        for (Mempool pool : detail.getMemoryStatus().getMemPools()) {
            model.getMemoryPools().getGlusterMemoryPools().add(map(pool));
        }
    }
    return model;
}
Also used : GlusterMemoryPools(org.ovirt.engine.api.model.GlusterMemoryPools) BrickDetails(org.ovirt.engine.core.common.businessentities.gluster.BrickDetails) GlusterClientInfo(org.ovirt.engine.core.common.businessentities.gluster.GlusterClientInfo) Mempool(org.ovirt.engine.core.common.businessentities.gluster.Mempool) GlusterClients(org.ovirt.engine.api.model.GlusterClients) GlusterBrick(org.ovirt.engine.api.model.GlusterBrick)

Example 8 with GlusterBrick

use of org.ovirt.engine.api.model.GlusterBrick 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 9 with GlusterBrick

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

the class BrickStatisticalQuery method clone.

private GlusterBrick clone(GlusterBrick brick) {
    // Needed to avoid NPE in LinkHelper due to unsetting of grandparent in LinkHelper#addLinks.
    GlusterBrick cloned = new GlusterBrick();
    cloned.setId(brick.getId());
    cloned.setGlusterVolume(new GlusterVolume());
    cloned.getGlusterVolume().setId(brick.getGlusterVolume().getId());
    cloned.getGlusterVolume().setCluster(new Cluster());
    cloned.getGlusterVolume().getCluster().setId(brick.getGlusterVolume().getCluster().getId());
    return cloned;
}
Also used : GlusterVolume(org.ovirt.engine.api.model.GlusterVolume) Cluster(org.ovirt.engine.api.model.Cluster) GlusterBrick(org.ovirt.engine.api.model.GlusterBrick)

Example 10 with GlusterBrick

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

the class BackendGlusterBrickResourceTest method setupParentPopulateExpectations.

private void setupParentPopulateExpectations() {
    doAnswer(invocation -> {
        GlusterBrick model = (GlusterBrick) invocation.getArguments()[0];
        model.setPort(GlusterTestHelper.BRICK_PORT);
        model.setMntOptions(GlusterTestHelper.BRICK_MNT_OPT);
        return model;
    }).when(bricksResourceMock).populateAdvancedDetails(isA(GlusterBrick.class), isA(GlusterBrickEntity.class));
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterBrick(org.ovirt.engine.api.model.GlusterBrick)

Aggregations

GlusterBrick (org.ovirt.engine.api.model.GlusterBrick)21 GlusterBricks (org.ovirt.engine.api.model.GlusterBricks)7 GlusterVolume (org.ovirt.engine.api.model.GlusterVolume)7 GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)6 GlusterVolumeRemoveBricksParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters)5 Action (org.ovirt.engine.api.model.Action)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 AbstractBackendCollectionResourceTest (org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)3 Cluster (org.ovirt.engine.api.model.Cluster)2 GlusterClients (org.ovirt.engine.api.model.GlusterClients)2 GlusterMemoryPools (org.ovirt.engine.api.model.GlusterMemoryPools)2 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)2 WebApplicationException (javax.ws.rs.WebApplicationException)1 BrickProfileDetail (org.ovirt.engine.api.model.BrickProfileDetail)1 BrickProfileDetails (org.ovirt.engine.api.model.BrickProfileDetails)1 Fault (org.ovirt.engine.api.model.Fault)1 GlusterVolumeProfileDetails (org.ovirt.engine.api.model.GlusterVolumeProfileDetails)1 NfsProfileDetail (org.ovirt.engine.api.model.NfsProfileDetail)1 NfsProfileDetails (org.ovirt.engine.api.model.NfsProfileDetails)1