Repository navigation
Expand file tree
/
Copy pathAsyncJobResponse.java
More file actions
148 lines (122 loc) · 6.75 KB
/
Copy pathAsyncJobResponse.java
File metadata and controls
148 lines (122 loc) · 6.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.api.response;
import java.util.Date;
import com.cloud.api.ApiConstants;
import com.cloud.api.ResponseObject;
import com.cloud.async.AsyncJob;
import com.cloud.serializer.Param;
import com.cloud.utils.IdentityProxy;
import com.google.gson.annotations.SerializedName;
@SuppressWarnings("unused")
public class AsyncJobResponse extends BaseResponse {
@SerializedName("accountid") @Param(description="the account that executed the async command")
private IdentityProxy accountId = new IdentityProxy("account");
@SerializedName(ApiConstants.USER_ID) @Param(description="the user that executed the async command")
private IdentityProxy userId = new IdentityProxy("user");
@SerializedName("cmd") @Param(description="the async command executed")
private String cmd;
@SerializedName("jobstatus") @Param(description="the current job status-should be 0 for PENDING")
private Integer jobStatus;
@SerializedName("jobprocstatus") @Param(description="the progress information of the PENDING job")
private Integer jobProcStatus;
@SerializedName("jobresultcode") @Param(description="the result code for the job")
private Integer jobResultCode;
@SerializedName("jobresulttype") @Param(description="the result type")
private String jobResultType;
@SerializedName("jobresult") @Param(description="the result reason")
private ResponseObject jobResult;
@SerializedName("jobinstancetype") @Param(description="the instance/entity object related to the job")
private String jobInstanceType;
@SerializedName("jobinstanceid") @Param(description="the unique ID of the instance/entity object related to the job")
private IdentityProxy jobInstanceId = new IdentityProxy();
@SerializedName(ApiConstants.CREATED) @Param(description=" the created date of the job")
private Date created;
public void setAccountId(Long accountId) {
this.accountId.setValue(accountId);
}
public void setUserId(Long userId) {
this.userId.setValue(userId);
}
public void setCmd(String cmd) {
this.cmd = cmd;
}
public void setJobStatus(Integer jobStatus) {
this.jobStatus = jobStatus;
}
public void setJobProcStatus(Integer jobProcStatus) {
this.jobProcStatus = jobProcStatus;
}
public void setJobResultCode(Integer jobResultCode) {
this.jobResultCode = jobResultCode;
}
public void setJobResultType(String jobResultType) {
this.jobResultType = jobResultType;
}
public void setJobResult(ResponseObject jobResult) {
this.jobResult = jobResult;
}
public void setJobInstanceType(String jobInstanceType) {
this.jobInstanceType = jobInstanceType;
if(jobInstanceType != null) {
if(jobInstanceType.equalsIgnoreCase(AsyncJob.Type.Volume.toString())) {
this.jobInstanceId.setTableName("volumes");
} else if (jobInstanceType.equalsIgnoreCase(AsyncJob.Type.Template.toString())) {
this.jobInstanceId.setTableName("vm_template");
} else if (jobInstanceType.equalsIgnoreCase(AsyncJob.Type.Iso.toString())) {
this.jobInstanceId.setTableName("vm_template");
} else if (jobInstanceType.equalsIgnoreCase(AsyncJob.Type.VirtualMachine.toString()) || jobInstanceType.equalsIgnoreCase(AsyncJob.Type.ConsoleProxy.toString()) || jobInstanceType.equalsIgnoreCase(AsyncJob.Type.SystemVm.toString()) || jobInstanceType.equalsIgnoreCase(AsyncJob.Type.DomainRouter.toString()) ) {
this.jobInstanceId.setTableName("vm_instance");
} else if (jobInstanceType.equalsIgnoreCase(AsyncJob.Type.Snapshot.toString())) {
this.jobInstanceId.setTableName("snapshots");
} else if (jobInstanceType.equalsIgnoreCase(AsyncJob.Type.Host.toString())) {
this.jobInstanceId.setTableName("host");
} else if (jobInstanceType.equalsIgnoreCase(AsyncJob.Type.StoragePool.toString())) {
this.jobInstanceId.setTableName("storage_pool");
} else if (jobInstanceType.equalsIgnoreCase(AsyncJob.Type.IpAddress.toString())) {
this.jobInstanceId.setTableName("user_ip_address");
} else if (jobInstanceType.equalsIgnoreCase(AsyncJob.Type.SecurityGroup.toString())) {
this.jobInstanceId.setTableName("security_group");
} else if (jobInstanceType.equalsIgnoreCase(AsyncJob.Type.PhysicalNetwork.toString())) {
this.jobInstanceId.setTableName("physical_network");
} else if (jobInstanceType.equalsIgnoreCase(AsyncJob.Type.TrafficType.toString())) {
this.jobInstanceId.setTableName("physical_network_traffic_types");
} else if (jobInstanceType.equalsIgnoreCase(AsyncJob.Type.PhysicalNetworkServiceProvider.toString())) {
this.jobInstanceId.setTableName("physical_network_service_providers");
} else if (jobInstanceType.equalsIgnoreCase(AsyncJob.Type.FirewallRule.toString())) {
this.jobInstanceId.setTableName("firewall_rules");
} else if (jobInstanceType.equalsIgnoreCase(AsyncJob.Type.Account.toString())) {
this.jobInstanceId.setTableName("account");
} else if (jobInstanceType.equalsIgnoreCase(AsyncJob.Type.User.toString())) {
this.jobInstanceId.setTableName("user");
} else if (jobInstanceType.equalsIgnoreCase(AsyncJob.Type.StaticRoute.toString())) {
this.jobInstanceId.setTableName("static_routes");
} else if (jobInstanceType.equalsIgnoreCase(AsyncJob.Type.PrivateGateway.toString())) {
this.jobInstanceId.setTableName("vpc_gateways");
} else if (!jobInstanceType.equalsIgnoreCase(AsyncJob.Type.None.toString())){
// TODO : when we hit here, we need to add instanceType -> UUID entity table mapping
assert(false);
}
}
}
public void setJobInstanceId(Long jobInstanceId) {
this.jobInstanceId.setValue(jobInstanceId);
}
public void setCreated(Date created) {
this.created = created;
}
}