Skip to content

Commit 2a5bf65

Browse files
author
Marcus Sorensen
committed
CLOUDSTACK-6785: Allow async jobs to supply an injectedjobid
1 parent d0c249b commit 2a5bf65

5 files changed

Lines changed: 13 additions & 5 deletions

File tree

api/src/org/apache/cloudstack/api/BaseAsyncCmd.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ public abstract class BaseAsyncCmd extends BaseCmd {
3636
@Parameter(name = "starteventid", type = CommandType.LONG)
3737
private Long startEventId;
3838

39+
@Parameter(name= "injectedjobid", type = CommandType.STRING)
40+
private String injectedJobId;
41+
42+
public String getInjectedJobId() {
43+
return this.injectedJobId;
44+
}
45+
3946
/**
4047
* For proper tracking of async commands through the system, events must be generated when the command is
4148
* scheduled, started, and completed. Commands should specify the type of event so that when the scheduled,

framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobVO.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,12 @@ public AsyncJobVO() {
136136
status = Status.IN_PROGRESS;
137137
}
138138

139-
public AsyncJobVO(String related, long userId, long accountId, String cmd, String cmdInfo, Long instanceId, String instanceType) {
139+
public AsyncJobVO(String related, long userId, long accountId, String cmd, String cmdInfo, Long instanceId, String instanceType, String injectedUuid) {
140140
this.userId = userId;
141141
this.accountId = accountId;
142142
this.cmd = cmd;
143143
this.cmdInfo = cmdInfo;
144-
uuid = UUID.randomUUID().toString();
144+
uuid = ( injectedUuid == null ? UUID.randomUUID().toString() : injectedUuid );
145145
this.related = related;
146146
this.instanceId = instanceId;
147147
this.instanceType = instanceType;

server/src/com/cloud/api/ApiServer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,8 @@ private String queueCommand(final BaseCmd cmdObj, final Map<String, String> para
661661
Long instanceId = (objectId == null) ? asyncCmd.getInstanceId() : objectId;
662662
AsyncJobVO job = new AsyncJobVO("", callerUserId, caller.getId(), cmdObj.getClass().getName(),
663663
ApiGsonHelper.getBuilder().create().toJson(params), instanceId,
664-
asyncCmd.getInstanceType() != null ? asyncCmd.getInstanceType().toString() : null);
664+
asyncCmd.getInstanceType() != null ? asyncCmd.getInstanceType().toString() : null,
665+
asyncCmd.getInjectedJobId());
665666
job.setDispatcher(_asyncDispatcher.getName());
666667

667668
final long jobId = _asyncMgr.submitAsyncJob(job);

server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4360,7 +4360,7 @@ private List<Long> rebootRouters(List<DomainRouterVO> routers){
43604360
params.put("ctxStartEventId", "1");
43614361
AsyncJobVO job = new AsyncJobVO("", User.UID_SYSTEM, router.getAccountId(), RebootRouterCmd.class.getName(),
43624362
ApiGsonHelper.getBuilder().create().toJson(params), router.getId(),
4363-
cmd.getInstanceType() != null ? cmd.getInstanceType().toString() : null);
4363+
cmd.getInstanceType() != null ? cmd.getInstanceType().toString() : null, null);
43644364
job.setDispatcher(_asyncDispatcher.getName());
43654365
long jobId = _asyncMgr.submitAsyncJob(job);
43664366
jobIds.add(jobId);

server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ protected void scheduleSnapshots() {
264264

265265
AsyncJobVO job = new AsyncJobVO("", User.UID_SYSTEM, volume.getAccountId(), CreateSnapshotCmd.class.getName(),
266266
ApiGsonHelper.getBuilder().create().toJson(params), cmd.getEntityId(),
267-
cmd.getInstanceType() != null ? cmd.getInstanceType().toString() : null);
267+
cmd.getInstanceType() != null ? cmd.getInstanceType().toString() : null, null);
268268
job.setDispatcher(_asyncDispatcher.getName());
269269

270270
final long jobId = _asyncMgr.submitAsyncJob(job);

0 commit comments

Comments
 (0)