mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Add snapshotName parameter in CreateSnapshotCmd
This commit is contained in:
parent
4608053ed7
commit
fc1a09ff49
@ -80,7 +80,7 @@ public interface VolumeApiService {
|
||||
|
||||
Snapshot takeSnapshot(Long volumeId, Long policyId, Long snapshotId, Account account, boolean quiescevm) throws ResourceAllocationException;
|
||||
|
||||
Snapshot allocSnapshot(Long volumeId, Long policyId) throws ResourceAllocationException;
|
||||
Snapshot allocSnapshot(Long volumeId, Long policyId, String snapshotName) throws ResourceAllocationException;
|
||||
|
||||
Volume updateVolume(long volumeId, String path, String state, Long storageId, Boolean displayVolume, String customId, long owner, String chainInfo);
|
||||
|
||||
|
||||
@ -86,7 +86,7 @@ public interface SnapshotApiService {
|
||||
|
||||
boolean deleteSnapshotPolicies(DeleteSnapshotPoliciesCmd cmd);
|
||||
|
||||
Snapshot allocSnapshot(Long volumeId, Long policyId) throws ResourceAllocationException;
|
||||
Snapshot allocSnapshot(Long volumeId, Long policyId, String snapshotName) throws ResourceAllocationException;
|
||||
|
||||
/**
|
||||
* Create a snapshot of a volume
|
||||
|
||||
@ -74,6 +74,9 @@ public class CreateSnapshotCmd extends BaseAsyncCreateCmd {
|
||||
@Parameter(name = ApiConstants.SNAPSHOT_QUIESCEVM, type = CommandType.BOOLEAN, required = false, description = "quiesce vm if true")
|
||||
private Boolean quiescevm;
|
||||
|
||||
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "the name of the snapshot")
|
||||
private String snapshotName;
|
||||
|
||||
private String syncObjectType = BaseAsyncCmd.snapshotHostSyncObject;
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
@ -100,6 +103,10 @@ public class CreateSnapshotCmd extends BaseAsyncCreateCmd {
|
||||
return volumeId;
|
||||
}
|
||||
|
||||
public String getSnapshotName() {
|
||||
return snapshotName;
|
||||
}
|
||||
|
||||
public Long getPolicyId() {
|
||||
if (policyId != null) {
|
||||
return policyId;
|
||||
@ -169,7 +176,7 @@ public class CreateSnapshotCmd extends BaseAsyncCreateCmd {
|
||||
|
||||
@Override
|
||||
public void create() throws ResourceAllocationException {
|
||||
Snapshot snapshot = _volumeService.allocSnapshot(getVolumeId(), getPolicyId());
|
||||
Snapshot snapshot = _volumeService.allocSnapshot(getVolumeId(), getPolicyId(), getSnapshotName());
|
||||
if (snapshot != null) {
|
||||
setEntityId(snapshot.getId());
|
||||
setEntityUuid(snapshot.getUuid());
|
||||
|
||||
@ -1929,7 +1929,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_SNAPSHOT_CREATE, eventDescription = "allocating snapshot", create = true)
|
||||
public Snapshot allocSnapshot(Long volumeId, Long policyId) throws ResourceAllocationException {
|
||||
public Snapshot allocSnapshot(Long volumeId, Long policyId, String snapshotName) throws ResourceAllocationException {
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
|
||||
VolumeInfo volume = volFactory.getVolume(volumeId);
|
||||
@ -1972,7 +1972,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
||||
throw new InvalidParameterValueException("VolumeId: " + volumeId + " please attach this volume to a VM before create snapshot for it");
|
||||
}
|
||||
|
||||
return snapshotMgr.allocSnapshot(volumeId, policyId);
|
||||
return snapshotMgr.allocSnapshot(volumeId, policyId, snapshotName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1092,7 +1092,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
||||
}
|
||||
|
||||
@Override
|
||||
public Snapshot allocSnapshot(Long volumeId, Long policyId) throws ResourceAllocationException {
|
||||
public Snapshot allocSnapshot(Long volumeId, Long policyId, String snapshotName) throws ResourceAllocationException {
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
VolumeInfo volume = volFactory.getVolume(volumeId);
|
||||
supportedByHypervisor(volume);
|
||||
@ -1125,7 +1125,8 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
||||
if (vmInstance != null) {
|
||||
vmDisplayName = vmInstance.getHostName();
|
||||
}
|
||||
String snapshotName = vmDisplayName + "_" + volume.getName() + "_" + timeString;
|
||||
if (snapshotName == null)
|
||||
snapshotName = vmDisplayName + "_" + volume.getName() + "_" + timeString;
|
||||
|
||||
HypervisorType hypervisorType = HypervisorType.None;
|
||||
StoragePoolVO storagePool = _storagePoolDao.findById(volume.getDataStore().getId());
|
||||
|
||||
@ -597,12 +597,25 @@
|
||||
else
|
||||
return true;
|
||||
}
|
||||
},
|
||||
name: {
|
||||
label: 'label.name',
|
||||
}
|
||||
}
|
||||
},
|
||||
action: function(args) {
|
||||
var data = {
|
||||
volumeId: args.context.volumes[0].id,
|
||||
quiescevm: (args.data.quiescevm == 'on' ? true: false)
|
||||
};
|
||||
if (args.data.name != null && args.data.name.length > 0) {
|
||||
$.extend(data, {
|
||||
name: args.data.name
|
||||
});
|
||||
}
|
||||
$.ajax({
|
||||
url: createURL("createSnapshot&volumeid=" + args.context.volumes[0].id + "&quiescevm=" + (args.data.quiescevm=='on')),
|
||||
url: createURL("createSnapshot"),
|
||||
data: data,
|
||||
dataType: "json",
|
||||
async: true,
|
||||
success: function(json) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user