forked from zstackio/zstack
-
Notifications
You must be signed in to change notification settings - Fork 0
<feature>[storage]: register and take over sblk #3539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
ZStack-Robot
wants to merge
1
commit into
feature-zsv-5.0.0-vm-registration
from
sync/tao.gan/sblk-ZSV-10000@@3
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...src/main/java/org/zstack/header/storage/primary/APICheckPrimaryStorageConsistencyMsg.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package org.zstack.header.storage.primary; | ||
|
|
||
| import org.springframework.http.HttpMethod; | ||
| import org.zstack.header.message.APISyncCallMessage; | ||
| import org.zstack.header.message.APIParam; | ||
| import org.zstack.header.rest.RestRequest; | ||
|
|
||
| @RestRequest( | ||
| path = "/primary-storage/{uuid}/consistency", | ||
| responseClass = APICheckPrimaryStorageConsistencyReply.class, | ||
| method = HttpMethod.GET | ||
| ) | ||
| public class APICheckPrimaryStorageConsistencyMsg extends APISyncCallMessage implements PrimaryStorageMessage { | ||
| @APIParam(resourceType = PrimaryStorageVO.class) | ||
| private String uuid; | ||
|
|
||
| @Override | ||
| public String getPrimaryStorageUuid() { | ||
| return uuid; | ||
| } | ||
|
|
||
| public String getUuid() { | ||
| return uuid; | ||
| } | ||
|
|
||
| public void setUuid(String uuid) { | ||
| this.uuid = uuid; | ||
| } | ||
|
|
||
| public static APICheckPrimaryStorageConsistencyMsg __example__() { | ||
| APICheckPrimaryStorageConsistencyMsg msg = new APICheckPrimaryStorageConsistencyMsg(); | ||
| msg.setUuid(uuid(PrimaryStorageVO.class)); | ||
| return msg; | ||
| } | ||
| } | ||
58 changes: 58 additions & 0 deletions
58
...va/org/zstack/header/storage/primary/APICheckPrimaryStorageConsistencyMsgDoc_zh_cn.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package org.zstack.header.storage.primary | ||
|
|
||
| import org.zstack.header.storage.primary.APICheckPrimaryStorageConsistencyReply | ||
|
|
||
| doc { | ||
| title "CheckPrimaryStorageConsistency" | ||
|
|
||
| category "storage.primary" | ||
|
|
||
| desc """检查存储一致性""" | ||
|
|
||
| rest { | ||
| request { | ||
| url "GET /v1/primary-storage/{uuid}/consistency" | ||
|
|
||
| header (Authorization: 'OAuth the-session-uuid') | ||
|
|
||
| clz APICheckPrimaryStorageConsistencyMsg.class | ||
|
|
||
| desc """检查指定主存储的一致性状态""" | ||
|
|
||
| params { | ||
|
|
||
| column { | ||
| name "uuid" | ||
| enclosedIn "" | ||
| desc "主存储的UUID" | ||
| location "url" | ||
| type "String" | ||
| optional false | ||
| since "5.0.0" | ||
| } | ||
| column { | ||
| name "systemTags" | ||
| enclosedIn "" | ||
| desc "系统标签" | ||
| location "query" | ||
| type "List" | ||
| optional true | ||
| since "5.0.0" | ||
| } | ||
| column { | ||
| name "userTags" | ||
| enclosedIn "" | ||
| desc "用户标签" | ||
| location "query" | ||
| type "List" | ||
| optional true | ||
| since "5.0.0" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| response { | ||
| clz APICheckPrimaryStorageConsistencyReply.class | ||
| } | ||
| } | ||
| } |
42 changes: 42 additions & 0 deletions
42
...c/main/java/org/zstack/header/storage/primary/APICheckPrimaryStorageConsistencyReply.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package org.zstack.header.storage.primary; | ||
|
|
||
| import org.zstack.header.message.APIReply; | ||
| import org.zstack.header.rest.RestResponse; | ||
|
|
||
| @RestResponse(fieldsTo = {"all"}) | ||
| public class APICheckPrimaryStorageConsistencyReply extends APIReply { | ||
| private boolean consistent; | ||
| private ConsistencyCheckReason reason; | ||
| private String candidateVgUuid; | ||
|
|
||
| public boolean isConsistent() { | ||
| return consistent; | ||
| } | ||
|
|
||
| public void setConsistent(boolean consistent) { | ||
| this.consistent = consistent; | ||
| } | ||
|
|
||
| public ConsistencyCheckReason getReason() { | ||
| return reason; | ||
| } | ||
|
|
||
| public void setReason(ConsistencyCheckReason reason) { | ||
| this.reason = reason; | ||
| } | ||
|
|
||
| public String getCandidateVgUuid() { | ||
| return candidateVgUuid; | ||
| } | ||
|
|
||
| public void setCandidateVgUuid(String candidateVgUuid) { | ||
| this.candidateVgUuid = candidateVgUuid; | ||
| } | ||
|
|
||
| public static APICheckPrimaryStorageConsistencyReply __example__() { | ||
| APICheckPrimaryStorageConsistencyReply reply = new APICheckPrimaryStorageConsistencyReply(); | ||
| reply.setConsistent(true); | ||
| reply.setReason(ConsistencyCheckReason.CONSISTENT); | ||
| return reply; | ||
| } | ||
| } |
41 changes: 41 additions & 0 deletions
41
.../org/zstack/header/storage/primary/APICheckPrimaryStorageConsistencyReplyDoc_zh_cn.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package org.zstack.header.storage.primary | ||
|
|
||
| import org.zstack.header.errorcode.ErrorCode | ||
|
|
||
| doc { | ||
|
|
||
| title "检查存储一致性返回" | ||
|
|
||
| field { | ||
| name "consistent" | ||
| desc "是否一致" | ||
| type "boolean" | ||
| since "5.0.0" | ||
| } | ||
| field { | ||
| name "reason" | ||
| desc "一致性检查结果原因: CONSISTENT(VG 存在且 UUID 一致)/ UUID_MISMATCH(VG 存在但 UUID 不一致,可执行接管)/ VG_NOT_FOUND(未找到 WWID 匹配的 VG)" | ||
| type "ConsistencyCheckReason" | ||
| since "5.0.0" | ||
| } | ||
| field { | ||
| name "candidateVgUuid" | ||
| desc "reason 为 UUID_MISMATCH 时,存储上实际找到的 VG UUID(即接管候选);其他情况为 null" | ||
| type "String" | ||
| since "5.0.0" | ||
| } | ||
| field { | ||
| name "success" | ||
| desc "操作是否成功" | ||
| type "boolean" | ||
| since "5.0.0" | ||
| } | ||
| ref { | ||
| name "error" | ||
| path "org.zstack.header.storage.primary.APICheckPrimaryStorageConsistencyReply.error" | ||
| desc "错误码,若不为null,则表示操作失败, 操作成功时该字段为null" | ||
| type "ErrorCode" | ||
| since "5.0.0" | ||
| clz ErrorCode.class | ||
| } | ||
| } |
60 changes: 60 additions & 0 deletions
60
header/src/main/java/org/zstack/header/storage/primary/APITakeoverPrimaryStorageEvent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| package org.zstack.header.storage.primary; | ||
|
|
||
| import org.zstack.header.message.APIEvent; | ||
| import org.zstack.header.rest.RestResponse; | ||
|
|
||
| import java.util.Collections; | ||
|
|
||
| @RestResponse(fieldsTo = {"all"}) | ||
| public class APITakeoverPrimaryStorageEvent extends APIEvent { | ||
| private PrimaryStorageInventory inventory; | ||
|
|
||
| private ReconnectResult reconnectResult; | ||
|
|
||
| private String reconnectError; | ||
|
|
||
| public APITakeoverPrimaryStorageEvent() { | ||
| } | ||
|
|
||
| public APITakeoverPrimaryStorageEvent(String apiId) { | ||
| super(apiId); | ||
| } | ||
|
|
||
| public PrimaryStorageInventory getInventory() { | ||
| return inventory; | ||
| } | ||
|
|
||
| public void setInventory(PrimaryStorageInventory inventory) { | ||
| this.inventory = inventory; | ||
| } | ||
|
|
||
| public ReconnectResult getReconnectResult() { | ||
| return reconnectResult; | ||
| } | ||
|
|
||
| public void setReconnectResult(ReconnectResult reconnectResult) { | ||
| this.reconnectResult = reconnectResult; | ||
| } | ||
|
|
||
| public String getReconnectError() { | ||
| return reconnectError; | ||
| } | ||
|
|
||
| public void setReconnectError(String reconnectError) { | ||
| this.reconnectError = reconnectError; | ||
| } | ||
|
|
||
| public static APITakeoverPrimaryStorageEvent __example__() { | ||
| APITakeoverPrimaryStorageEvent event = new APITakeoverPrimaryStorageEvent(); | ||
|
|
||
| PrimaryStorageInventory ps = new PrimaryStorageInventory(); | ||
| ps.setName("PS1"); | ||
| ps.setUrl("/zstack_ps"); | ||
| ps.setType("SharedBlock"); | ||
| ps.setAttachedClusterUuids(Collections.singletonList(uuid())); | ||
|
|
||
| event.setInventory(ps); | ||
| event.setReconnectResult(ReconnectResult.SUCCESS); | ||
| return event; | ||
| } | ||
| } |
44 changes: 44 additions & 0 deletions
44
...ain/java/org/zstack/header/storage/primary/APITakeoverPrimaryStorageEventDoc_zh_cn.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package org.zstack.header.storage.primary | ||
|
|
||
| import org.zstack.header.storage.primary.PrimaryStorageInventory | ||
| import org.zstack.header.errorcode.ErrorCode | ||
|
|
||
| doc { | ||
|
|
||
| title "接管主存储返回" | ||
|
|
||
| ref { | ||
| name "inventory" | ||
| path "org.zstack.header.storage.primary.APITakeoverPrimaryStorageEvent.inventory" | ||
| desc "主存储信息" | ||
| type "PrimaryStorageInventory" | ||
| since "5.0.0" | ||
| clz PrimaryStorageInventory.class | ||
| } | ||
| field { | ||
| name "success" | ||
| desc "操作是否成功" | ||
| type "boolean" | ||
| since "5.0.0" | ||
| } | ||
| ref { | ||
| name "error" | ||
| path "org.zstack.header.storage.primary.APITakeoverPrimaryStorageEvent.error" | ||
| desc "错误码,若不为null,则表示操作失败, 操作成功时该字段为null" | ||
| type "ErrorCode" | ||
| since "5.0.0" | ||
| clz ErrorCode.class | ||
| } | ||
| field { | ||
| name "reconnectResult" | ||
| desc "接管后重连结果,取值参见 ReconnectResult 枚举: SUCCESS(重连成功)/ FAILED(重连失败,但接管已完成且不可逆)/ NOT_ATTEMPTED(未尝试重连)" | ||
| type "ReconnectResult" | ||
| since "5.0.0" | ||
| } | ||
| field { | ||
| name "reconnectError" | ||
| desc "重连失败时的错误信息" | ||
| type "String" | ||
| since "5.0.0" | ||
| } | ||
| } |
40 changes: 40 additions & 0 deletions
40
header/src/main/java/org/zstack/header/storage/primary/APITakeoverPrimaryStorageMsg.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| package org.zstack.header.storage.primary; | ||
|
|
||
| import org.springframework.http.HttpMethod; | ||
| import org.zstack.header.message.APIMessage; | ||
| import org.zstack.header.message.APIParam; | ||
| import org.zstack.header.message.DefaultTimeout; | ||
| import org.zstack.header.rest.RestRequest; | ||
|
|
||
| import java.util.concurrent.TimeUnit; | ||
|
|
||
| @RestRequest( | ||
| path = "/primary-storage/{uuid}/takeover", | ||
| responseClass = APITakeoverPrimaryStorageEvent.class, | ||
| method = HttpMethod.PUT, | ||
| isAction = true | ||
| ) | ||
| @DefaultTimeout(timeunit = TimeUnit.HOURS, value = 1) | ||
| public class APITakeoverPrimaryStorageMsg extends APIMessage implements PrimaryStorageMessage { | ||
| @APIParam(resourceType = PrimaryStorageVO.class) | ||
| private String uuid; | ||
|
|
||
| @Override | ||
| public String getPrimaryStorageUuid() { | ||
| return uuid; | ||
| } | ||
|
|
||
| public String getUuid() { | ||
| return uuid; | ||
| } | ||
|
|
||
| public void setUuid(String uuid) { | ||
| this.uuid = uuid; | ||
| } | ||
|
|
||
| public static APITakeoverPrimaryStorageMsg __example__() { | ||
| APITakeoverPrimaryStorageMsg msg = new APITakeoverPrimaryStorageMsg(); | ||
| msg.setUuid(uuid(PrimaryStorageVO.class)); | ||
| return msg; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
缺少权限注解,存在授权边界过宽风险。
Line 13 的 API 消息未声明权限控制(如管理员级别)。该接口与接管流程直接相关,建议在消息类上显式增加权限注解,避免普通租户可调用。
🤖 Prompt for AI Agents