Search in sources :

Example 21 with GlusterBrickEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.

the class GlusterVolumeProfileInfoReturn method prepareBrickProfileDetails.

private List<BrickProfileDetails> prepareBrickProfileDetails(GlusterVolumeEntity volume, Object[] brickProfileDetails) {
    List<BrickProfileDetails> brickProfileDetailsList = new ArrayList<>();
    for (Object brickProfileObj : brickProfileDetails) {
        BrickProfileDetails brickProfileDetail = new BrickProfileDetails();
        Map<String, Object> brickProfile = (Map<String, Object>) brickProfileObj;
        GlusterBrickEntity brick = GlusterCoreUtil.getBrickByQualifiedName(volume.getBricks(), (String) brickProfile.get(BRICK));
        if (brick != null) {
            brickProfileDetail.setBrickId(brick.getId());
        }
        List<StatsInfo> statsInfo = new ArrayList<>();
        statsInfo.add(getStatInfo((Map<String, Object>) brickProfile.get(CUMULATIVE_STATS), CUMULATIVE_STATS));
        statsInfo.add(getStatInfo((Map<String, Object>) brickProfile.get(INTERVAL_STATS), INTERVAL_STATS));
        brickProfileDetail.setProfileStats(statsInfo);
        brickProfileDetailsList.add(brickProfileDetail);
    }
    return brickProfileDetailsList;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) StatsInfo(org.ovirt.engine.core.common.businessentities.gluster.StatsInfo) BrickProfileDetails(org.ovirt.engine.core.common.businessentities.gluster.BrickProfileDetails) ArrayList(java.util.ArrayList) Map(java.util.Map)

Example 22 with GlusterBrickEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.

the class GlusterVolumesListReturn method getBricks.

/**
 * Gets list of bricks of the volume from given list of brick representations. This can return null in certain cases
 * of failure e.g. if the brick representation contains an ip address which is mapped to more than servers in the
 * database.
 */
private List<GlusterBrickEntity> getBricks(Guid volumeId, Object[] brickList, boolean withUuid) throws Exception {
    List<GlusterBrickEntity> bricks = new ArrayList<>();
    GlusterBrickEntity fetchedBrick;
    int brickOrder = 0;
    try {
        for (Object brick : brickList) {
            if (withUuid) {
                fetchedBrick = getBrick(clusterId, volumeId, (Map<String, Object>) brick, brickOrder++);
            } else {
                fetchedBrick = getBrick(clusterId, volumeId, (String) brick, brickOrder++);
            }
            if (fetchedBrick != null) {
                bricks.add(fetchedBrick);
            }
        }
    } catch (Exception e) {
        // We do not want the command to fail if bricks for one of the volumes could not be fetched. Hence log the
        // exception and return null. The client should have special handling if bricks list of any of the volumes
        // is null.
        log.error("Error while populating bricks of volume '{}': {}", volumeId, e.getMessage());
        log.debug("Exception", e);
        return null;
    }
    return bricks;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) UnknownHostException(java.net.UnknownHostException)

Example 23 with GlusterBrickEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.

the class StorageListModel method onImport.

private void onImport() {
    StorageModel model = (StorageModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    if (!model.validate()) {
        return;
    }
    model.startProgress(ConstantsManager.getInstance().getConstants().importingStorageDomainProgress());
    VDS host = model.getHost().getSelectedItem();
    // Save changes.
    if (model.getCurrentStorageItem() instanceof NfsStorageModel) {
        NfsStorageModel nfsModel = (NfsStorageModel) model.getCurrentStorageItem();
        nfsModel.setMessage(null);
        Task.create(this, new ArrayList<>(Arrays.asList(new Object[] { // $NON-NLS-1$
        "ImportFile", host.getId(), nfsModel.getPath().getEntity(), nfsModel.getRole(), StorageType.NFS, model.getActivateDomain().getEntity() }))).run();
    } else if (model.getCurrentStorageItem() instanceof LocalStorageModel) {
        LocalStorageModel localModel = (LocalStorageModel) model.getCurrentStorageItem();
        localModel.setMessage(null);
        Task.create(this, new ArrayList<>(Arrays.asList(new Object[] { // $NON-NLS-1$
        "ImportFile", host.getId(), localModel.getPath().getEntity(), localModel.getRole(), StorageType.LOCALFS, model.getActivateDomain().getEntity() }))).run();
    } else if (model.getCurrentStorageItem() instanceof GlusterStorageModel) {
        GlusterStorageModel glusterModel = (GlusterStorageModel) model.getCurrentStorageItem();
        glusterModel.setMessage(null);
        // Check checkbox is selected or not
        if (glusterModel.getLinkGlusterVolume().getEntity() && glusterModel.getGlusterVolumes().getSelectedItem() != null) {
            GlusterBrickEntity brick = glusterModel.getGlusterVolumes().getSelectedItem().getBricks().get(0);
            if (brick != null) {
                String server = brick.getNetworkId() != null && StringHelper.isNotNullOrEmpty(brick.getNetworkAddress()) ? brick.getNetworkAddress() : brick.getServerName();
                path = // $NON-NLS-1$
                server + ":/" + glusterModel.getGlusterVolumes().getSelectedItem().getName();
            }
        } else if (!glusterModel.getLinkGlusterVolume().getEntity()) {
            path = glusterModel.getPath().getEntity();
        }
        if (StringHelper.isNotNullOrEmpty(path)) {
            Task.create(this, new ArrayList<>(Arrays.asList(new Object[] { // $NON-NLS-1$
            "ImportFile", host.getId(), path, glusterModel.getRole(), glusterModel.getType(), model.getActivateDomain().getEntity() }))).run();
        } else {
            return;
        }
    } else if (model.getCurrentStorageItem() instanceof PosixStorageModel) {
        PosixStorageModel posixModel = (PosixStorageModel) model.getCurrentStorageItem();
        posixModel.setMessage(null);
        Task.create(this, new ArrayList<>(Arrays.asList(new Object[] { // $NON-NLS-1$
        "ImportFile", host.getId(), posixModel.getPath().getEntity(), posixModel.getRole(), posixModel.getType(), model.getActivateDomain().getEntity() }))).run();
    } else if (model.getCurrentStorageItem() instanceof ImportSanStorageModel) {
        Task.create(this, new ArrayList<>(Arrays.asList(new Object[] { // $NON-NLS-1$
        "ImportSan", host.getId(), model.getActivateDomain().getEntity() }))).run();
    }
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList)

Example 24 with GlusterBrickEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.

the class GlusterStorageView method initEditors.

void initEditors() {
    linkGlusterVolumeEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
    glusterVolumesEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<GlusterVolumeEntity>() {

        @Override
        protected String renderNullSafe(GlusterVolumeEntity glusterVolume) {
            if (glusterVolume == null) {
                // $NON-NLS-1$
                return "";
            } else {
                if (glusterVolume.getBricks().isEmpty()) {
                    return glusterVolume.getName();
                }
                GlusterBrickEntity brick = glusterVolume.getBricks().get(0);
                if (brick == null) {
                    return glusterVolume.getName();
                }
                String server = brick.getNetworkId() != null && StringHelper.isNotNullOrEmpty(brick.getNetworkAddress()) ? brick.getNetworkAddress() : brick.getServerName();
                // $NON-NLS-1$
                return server + ":/" + glusterVolume.getName();
            }
        }
    });
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) NullSafeRenderer(org.ovirt.engine.ui.common.widget.renderer.NullSafeRenderer) EntityModelCheckBoxEditor(org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor)

Example 25 with GlusterBrickEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.

the class GetGlusterVolumeRemoveBricksStatusVDSCommand method executeVdsBrokerCommand.

@Override
protected void executeVdsBrokerCommand() {
    String volumeName = getParameters().getVolumeName();
    List<GlusterBrickEntity> bricksList = getParameters().getBricks();
    String[] brickNames = new String[bricksList.size()];
    for (int count = 0; count < bricksList.size(); count++) {
        brickNames[count] = bricksList.get(count).getQualifiedName();
    }
    result = getBroker().glusterVolumeRemoveBrickStatus(volumeName, brickNames);
    proceedProxyReturnValue();
    // Set the current engine time as status time
    GlusterVolumeTaskStatusEntity entity = result.getStatusDetails();
    entity.setStatusTime(new Date());
    setReturnValue(entity);
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeTaskStatusEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeTaskStatusEntity) Date(java.util.Date)

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