use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class GlusterVolumesListReturn method getBrickEntity.
private GlusterBrickEntity getBrickEntity(Guid clusterId, Guid volumeId, int brickOrder, VdsStatic server, String brickDir, String networkAddress, Guid networkId, boolean isArbiter) {
GlusterBrickEntity brick = new GlusterBrickEntity();
brick.setVolumeId(volumeId);
brick.setBrickOrder(brickOrder);
brick.setBrickDirectory(brickDir);
brick.setIsArbiter(isArbiter);
brick.setServerId(server.getId());
brick.setServerName(server.getHostName());
brick.setNetworkAddress(networkAddress);
brick.setNetworkId(networkId);
return brick;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class VolumeListModel method onCreateVolume.
private void onCreateVolume() {
VolumeModel volumeModel = (VolumeModel) getWindow();
if (!volumeModel.validate()) {
return;
}
Guid clusterId = volumeModel.getCluster().getSelectedItem().getId();
final GlusterVolumeEntity volume = new GlusterVolumeEntity();
volume.setClusterId(clusterId);
volume.setName(volumeModel.getName().getEntity());
GlusterVolumeType type = volumeModel.getTypeList().getSelectedItem();
if (type.isStripedType()) {
volume.setStripeCount(volumeModel.getStripeCountValue());
}
if (type.isReplicatedType()) {
volume.setReplicaCount(volumeModel.getReplicaCountValue());
volume.setIsArbiter(volumeModel.getArbiterVolume().getEntity());
}
volume.setVolumeType(type);
if (volumeModel.getTcpTransportType().getEntity()) {
volume.getTransportTypes().add(TransportType.TCP);
}
if (volumeModel.getRdmaTransportType().getEntity()) {
volume.getTransportTypes().add(TransportType.RDMA);
}
ArrayList<GlusterBrickEntity> brickList = new ArrayList<>();
for (Object model : volumeModel.getBricks().getItems()) {
brickList.add((GlusterBrickEntity) ((EntityModel) model).getEntity());
}
volume.setBricks(brickList);
if (volumeModel.getNfs_accecssProtocol().getEntity()) {
volume.enableNFS();
} else {
volume.disableNFS();
}
if (volumeModel.getCifs_accecssProtocol().getEntity()) {
volume.enableCifs();
} else {
volume.disableCifs();
}
volume.setAccessControlList(volumeModel.getAllowAccess().getEntity());
volumeModel.startProgress();
CreateGlusterVolumeParameters parameter = new CreateGlusterVolumeParameters(volume, volumeModel.isForceAddBricks());
Frontend.getInstance().runAction(ActionType.CreateGlusterVolume, parameter, result -> {
VolumeListModel localModel = (VolumeListModel) result.getState();
localModel.postOnCreateVolume(result.getReturnValue(), volume);
}, this);
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class GlusterBrickEventSubscriber method processEvent.
@Override
public void processEvent(GlusterEvent event) {
if (event == null) {
log.debug("No event to process!");
return;
}
GlusterServer glusterServer = glusterServerDao.getByGlusterServerUuid(Guid.createGuidFromString(event.getNodeId()));
if (glusterServer == null) {
log.debug("Could not determine gluster server from event '{}'", event);
return;
}
VdsStatic host = vdsStaticDao.get(glusterServer.getId());
if (host == null) {
log.debug("No host corresponding to gluster server in '{}'", event);
return;
}
GlusterVolumeEntity vol = glusterVolumeDao.getByName(host.getClusterId(), (String) event.getMessage().get("volume"));
if (vol == null) {
return;
}
if (event.getEvent().equalsIgnoreCase(EVENT_BRICK_DISCONNECTED) || event.getEvent().equalsIgnoreCase(EVENT_BRICK_CONNECTED)) {
// get brick
GlusterStatus status = event.getEvent().equalsIgnoreCase(EVENT_BRICK_DISCONNECTED) ? GlusterStatus.DOWN : GlusterStatus.UP;
String path = (String) event.getMessage().get(BRICK);
String peer = (String) event.getMessage().get(PEER);
List<VdsStatic> vdsList = vdsStaticDao.getAllForCluster(host.getClusterId());
VdsStatic vds = vdsList.stream().filter(v -> v.getName().equals(peer) || interfaceDao.getAllInterfacesForVds(v.getId()).stream().anyMatch(iface -> iface.getIpv4Address().equals(peer))).findFirst().orElse(null);
GlusterBrickEntity brick = vds != null ? glusterBrickDao.getBrickByServerIdAndDirectory(vds.getId(), path) : null;
if (brick != null) {
glusterBrickDao.updateBrickStatus(brick.getId(), status);
logBrickStatusChange(vol, status, brick);
} else {
// call sync to force updation
log.debug("Forcing sync as brick event '{}' received that could not be resolved to brick", event);
backend.runInternalAction(ActionType.RefreshGlusterVolumeDetails, new GlusterVolumeParameters(vol.getId()));
}
}
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class BackendGlusterBricksResource method list.
@SuppressWarnings("unchecked")
@Override
public GlusterBricks list() {
List<GlusterBrickEntity> bricks = getBackendCollection(QueryType.GetGlusterVolumeBricks, new IdQueryParameters(asGuid(getVolumeId())));
GlusterBricks bricksModel = mapCollection(bricks);
return addActions(bricksModel);
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class BackendGlusterBricksResource method resolveCreatedList.
@SuppressWarnings("unchecked")
protected GlusterBricks resolveCreatedList(ActionReturnValue result, EntityIdResolver<Guid> entityResolver) {
try {
GlusterBricks bricks = new GlusterBricks();
for (Guid id : (List<Guid>) result.getActionReturnValue()) {
GlusterBrickEntity created = entityResolver.resolve(id);
bricks.getGlusterBricks().add(addLinks(populate(map(created), created)));
}
return bricks;
} catch (Exception e) {
// we tolerate a failure in the entity resolution
// as the substantive action (entity creation) has
// already succeeded
e.printStackTrace();
return null;
}
}
Aggregations