Skip to content

Commit 59bfe2e

Browse files
committed
Merge remote-tracking branch 'apache/main' into ExternalDeploymentIntegration
2 parents 75e36b5 + 6d5cefd commit 59bfe2e

File tree

34 files changed

+788
-102
lines changed

34 files changed

+788
-102
lines changed

.asf.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,12 @@ github:
5353
- acs-robot
5454
- gpordeus
5555
- hsato03
56-
- bernardodemarco
5756
- FelipeM525
5857
- lucas-a-martins
5958
- nicoschmdt
6059
- abh1sar
61-
- sudo87
6260
- rosi-shapeblue
61+
- sudo87
6362

6463
protected_branches: ~
6564

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ public class ApiConstants {
233233
public static final String FORCED_DESTROY_LOCAL_STORAGE = "forcedestroylocalstorage";
234234
public static final String FORCE_DELETE_HOST = "forcedeletehost";
235235
public static final String FORCE_MS_TO_IMPORT_VM_FILES = "forcemstoimportvmfiles";
236+
public static final String FORCE_UPDATE_OS_TYPE = "forceupdateostype";
236237
public static final String FORMAT = "format";
237238
public static final String FOR_VIRTUAL_NETWORK = "forvirtualnetwork";
238239
public static final String FOR_SYSTEM_VMS = "forsystemvms";

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ public abstract class BaseUpdateTemplateOrIsoCmd extends BaseCmd {
5151
description = "the ID of the OS type that best represents the OS of this image.")
5252
private Long osTypeId;
5353

54+
@Parameter(name = ApiConstants.FORCE_UPDATE_OS_TYPE, type = CommandType.BOOLEAN, since = "4.21", description = "Force OS type update. Warning: Updating OS type will " +
55+
"update the guest OS configuration for all the existing Instances deployed with this template/iso, which may affect their behavior.")
56+
private Boolean forceUpdateOsType;
57+
5458
@Parameter(name = ApiConstants.FORMAT, type = CommandType.STRING, description = "the format for the image")
5559
private String format;
5660

@@ -112,6 +116,10 @@ public Long getOsTypeId() {
112116
return osTypeId;
113117
}
114118

119+
public Boolean getForceUpdateOsType() {
120+
return forceUpdateOsType;
121+
}
122+
115123
public Boolean getPasswordEnabled() {
116124
return passwordEnabled;
117125
}

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
description = "Deletes the backup schedule of a VM",
4444
responseObject = SuccessResponse.class, since = "4.14.0",
4545
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
46-
public class DeleteBackupScheduleCmd extends BaseCmd {
46+
public class DeleteBackupScheduleCmd extends BaseCmd {
4747

4848
@Inject
4949
private BackupManager backupManager;
@@ -52,17 +52,13 @@ public class DeleteBackupScheduleCmd extends BaseCmd {
5252
//////////////// API parameters /////////////////////
5353
/////////////////////////////////////////////////////
5454

55-
@Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID,
56-
type = CommandType.UUID,
57-
entityType = UserVmResponse.class,
58-
description = "ID of the VM")
55+
@Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, entityType = UserVmResponse.class,
56+
description = "ID of the VM from which all backup schedules will be deleted.")
5957
private Long vmId;
6058

61-
@Parameter(name = ApiConstants.ID,
62-
type = CommandType.UUID,
63-
entityType = BackupScheduleResponse.class,
64-
description = "ID of the schedule",
65-
since = "4.20.1")
59+
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = BackupScheduleResponse.class,
60+
since = "4.20.1", description = "ID of the backup schedule to be deleted. It has precedence over the 'virtualmachineid' parameter, " +
61+
"i.e., when the 'id' parameter is specified, the 'virtualmachineid' parameter will be ignored.")
6662
private Long id;
6763

6864
/////////////////////////////////////////////////////

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828

2929
@EntityReference(value = BackupSchedule.class)
3030
public class BackupScheduleResponse extends BaseResponse {
31+
@SerializedName(ApiConstants.ID)
32+
@Param(description = "ID of the backup schedule.", since = "4.21.0")
33+
private String id;
3134

3235
@SerializedName(ApiConstants.VIRTUAL_MACHINE_NAME)
3336
@Param(description = "name of the VM")
@@ -51,7 +54,11 @@ public class BackupScheduleResponse extends BaseResponse {
5154

5255
@SerializedName(ApiConstants.MAX_BACKUPS)
5356
@Param(description = "maximum number of backups retained")
54-
private Integer maxBakups;
57+
private Integer maxBackups;
58+
59+
public void setId(String id) {
60+
this.id = id;
61+
}
5562

5663
public String getVmName() {
5764
return vmName;
@@ -93,7 +100,7 @@ public void setTimezone(String timezone) {
93100
this.timezone = timezone;
94101
}
95102

96-
public void setMaxBakups(Integer maxBakups) {
97-
this.maxBakups = maxBakups;
103+
public void setMaxBackups(Integer maxBackups) {
104+
this.maxBackups = maxBackups;
98105
}
99106
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ public interface BackupSchedule extends InternalIdentity {
3131
Date getScheduledTimestamp();
3232
Long getAsyncJobId();
3333
Integer getMaxBackups();
34+
String getUuid();
3435
}

client/pom.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -321,16 +321,6 @@
321321
<artifactId>cloud-plugin-hypervisor-ucs</artifactId>
322322
<version>${project.version}</version>
323323
</dependency>
324-
<dependency>
325-
<groupId>org.apache.cloudstack</groupId>
326-
<artifactId>cloud-plugin-hypervisor-ovm</artifactId>
327-
<version>${project.version}</version>
328-
</dependency>
329-
<dependency>
330-
<groupId>org.apache.cloudstack</groupId>
331-
<artifactId>cloud-plugin-hypervisor-ovm3</artifactId>
332-
<version>${project.version}</version>
333-
</dependency>
334324
<dependency>
335325
<groupId>org.apache.cloudstack</groupId>
336326
<artifactId>cloud-plugin-hypervisor-kvm</artifactId>

engine/schema/src/main/java/com/cloud/usage/dao/UsageJobDao.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,6 @@ public interface UsageJobDao extends GenericDao<UsageJobVO, Long> {
3737
UsageJobVO isOwner(String hostname, int pid);
3838

3939
void updateJobSuccess(Long jobId, long startMillis, long endMillis, long execTime, boolean success);
40+
41+
void removeLastOpenJobsOwned(String hostname, int pid);
4042
}

engine/schema/src/main/java/com/cloud/usage/dao/UsageJobDaoImpl.java

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.List;
2323

2424

25+
import org.apache.commons.collections.CollectionUtils;
2526
import org.springframework.stereotype.Component;
2627

2728
import com.cloud.usage.UsageJobVO;
@@ -114,7 +115,7 @@ public Long checkHeartbeat(String hostname, int pid, int aggregationDuration) {
114115
public UsageJobVO isOwner(String hostname, int pid) {
115116
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
116117
try {
117-
if ((hostname == null) || (pid <= 0)) {
118+
if (hostname == null || pid <= 0) {
118119
return null;
119120
}
120121

@@ -174,7 +175,7 @@ public UsageJobVO getNextImmediateJob() {
174175
SearchCriteria<UsageJobVO> sc = createSearchCriteria();
175176
sc.addAnd("endMillis", SearchCriteria.Op.EQ, Long.valueOf(0));
176177
sc.addAnd("jobType", SearchCriteria.Op.EQ, Integer.valueOf(UsageJobVO.JOB_TYPE_SINGLE));
177-
sc.addAnd("scheduled", SearchCriteria.Op.EQ, Integer.valueOf(0));
178+
sc.addAnd("scheduled", SearchCriteria.Op.EQ, Integer.valueOf(UsageJobVO.JOB_NOT_SCHEDULED));
178179
List<UsageJobVO> jobs = search(sc, filter);
179180

180181
if ((jobs == null) || jobs.isEmpty()) {
@@ -194,4 +195,36 @@ public Date getLastHeartbeat() {
194195
}
195196
return jobs.get(0).getHeartbeat();
196197
}
198+
199+
private List<UsageJobVO> getLastOpenJobsOwned(String hostname, int pid) {
200+
SearchCriteria<UsageJobVO> sc = createSearchCriteria();
201+
sc.addAnd("endMillis", SearchCriteria.Op.EQ, Long.valueOf(0));
202+
sc.addAnd("host", SearchCriteria.Op.EQ, hostname);
203+
if (pid > 0) {
204+
sc.addAnd("pid", SearchCriteria.Op.EQ, Integer.valueOf(pid));
205+
}
206+
return listBy(sc);
207+
}
208+
209+
@Override
210+
public void removeLastOpenJobsOwned(String hostname, int pid) {
211+
if (hostname == null) {
212+
return;
213+
}
214+
215+
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
216+
try {
217+
List<UsageJobVO> jobs = getLastOpenJobsOwned(hostname, pid);
218+
if (CollectionUtils.isNotEmpty(jobs)) {
219+
logger.info("Found {} opens job, to remove", jobs.size());
220+
for (UsageJobVO job : jobs) {
221+
logger.debug("Removing job - id: {}, pid: {}, job type: {}, scheduled: {}, heartbeat: {}",
222+
job.getId(), job.getPid(), job.getJobType(), job.getScheduled(), job.getHeartbeat());
223+
remove(job.getId());
224+
}
225+
}
226+
} finally {
227+
txn.close();
228+
}
229+
}
197230
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.cloudstack.backup;
1919

2020
import java.util.Date;
21+
import java.util.UUID;
2122

2223
import javax.persistence.Column;
2324
import javax.persistence.Entity;
@@ -39,6 +40,9 @@ public class BackupScheduleVO implements BackupSchedule {
3940
@Column(name = "id")
4041
private long id;
4142

43+
@Column(name = "uuid", nullable = false)
44+
private String uuid = UUID.randomUUID().toString();
45+
4246
@Column(name = "vm_id")
4347
private Long vmId;
4448

@@ -84,6 +88,11 @@ public long getId() {
8488
return id;
8589
}
8690

91+
@Override
92+
public String getUuid() {
93+
return uuid;
94+
}
95+
8796
public Long getVmId() {
8897
return vmId;
8998
}

0 commit comments

Comments
 (0)