Skip to content

Commit 553110c

Browse files
author
gitlab
committed
Merge branch 'sblk-ZSV-11559@@3' into 'feature-zsv-5.0.0-vm-support-vtpm-and-secuceboot'
<feature>[storage]: register and take over sblk See merge request zstackio/zstack!9432
2 parents a9e42f7 + e593470 commit 553110c

23 files changed

Lines changed: 921 additions & 0 deletions

conf/serviceConfig/primaryStorage.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,16 @@
8181
<message>
8282
<name>org.zstack.header.storage.primary.APICleanUpStorageTrashOnPrimaryStorageMsg</name>
8383
</message>
84+
8485
<message>
8586
<name>org.zstack.header.storage.primary.APIAddStorageProtocolMsg</name>
8687
</message>
88+
89+
<message>
90+
<name>org.zstack.header.storage.primary.APICheckPrimaryStorageConsistencyMsg</name>
91+
</message>
92+
93+
<message>
94+
<name>org.zstack.header.storage.primary.APITakeoverPrimaryStorageMsg</name>
95+
</message>
8796
</service>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package org.zstack.header.storage.primary;
2+
3+
import org.springframework.http.HttpMethod;
4+
import org.zstack.header.message.APISyncCallMessage;
5+
import org.zstack.header.message.APIParam;
6+
import org.zstack.header.rest.RestRequest;
7+
8+
@RestRequest(
9+
path = "/primary-storage/{uuid}/consistency",
10+
responseClass = APICheckPrimaryStorageConsistencyReply.class,
11+
method = HttpMethod.GET
12+
)
13+
public class APICheckPrimaryStorageConsistencyMsg extends APISyncCallMessage implements PrimaryStorageMessage {
14+
@APIParam(resourceType = PrimaryStorageVO.class)
15+
private String uuid;
16+
17+
@Override
18+
public String getPrimaryStorageUuid() {
19+
return uuid;
20+
}
21+
22+
public String getUuid() {
23+
return uuid;
24+
}
25+
26+
public void setUuid(String uuid) {
27+
this.uuid = uuid;
28+
}
29+
30+
public static APICheckPrimaryStorageConsistencyMsg __example__() {
31+
APICheckPrimaryStorageConsistencyMsg msg = new APICheckPrimaryStorageConsistencyMsg();
32+
msg.setUuid(uuid(PrimaryStorageVO.class));
33+
return msg;
34+
}
35+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package org.zstack.header.storage.primary
2+
3+
import org.zstack.header.storage.primary.APICheckPrimaryStorageConsistencyReply
4+
5+
doc {
6+
title "CheckPrimaryStorageConsistency"
7+
8+
category "storage.primary"
9+
10+
desc """检查存储一致性"""
11+
12+
rest {
13+
request {
14+
url "GET /v1/primary-storage/{uuid}/consistency"
15+
16+
header (Authorization: 'OAuth the-session-uuid')
17+
18+
clz APICheckPrimaryStorageConsistencyMsg.class
19+
20+
desc """检查指定主存储的一致性状态"""
21+
22+
params {
23+
24+
column {
25+
name "uuid"
26+
enclosedIn ""
27+
desc "主存储的UUID"
28+
location "url"
29+
type "String"
30+
optional false
31+
since "5.0.0"
32+
}
33+
column {
34+
name "systemTags"
35+
enclosedIn ""
36+
desc "系统标签"
37+
location "query"
38+
type "List"
39+
optional true
40+
since "5.0.0"
41+
}
42+
column {
43+
name "userTags"
44+
enclosedIn ""
45+
desc "用户标签"
46+
location "query"
47+
type "List"
48+
optional true
49+
since "5.0.0"
50+
}
51+
}
52+
}
53+
54+
response {
55+
clz APICheckPrimaryStorageConsistencyReply.class
56+
}
57+
}
58+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package org.zstack.header.storage.primary;
2+
3+
import org.zstack.header.message.APIReply;
4+
import org.zstack.header.rest.RestResponse;
5+
6+
@RestResponse(fieldsTo = {"all"})
7+
public class APICheckPrimaryStorageConsistencyReply extends APIReply {
8+
private boolean consistent;
9+
private ConsistencyCheckStatus status;
10+
private String candidateVgUuid;
11+
12+
public boolean isConsistent() {
13+
return consistent;
14+
}
15+
16+
public void setConsistent(boolean consistent) {
17+
this.consistent = consistent;
18+
}
19+
20+
public ConsistencyCheckStatus getStatus() {
21+
return status;
22+
}
23+
24+
public void setStatus(ConsistencyCheckStatus status) {
25+
this.status = status;
26+
}
27+
28+
public String getCandidateVgUuid() {
29+
return candidateVgUuid;
30+
}
31+
32+
public void setCandidateVgUuid(String candidateVgUuid) {
33+
this.candidateVgUuid = candidateVgUuid;
34+
}
35+
36+
public static APICheckPrimaryStorageConsistencyReply __example__() {
37+
APICheckPrimaryStorageConsistencyReply reply = new APICheckPrimaryStorageConsistencyReply();
38+
reply.setConsistent(true);
39+
reply.setStatus(ConsistencyCheckStatus.CONSISTENT);
40+
return reply;
41+
}
42+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package org.zstack.header.storage.primary
2+
3+
import org.zstack.header.errorcode.ErrorCode
4+
5+
doc {
6+
7+
title "检查存储一致性返回"
8+
9+
field {
10+
name "consistent"
11+
desc "是否一致"
12+
type "boolean"
13+
since "5.0.0"
14+
}
15+
field {
16+
name "status"
17+
desc "一致性检查结果: CONSISTENT(VG 存在且 UUID 一致)/ UUID_MISMATCH(VG 存在但 UUID 不一致,可执行接管)/ VG_NOT_FOUND(未找到 WWID 匹配的 VG)"
18+
type "ConsistencyCheckStatus"
19+
since "5.0.0"
20+
}
21+
field {
22+
name "candidateVgUuid"
23+
desc "status 为 UUID_MISMATCH 时,存储上实际找到的 VG UUID(即接管候选);其他情况为 null"
24+
type "String"
25+
since "5.0.0"
26+
}
27+
field {
28+
name "success"
29+
desc "操作是否成功"
30+
type "boolean"
31+
since "5.0.0"
32+
}
33+
ref {
34+
name "error"
35+
path "org.zstack.header.storage.primary.APICheckPrimaryStorageConsistencyReply.error"
36+
desc "错误码,若不为null,则表示操作失败, 操作成功时该字段为null"
37+
type "ErrorCode"
38+
since "5.0.0"
39+
clz ErrorCode.class
40+
}
41+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package org.zstack.header.storage.primary;
2+
3+
import org.zstack.header.message.APIEvent;
4+
import org.zstack.header.rest.RestResponse;
5+
6+
import java.util.Collections;
7+
8+
@RestResponse(fieldsTo = {"all"})
9+
public class APITakeoverPrimaryStorageEvent extends APIEvent {
10+
private PrimaryStorageInventory inventory;
11+
12+
private ReconnectResult reconnectResult;
13+
14+
private String reconnectError;
15+
16+
public APITakeoverPrimaryStorageEvent() {
17+
}
18+
19+
public APITakeoverPrimaryStorageEvent(String apiId) {
20+
super(apiId);
21+
}
22+
23+
public PrimaryStorageInventory getInventory() {
24+
return inventory;
25+
}
26+
27+
public void setInventory(PrimaryStorageInventory inventory) {
28+
this.inventory = inventory;
29+
}
30+
31+
public ReconnectResult getReconnectResult() {
32+
return reconnectResult;
33+
}
34+
35+
public void setReconnectResult(ReconnectResult reconnectResult) {
36+
this.reconnectResult = reconnectResult;
37+
}
38+
39+
public String getReconnectError() {
40+
return reconnectError;
41+
}
42+
43+
public void setReconnectError(String reconnectError) {
44+
this.reconnectError = reconnectError;
45+
}
46+
47+
public static APITakeoverPrimaryStorageEvent __example__() {
48+
APITakeoverPrimaryStorageEvent event = new APITakeoverPrimaryStorageEvent();
49+
50+
PrimaryStorageInventory ps = new PrimaryStorageInventory();
51+
ps.setName("PS1");
52+
ps.setUrl("/zstack_ps");
53+
ps.setType("SharedBlock");
54+
ps.setAttachedClusterUuids(Collections.singletonList(uuid()));
55+
56+
event.setInventory(ps);
57+
event.setReconnectResult(ReconnectResult.SUCCESS);
58+
return event;
59+
}
60+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package org.zstack.header.storage.primary
2+
3+
import org.zstack.header.storage.primary.PrimaryStorageInventory
4+
import org.zstack.header.errorcode.ErrorCode
5+
6+
doc {
7+
8+
title "接管主存储返回"
9+
10+
ref {
11+
name "inventory"
12+
path "org.zstack.header.storage.primary.APITakeoverPrimaryStorageEvent.inventory"
13+
desc "主存储信息"
14+
type "PrimaryStorageInventory"
15+
since "5.0.0"
16+
clz PrimaryStorageInventory.class
17+
}
18+
field {
19+
name "success"
20+
desc "操作是否成功"
21+
type "boolean"
22+
since "5.0.0"
23+
}
24+
ref {
25+
name "error"
26+
path "org.zstack.header.storage.primary.APITakeoverPrimaryStorageEvent.error"
27+
desc "错误码,若不为null,则表示操作失败, 操作成功时该字段为null"
28+
type "ErrorCode"
29+
since "5.0.0"
30+
clz ErrorCode.class
31+
}
32+
field {
33+
name "reconnectResult"
34+
desc "接管后重连结果,取值参见 ReconnectResult 枚举: SUCCESS(重连成功)/ FAILED(重连失败,但接管已完成且不可逆)/ NOT_ATTEMPTED(未尝试重连)"
35+
type "ReconnectResult"
36+
since "5.0.0"
37+
}
38+
field {
39+
name "reconnectError"
40+
desc "重连失败时的错误信息"
41+
type "String"
42+
since "5.0.0"
43+
}
44+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.zstack.header.storage.primary;
2+
3+
import org.springframework.http.HttpMethod;
4+
import org.zstack.header.message.APIMessage;
5+
import org.zstack.header.message.APIParam;
6+
import org.zstack.header.message.DefaultTimeout;
7+
import org.zstack.header.rest.RestRequest;
8+
9+
import java.util.concurrent.TimeUnit;
10+
11+
@RestRequest(
12+
path = "/primary-storage/{uuid}/takeover",
13+
responseClass = APITakeoverPrimaryStorageEvent.class,
14+
method = HttpMethod.PUT,
15+
isAction = true
16+
)
17+
@DefaultTimeout(timeunit = TimeUnit.HOURS, value = 1)
18+
public class APITakeoverPrimaryStorageMsg extends APIMessage implements PrimaryStorageMessage {
19+
@APIParam(resourceType = PrimaryStorageVO.class)
20+
private String uuid;
21+
22+
@Override
23+
public String getPrimaryStorageUuid() {
24+
return uuid;
25+
}
26+
27+
public String getUuid() {
28+
return uuid;
29+
}
30+
31+
public void setUuid(String uuid) {
32+
this.uuid = uuid;
33+
}
34+
35+
public static APITakeoverPrimaryStorageMsg __example__() {
36+
APITakeoverPrimaryStorageMsg msg = new APITakeoverPrimaryStorageMsg();
37+
msg.setUuid(uuid(PrimaryStorageVO.class));
38+
return msg;
39+
}
40+
}

0 commit comments

Comments
 (0)