Skip to content

Commit a1922bb

Browse files
author
Fabrício Duarte
committed
Merge branch 'isolated-backups' into '4.20.0.0-scclouds'
_Backups_ isolados Closes #3046 See merge request scclouds/scclouds!1302
2 parents 35dc483 + 649b7d6 commit a1922bb

27 files changed

Lines changed: 170 additions & 36 deletions

File tree

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ public class ApiConstants {
560560
public static final String VLAN_RANGE = "vlanrange";
561561
public static final String REMOVE_VLAN = "removevlan";
562562
public static final String VLAN_ID = "vlanid";
563+
public static final String ISOLATED = "isolated";
563564
public static final String ISOLATED_PVLAN = "isolatedpvlan";
564565
public static final String ISOLATED_PVLAN_TYPE = "isolatedpvlantype";
565566
public static final String ISOLATION_URI = "isolationuri";
@@ -1255,6 +1256,10 @@ public class ApiConstants {
12551256
"If \"0\", no retention policy will be applied and, thus, no backups from the schedule will be automatically deleted. " +
12561257
"This parameter is only supported for the Dummy, KNIB, NAS and EMC Networker backup provider.";
12571258

1259+
public static final String PARAMETER_DESCRIPTION_ISOLATED_BACKUPS = "Whether the backup will be isolated, defaults to false. " +
1260+
"Isolated backups are always created as full backups in independent chains. Therefore, they will never depend on any existing backup chain " +
1261+
"and no backup chain will depend on them. Currently only supported for the KNIB provider.";
1262+
12581263
public static final String CSS = "css";
12591264

12601265
public static final String JSON_CONFIGURATION = "jsonconfiguration";

api/src/main/java/org/apache/cloudstack/api/command/user/backup/CreateBackupCmd.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ public class CreateBackupCmd extends BaseAsyncCreateCmd {
6767
description = "Whether the VM's file systems should be frozen for the backup. Currently only supported for KNIB")
6868
private boolean quiesceVm;
6969

70+
@Parameter(name = ApiConstants.ISOLATED,
71+
type = CommandType.BOOLEAN,
72+
description = ApiConstants.PARAMETER_DESCRIPTION_ISOLATED_BACKUPS,
73+
since = "4.20.0.6-scclouds")
74+
private boolean isolated;
75+
7076
/////////////////////////////////////////////////////
7177
/////////////////// Accessors ///////////////////////
7278
/////////////////////////////////////////////////////
@@ -86,7 +92,7 @@ public boolean isQuiesceVm() {
8692
@Override
8793
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
8894
try {
89-
boolean result = backupManager.createBackup(getVmId(), quiesceVm, getJob());
95+
boolean result = backupManager.createBackup(getVmId(), quiesceVm, isolated, getJob());
9096
if (result) {
9197
SuccessResponse response = new SuccessResponse(getCommandName());
9298
response.setResponseName(getCommandName());

api/src/main/java/org/apache/cloudstack/api/command/user/backup/CreateBackupScheduleCmd.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ public class CreateBackupScheduleCmd extends BaseCmd {
8484
description = ApiConstants.PARAMETER_DESCRIPTION_MAX_BACKUPS, since = "4.20.0.4-scclouds")
8585
private Integer maxBackups;
8686

87+
@Parameter(name = ApiConstants.ISOLATED,
88+
type = CommandType.BOOLEAN,
89+
description = ApiConstants.PARAMETER_DESCRIPTION_ISOLATED_BACKUPS,
90+
since = "4.20.0.6-scclouds")
91+
private boolean isolated;
92+
8793
/////////////////////////////////////////////////////
8894
/////////////////// Accessors ///////////////////////
8995
/////////////////////////////////////////////////////
@@ -112,6 +118,10 @@ public Integer getMaxBackups() {
112118
return maxBackups;
113119
}
114120

121+
public boolean isIsolated() {
122+
return isolated;
123+
}
124+
115125
/////////////////////////////////////////////////////
116126
/////////////// API Implementation///////////////////
117127
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/response/BackupScheduleResponse.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ public class BackupScheduleResponse extends BaseResponse {
6060
@Param(description = ApiConstants.PARAMETER_DESCRIPTION_MAX_BACKUPS)
6161
private int maxBackups;
6262

63+
@SerializedName(ApiConstants.ISOLATED)
64+
@Param(description = ApiConstants.PARAMETER_DESCRIPTION_ISOLATED_BACKUPS)
65+
private boolean isolated;
66+
6367
public void setId(String id) {
6468
this.id = id;
6569
}
@@ -111,4 +115,8 @@ public void setQuiesceVm(boolean quiesceVm) {
111115
public void setMaxBackups(int maxBackups) {
112116
this.maxBackups = maxBackups;
113117
}
118+
119+
public void setIsolated(boolean isolated) {
120+
this.isolated = isolated;
121+
}
114122
}

api/src/main/java/org/apache/cloudstack/backup/BackupManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,11 @@ public interface BackupManager extends BackupService, Configurable, PluggableSer
125125
*
126126
* @param vmId Virtual Machine ID
127127
* @param quiesceVm
128+
* @param isolated Whether the backup will be isolated or not
128129
* @param job The async job associated with the backup creation
129130
* @return returns operation success
130131
*/
131-
boolean createBackup(final Long vmId, boolean quiesceVm, Object job);
132+
boolean createBackup(final Long vmId, boolean quiesceVm, boolean isolated, Object job);
132133

133134
/**
134135
* List existing backups for a VM

api/src/main/java/org/apache/cloudstack/backup/BackupProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ public interface BackupProvider {
7979
*
8080
* @param vm VirtualMachine definition
8181
* @param quiesceVm whether to quiesce the VM or not.
82+
* @param isolated whether the backup will be isolated or not.
8283
* @param backupScheduleId the ID of the backup schedule; should be null if the backup is manual.
8384
* @return
8485
*/
85-
boolean takeBackup(VirtualMachine vm, boolean quiesceVm, Long backupScheduleId);
86+
boolean takeBackup(VirtualMachine vm, boolean quiesceVm, boolean isolated, Long backupScheduleId);
8687

8788
/**
8889
* Delete an existing backup
@@ -122,7 +123,7 @@ Pair<Boolean, String> restoreBackedUpVolume(Backup backup, String volumeUuid, St
122123
* This method should be overwritten by any backup providers that want to schedule their backup jobs in the same queue as the VM jobs.
123124
* Otherwise, just use the takeBackup method.
124125
* */
125-
default Boolean orchestrateTakeBackup(Backup backup, boolean quiesceVm) {
126+
default Boolean orchestrateTakeBackup(Backup backup, boolean quiesceVm, boolean isolated) {
126127
return null;
127128
}
128129

api/src/main/java/org/apache/cloudstack/backup/BackupSchedule.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@ public interface BackupSchedule extends InternalIdentity {
3333
String getUuid();
3434
boolean isQuiesceVm();
3535
int getMaxBackups();
36+
boolean isIsolated();
3637
}

core/src/main/java/org/apache/cloudstack/backup/TakeKnibBackupCommand.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,17 @@ public class TakeKnibBackupCommand extends Command {
4040

4141
private List<KnibTO> knibTOs;
4242

43-
public TakeKnibBackupCommand(boolean quiesceVm, boolean runningVM, boolean endChain, String vmName, String imageStoreUrl, List<String> backupChainImageStoreUrls, List<KnibTO> knibTOs) {
43+
private boolean isolated;
44+
45+
public TakeKnibBackupCommand(boolean quiesceVm, boolean runningVM, boolean endChain, String vmName, String imageStoreUrl, List<String> backupChainImageStoreUrls, List<KnibTO> knibTOs, boolean isolated) {
4446
this.quiesceVm = quiesceVm;
4547
this.runningVM = runningVM;
4648
this.endChain = endChain;
4749
this.vmName = vmName;
4850
this.imageStoreUrl = imageStoreUrl;
4951
this.backupChainImageStoreUrls = backupChainImageStoreUrls;
5052
this.knibTOs = knibTOs;
53+
this.isolated = isolated;
5154
}
5255

5356
public boolean isQuiesceVm() {
@@ -78,6 +81,10 @@ public List<KnibTO> getKnibTOs() {
7881
return knibTOs;
7982
}
8083

84+
public boolean isIsolated() {
85+
return isolated;
86+
}
87+
8188
@Override
8289
public boolean executeInSequence() {
8390
return false;

engine/components-api/src/main/java/com/cloud/vm/VmWorkTakeBackup.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@ public class VmWorkTakeBackup extends VmWork {
2525

2626
private boolean quiesceVm;
2727

28-
public VmWorkTakeBackup(long userId, long accountId, long vmId, long backupId, String handlerName, String backupProvider, boolean quiesceVm) {
28+
private boolean isolated;
29+
30+
public VmWorkTakeBackup(long userId, long accountId, long vmId, long backupId, String handlerName, String backupProvider, boolean quiesceVm, boolean isolated) {
2931
super(userId, accountId, vmId, handlerName);
3032
this.backupProvider = backupProvider;
3133
this.quiesceVm = quiesceVm;
3234
this.backupId = backupId;
35+
this.isolated = isolated;
3336
}
3437

3538
public String getBackupProvider() {
@@ -44,6 +47,10 @@ public long getBackupId() {
4447
return backupId;
4548
}
4649

50+
public boolean isIsolated() {
51+
return isolated;
52+
}
53+
4754
@Override
4855
public String toString() {
4956
return super.toStringAfterRemoveParams(null, null);

engine/schema/src/main/java/org/apache/cloudstack/backup/BackupScheduleVO.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,21 @@ public class BackupScheduleVO implements BackupSchedule {
6767
@Column(name = "quiesce_vm")
6868
private boolean quiesceVm;
6969

70+
@Column(name = "isolated")
71+
private boolean isolated;
72+
7073
public BackupScheduleVO() {
7174
}
7275

73-
public BackupScheduleVO(Long vmId, DateUtil.IntervalType scheduleType, String schedule, String timezone, Date scheduledTimestamp, boolean quiesceVm, int maxBackups) {
76+
public BackupScheduleVO(Long vmId, DateUtil.IntervalType scheduleType, String schedule, String timezone, Date scheduledTimestamp, boolean quiesceVm, int maxBackups, boolean isolated) {
7477
this.vmId = vmId;
7578
this.scheduleType = (short) scheduleType.ordinal();
7679
this.schedule = schedule;
7780
this.timezone = timezone;
7881
this.scheduledTimestamp = scheduledTimestamp;
7982
this.quiesceVm = quiesceVm;
8083
this.maxBackups = maxBackups;
84+
this.isolated = isolated;
8185
}
8286

8387
@Override
@@ -156,4 +160,13 @@ public void setQuiesceVm(boolean quiesceVm) {
156160
public boolean isQuiesceVm() {
157161
return quiesceVm;
158162
}
163+
164+
@Override
165+
public boolean isIsolated() {
166+
return isolated;
167+
}
168+
169+
public void setIsolated(boolean isolated) {
170+
this.isolated = isolated;
171+
}
159172
}

0 commit comments

Comments
 (0)