Skip to content

Commit

Permalink
Add ListVolumeBitmaps
Browse files Browse the repository at this point in the history
Add a new ListVolumeBitmaps command to list all bitmaps on a
image/volume.
This will be used to validate the bitmaps in the database.

Signed-off-by: Jean-Louis Dupond <[email protected]>
  • Loading branch information
dupondje committed Jun 8, 2023
1 parent 1511d64 commit c8ed87d
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.ovirt.engine.core.bll.storage.disk.image;

import org.ovirt.engine.core.bll.InternalCommandAttribute;
import org.ovirt.engine.core.bll.NonTransactiveCommandAttribute;
import org.ovirt.engine.core.bll.context.CommandContext;
import org.ovirt.engine.core.common.action.VolumeBitmapCommandParameters;
import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
import org.ovirt.engine.core.compat.Guid;

@NonTransactiveCommandAttribute(forceCompensation = true)
@InternalCommandAttribute
public class ListVolumeBitmapsCommand<T extends VolumeBitmapCommandParameters> extends
VolumeBitmapCommandBase<T> {

public ListVolumeBitmapsCommand(Guid commandId) {
super(commandId);
}

public ListVolumeBitmapsCommand(T parameters, CommandContext commandContext) {
super(parameters, commandContext);
}

@Override
protected VDSCommandType getBitmapAction() {
return VDSCommandType.ListVolumeBitmaps;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ public enum ActionType {
ClearVolumeBitmaps(3309, ActionGroup.BACKUP_DISK, false, QuotaDependency.NONE),
DeleteAllVmCheckpoints(3310, ActionGroup.BACKUP_DISK, false, QuotaDependency.NONE),
HybridBackup(3311, ActionGroup.BACKUP_DISK, QuotaDependency.NONE),
ListVolumeBitmaps(3312, ActionGroup.BACKUP_DISK, false, QuotaDependency.NONE),

// Host Devices
RefreshHostDevices(4000, ActionGroup.MANIPULATE_HOST, false, QuotaDependency.NONE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ public enum VDSCommandType {
ListVmCheckpoints("org.ovirt.engine.core.vdsbroker.vdsbroker"),
AddVolumeBitmap("org.ovirt.engine.core.vdsbroker.vdsbroker"),
RemoveVolumeBitmap("org.ovirt.engine.core.vdsbroker.vdsbroker"),
ListVolumeBitmaps("org.ovirt.engine.core.vdsbroker.vdsbroker"),
ClearVolumeBitmaps("org.ovirt.engine.core.vdsbroker.vdsbroker"),
StartNbdServer("org.ovirt.engine.core.vdsbroker.vdsbroker"),
StopNbdServer("org.ovirt.engine.core.vdsbroker.vdsbroker"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2350,6 +2350,18 @@ public StatusOnlyReturn removeBitmap(String jobId, Map<String, Object> volInfo,
return new StatusOnlyReturn(response);
}

@Override
public UUIDListReturn listBitmaps(String jobId, Map<String, Object> volInfo) {
JsonRpcRequest request =
new RequestBuilder("SDM.list_bitmaps")
.withParameter("job_id", jobId)
.withParameter("vol_info", volInfo)
.build();
Map<String, Object> response = new FutureMap(this.client, request).withResponseKey("uuidlist")
.withResponseType(Object[].class);
return new UUIDListReturn(response);
}

@Override
public StatusOnlyReturn clearBitmaps(String jobId, Map<String, Object> volInfo) {
JsonRpcRequest request =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,8 @@ OneStorageDeviceReturn glusterCreateBrick(String lvName,

StatusOnlyReturn removeBitmap(String jobId, Map<String, Object> volInfo, String bitmapName);

UUIDListReturn listBitmaps(String jobId, Map<String, Object> volInfo);

StatusOnlyReturn clearBitmaps(String jobId, Map<String, Object> volInfo);

NbdServerURLReturn startNbdServer(String serverId, Map<String, Object> nbdServerConfig);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.ovirt.engine.core.vdsbroker.vdsbroker;

import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.ovirt.engine.core.common.vdscommands.VolumeBitmapVDSCommandParameters;
import org.ovirt.engine.core.compat.Guid;
import org.ovirt.engine.core.vdsbroker.irsbroker.UUIDListReturn;

public class ListVolumeBitmapsVDSCommand<P extends VolumeBitmapVDSCommandParameters> extends VdsBrokerCommand<P> {

private UUIDListReturn uuidListReturn;

public ListVolumeBitmapsVDSCommand(P parameters) {
super(parameters);
}

@Override
protected void executeVdsBrokerCommand() {
Map<String, Object> volume = new HashMap<>();
volume.put("sd_id", getParameters().getStorageDomainId().toString());
volume.put("img_id", getParameters().getImageGroupId().toString());
volume.put("vol_id", getParameters().getImageId().toString());
volume.put("generation", getParameters().getGeneration());

uuidListReturn = getBroker().listBitmaps(getParameters().getJobId().toString(), volume);
proceedProxyReturnValue();

setReturnValue(Stream.of(uuidListReturn.getUUIDList()).map(Guid::new).collect(Collectors.toList()));
}

@Override
protected Status getReturnStatus() {
return uuidListReturn.getStatus();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,11 @@ public StatusOnlyReturn removeBitmap(String jobId, Map<String, Object> volInfo,
return null;
}

@Override
public UUIDListReturn listBitmaps(String jobId, Map<String, Object> volInfo) {
return null;
}

@Override
public StatusOnlyReturn clearBitmaps(String jobId, Map<String, Object> volInfo) {
return null;
Expand Down

0 comments on commit c8ed87d

Please sign in to comment.