Search in sources :

Example 6 with GlusterVolumeSnapshotEntity

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

the class GlusterVolumeSnapshotListModel method deleteSnapshot.

private void deleteSnapshot() {
    if (getSelectedItems() == null) {
        return;
    }
    ConfirmationModel model = new ConfirmationModel();
    List<GlusterVolumeSnapshotEntity> snapshots = getSelectedItems();
    StringBuilder snapshotNames = new StringBuilder();
    for (GlusterVolumeSnapshotEntity snapshot : snapshots) {
        snapshotNames.append(snapshot.getSnapshotName());
        // $NON-NLS-1$
        snapshotNames.append("\n");
    }
    setConfirmWindow(model);
    model.setTitle(ConstantsManager.getInstance().getMessages().confirmRemoveSnapshot(getEntity().getName()));
    model.setHelpTag(HelpTag.volume_delete_snapshot_confirmation);
    // $NON-NLS-1$
    model.setHashName("volume_delete_snapshot_confirmation");
    model.setMessage(ConstantsManager.getInstance().getMessages().confirmVolumeSnapshotDeleteMessage(snapshotNames.toString()));
    // $NON-NLS-1$
    UICommand okCommand = UICommand.createDefaultOkUiCommand("onDeleteSnapshot", this);
    model.getCommands().add(okCommand);
    // $NON-NLS-1$
    UICommand cancelCommand = UICommand.createCancelUiCommand("cancelConfirmation", this);
    model.getCommands().add(cancelCommand);
}
Also used : GlusterVolumeSnapshotEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)

Example 7 with GlusterVolumeSnapshotEntity

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

the class SubTabGlusterVolumeSnapshotView method initTable.

void initTable() {
    getTable().enableColumnResizing();
    GlusterVolumeSnapshotStatusColumn snapshotStatusColumn = new GlusterVolumeSnapshotStatusColumn();
    snapshotStatusColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(snapshotStatusColumn, constants.empty(), "30px");
    AbstractTextColumn<GlusterVolumeSnapshotEntity> snapshotNameColumn = new AbstractTextColumn<GlusterVolumeSnapshotEntity>() {

        @Override
        public String getValue(GlusterVolumeSnapshotEntity snapshot) {
            return snapshot.getSnapshotName();
        }
    };
    snapshotNameColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(snapshotNameColumn, constants.volumeSnapshotName(), "300px");
    AbstractTextColumn<GlusterVolumeSnapshotEntity> descriptionColumn = new AbstractTextColumn<GlusterVolumeSnapshotEntity>() {

        @Override
        public String getValue(GlusterVolumeSnapshotEntity snapshot) {
            return snapshot.getDescription();
        }
    };
    descriptionColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(descriptionColumn, constants.volumeSnapshotDescription(), "400px");
    AbstractTextColumn<GlusterVolumeSnapshotEntity> creationTimeColumn = new AbstractTextColumn<GlusterVolumeSnapshotEntity>() {

        @Override
        public String getValue(GlusterVolumeSnapshotEntity snapshot) {
            // $NON-NLS-1$
            DateTimeFormat df = DateTimeFormat.getFormat("yyyy-MM-dd, HH:mm:ss");
            return df.format(snapshot.getCreatedAt());
        }
    };
    creationTimeColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(creationTimeColumn, constants.volumeSnapshotCreationTime(), "400px");
}
Also used : GlusterVolumeSnapshotEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity) GlusterVolumeSnapshotStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.GlusterVolumeSnapshotStatusColumn) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) DateTimeFormat(com.google.gwt.i18n.client.DateTimeFormat)

Example 8 with GlusterVolumeSnapshotEntity

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

the class GlusterSnapshotSyncJob method refreshSnapshotsInCluster.

private void refreshSnapshotsInCluster(Cluster cluster) {
    if (!supportsGlusterSnapshotFeature(cluster)) {
        return;
    }
    final VDS upServer = glusterUtil.getRandomUpServer(cluster.getId());
    if (upServer == null) {
        log.info("No UP server found in cluster '{}' for snapshot monitoring", cluster.getName());
        return;
    }
    VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GetGlusterVolumeSnapshotInfo, new GlusterVolumeSnapshotVDSParameters(upServer.getId(), cluster.getId(), null));
    if (returnValue.getSucceeded()) {
        addOrUpdateSnapshots(cluster.getId(), (ArrayList<GlusterVolumeSnapshotEntity>) returnValue.getReturnValue());
        // check if the snapshot soft limit reached for a volume and alert
        List<GlusterVolumeEntity> volumes = volumeDao.getByClusterId(cluster.getId());
        for (final GlusterVolumeEntity volume : volumes) {
            // check if the snapshot soft limit reached for the volume and alert
            glusterUtil.alertVolumeSnapshotLimitsReached(volume);
            // Check and remove soft limit alert for the volume.
            // It might have fallen below the soft limit as part of deletions of snapshots
            glusterUtil.checkAndRemoveVolumeSnapshotLimitsAlert(volume);
        }
    } else {
        log.error("VDS Error {}", returnValue.getVdsError().getMessage());
        log.debug("VDS Error {}", returnValue.getVdsError());
    }
}
Also used : GlusterVolumeSnapshotVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeSnapshotVDSParameters) VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterVolumeSnapshotEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 9 with GlusterVolumeSnapshotEntity

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

the class GlusterSnapshotSyncJob method addOrUpdateSnapshots.

private void addOrUpdateSnapshots(Guid clusterId, List<GlusterVolumeSnapshotEntity> fetchedSnapshots) {
    Map<Guid, GlusterVolumeSnapshotEntity> fetchedSnapshotsMap = new HashMap<>();
    for (GlusterVolumeSnapshotEntity fetchedSnapshot : fetchedSnapshots) {
        fetchedSnapshotsMap.put(fetchedSnapshot.getId(), fetchedSnapshot);
    }
    Cluster cluster = clusterDao.get(clusterId);
    List<GlusterVolumeSnapshotEntity> existingSnapshots = volumeSnapshotDao.getAllByClusterId(clusterId);
    Map<Guid, GlusterVolumeSnapshotEntity> existingSnapshotsMap = new HashMap<>();
    for (GlusterVolumeSnapshotEntity existingSnapshot : existingSnapshots) {
        existingSnapshotsMap.put(existingSnapshot.getId(), existingSnapshot);
    }
    List<GlusterVolumeSnapshotEntity> updatedSnapshots = new ArrayList<>();
    List<GlusterVolumeSnapshotEntity> newlyAddedSnapshots = new ArrayList<>();
    List<GlusterVolumeSnapshotEntity> deletedSnapshots = new ArrayList<>();
    for (final GlusterVolumeSnapshotEntity fetchedSnapshot : fetchedSnapshots) {
        GlusterVolumeSnapshotEntity correspondingExistingSnapshot = existingSnapshotsMap.get(fetchedSnapshot.getId());
        if (correspondingExistingSnapshot == null) {
            final GlusterVolumeEntity volume = volumeDao.getById(fetchedSnapshot.getVolumeId());
            newlyAddedSnapshots.add(fetchedSnapshot);
            log.debug("Detected new gluster volume snapshot '{}' for volume '{}' on cluster: '{}'", fetchedSnapshot.getSnapshotName(), volume.getName(), cluster.getName());
            Map<String, String> customValues = new HashMap<>();
            customValues.put("snapName", fetchedSnapshot.getSnapshotName());
            customValues.put(GlusterConstants.VOLUME_NAME, volume.getName());
            logUtil.logAuditMessage(clusterId, volume.getClusterName(), volume, null, AuditLogType.GLUSTER_VOLUME_SNAPSHOT_DETECTED_NEW, customValues);
        } else if (correspondingExistingSnapshot.getStatus() != fetchedSnapshot.getStatus()) {
            correspondingExistingSnapshot.setStatus(fetchedSnapshot.getStatus());
            updatedSnapshots.add(correspondingExistingSnapshot);
        }
    }
    for (final GlusterVolumeSnapshotEntity existingSnapshot : existingSnapshots) {
        GlusterVolumeSnapshotEntity correspondingFetchedSnapshot = fetchedSnapshotsMap.get(existingSnapshot.getId());
        if (correspondingFetchedSnapshot == null) {
            final GlusterVolumeEntity volume = volumeDao.getById(existingSnapshot.getVolumeId());
            deletedSnapshots.add(existingSnapshot);
            log.debug("Gluster volume snapshot '{}' detected removed for volume '{}' on cluster: '{}'", existingSnapshot.getSnapshotName(), volume.getName(), cluster.getName());
            Map<String, String> customValues = new HashMap<>();
            customValues.put("snapName", existingSnapshot.getSnapshotName());
            customValues.put(GlusterConstants.VOLUME_NAME, volume.getName());
            logUtil.logAuditMessage(clusterId, volume.getClusterName(), volume, null, AuditLogType.GLUSTER_VOLUME_SNAPSHOT_DELETED_FROM_CLI, customValues);
        }
    }
    // update snapshot details
    try (EngineLock lock = acquireVolumeSnapshotLock(clusterId)) {
        saveNewSnapshots(newlyAddedSnapshots);
        updateSnapshots(updatedSnapshots);
        deleteSnapshots(deletedSnapshots);
    } catch (Exception e) {
        log.error("Exception ocuured while adding/updating snapshots from CLI - '{}'", e.getMessage());
        log.debug("Exception", e);
        throw new EngineException(EngineError.GlusterSnapshotInfoFailedException, e.getLocalizedMessage());
    }
}
Also used : HashMap(java.util.HashMap) GlusterVolumeSnapshotEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity) ArrayList(java.util.ArrayList) EngineException(org.ovirt.engine.core.common.errors.EngineException) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Guid(org.ovirt.engine.core.compat.Guid) EngineLock(org.ovirt.engine.core.utils.lock.EngineLock) EngineException(org.ovirt.engine.core.common.errors.EngineException) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)

Example 10 with GlusterVolumeSnapshotEntity

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

the class GlusterVolumeSnapshotDaoTest method testUpdateSnapshotStatusByName.

@Test
public void testUpdateSnapshotStatusByName() {
    dao.updateSnapshotStatusByName(existingSnapshot.getVolumeId(), existingSnapshot.getSnapshotName(), GlusterSnapshotStatus.DEACTIVATED);
    GlusterVolumeSnapshotEntity snapshot = dao.getById(existingSnapshot.getSnapshotId());
    assertNotNull(snapshot);
    assertFalse(snapshot.equals(existingSnapshot));
    existingSnapshot.setStatus(GlusterSnapshotStatus.DEACTIVATED);
    assertEquals(existingSnapshot, snapshot);
}
Also used : GlusterVolumeSnapshotEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity) Test(org.junit.Test)

Aggregations

GlusterVolumeSnapshotEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity)25 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)12 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)8 Guid (org.ovirt.engine.core.compat.Guid)6 Date (java.util.Date)5 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)4 EngineLock (org.ovirt.engine.core.utils.lock.EngineLock)4 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)3 VDS (org.ovirt.engine.core.common.businessentities.VDS)3 GlusterGeoRepSession (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)3 HashMap (java.util.HashMap)2 CreateGlusterVolumeSnapshotParameters (org.ovirt.engine.core.common.action.gluster.CreateGlusterVolumeSnapshotParameters)2 GlusterVolumeGeoRepSessionParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters)2 CreateGlusterVolumeSnapshotVDSParameters (org.ovirt.engine.core.common.vdscommands.gluster.CreateGlusterVolumeSnapshotVDSParameters)2 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)2 DateTimeFormat (com.google.gwt.i18n.client.DateTimeFormat)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Map (java.util.Map)1