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;
}
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;
}
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;
}
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;
}
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));
}
Aggregations