Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions conf/serviceConfig/primaryStorage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,16 @@
<message>
<name>org.zstack.header.storage.primary.APICleanUpStorageTrashOnPrimaryStorageMsg</name>
</message>

<message>
<name>org.zstack.header.storage.primary.APIAddStorageProtocolMsg</name>
</message>

<message>
<name>org.zstack.header.storage.primary.APICheckPrimaryStorageConsistencyMsg</name>
</message>

<message>
<name>org.zstack.header.storage.primary.APITakeoverPrimaryStorageMsg</name>
</message>
</service>
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;
}
}
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
}
}
}
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;
}
}
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
}
}
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;
}
}
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"
}
}
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;
}
}
Loading