Search in sources :

Example 96 with GlusterBrickEntity

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;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)

Example 97 with GlusterBrickEntity

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);
}
Also used : GlusterVolumeType(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeType) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) VolumeModel(org.ovirt.engine.ui.uicommonweb.models.gluster.VolumeModel) CreateGlusterVolumeParameters(org.ovirt.engine.core.common.action.gluster.CreateGlusterVolumeParameters) Guid(org.ovirt.engine.core.compat.Guid)

Example 98 with GlusterBrickEntity

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()));
        }
    }
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterServer(org.ovirt.engine.core.common.businessentities.gluster.GlusterServer) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus) GlusterVolumeParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeParameters)

Example 99 with GlusterBrickEntity

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);
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) GlusterBricks(org.ovirt.engine.api.model.GlusterBricks)

Example 100 with GlusterBrickEntity

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;
    }
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterBricks(org.ovirt.engine.api.model.GlusterBricks) ArrayList(java.util.ArrayList) List(java.util.List) Guid(org.ovirt.engine.core.compat.Guid) WebApplicationException(javax.ws.rs.WebApplicationException)

Aggregations

GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)132 ArrayList (java.util.ArrayList)63 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)43 Test (org.junit.Test)28 Guid (org.ovirt.engine.core.compat.Guid)19 GlusterAsyncTask (org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask)14 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)13 VDS (org.ovirt.engine.core.common.businessentities.VDS)11 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)11 List (java.util.List)10 HashMap (java.util.HashMap)9 Map (java.util.Map)9 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)9 BrickProperties (org.ovirt.engine.core.common.businessentities.gluster.BrickProperties)9 GlusterVolumeRemoveBricksParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters)7 BrickDetails (org.ovirt.engine.core.common.businessentities.gluster.BrickDetails)7 GlusterVolumeAdvancedDetails (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails)7 GlusterVolumeType (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeType)7 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)7 Iterator (java.util.Iterator)5