Skip to content
Merged
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.APITakeoverPrimaryStorageMsg</name>
</message>

<message>
<name>org.zstack.header.storage.primary.APIDiscoverStrangePrimaryStorageMsg</name>
</message>
</service>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.zstack.header.storage.primary;

import org.springframework.http.HttpMethod;
import org.zstack.header.cluster.ClusterVO;
import org.zstack.header.message.APIParam;
import org.zstack.header.message.APISyncCallMessage;
import org.zstack.header.rest.RestRequest;

@RestRequest(
path = "/primary-storage/stranger",
method = HttpMethod.GET,
responseClass = APIDiscoverStrangePrimaryStorageReply.class
)
public class APIDiscoverStrangePrimaryStorageMsg extends APISyncCallMessage {
@APIParam(resourceType = ClusterVO.class)
private String clusterUuid;

public String getClusterUuid() {
return clusterUuid;
}

public void setClusterUuid(String clusterUuid) {
this.clusterUuid = clusterUuid;
}

public static APIDiscoverStrangePrimaryStorageMsg __example__() {
APIDiscoverStrangePrimaryStorageMsg msg = new APIDiscoverStrangePrimaryStorageMsg();
msg.setClusterUuid(uuid());
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.APIDiscoverStrangePrimaryStorageReply

doc {
title "DiscoverStrangePrimaryStorage"

category "storage.primary"

desc """发现集群物理机上未受当前平台管控的主存储"""

rest {
request {
url "GET /v1/primary-storage/stranger"

header (Authorization: 'OAuth the-session-uuid')

clz APIDiscoverStrangePrimaryStorageMsg.class

desc """"""

params {

column {
name "clusterUuid"
enclosedIn ""
desc "集群UUID"
location "query"
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 APIDiscoverStrangePrimaryStorageReply.class
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.zstack.header.storage.primary;

import org.zstack.header.message.APIReply;
import org.zstack.header.rest.RestResponse;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@RestResponse(fieldsTo = {"all"})
public class APIDiscoverStrangePrimaryStorageReply extends APIReply {
private List<PrimaryStorageInventory> inventories = new ArrayList<>();

public List<PrimaryStorageInventory> getInventories() {
return inventories;
}

public void setInventories(List<PrimaryStorageInventory> inventories) {
this.inventories = inventories;
}

public static APIDiscoverStrangePrimaryStorageReply __example__() {
APIDiscoverStrangePrimaryStorageReply reply = new APIDiscoverStrangePrimaryStorageReply();

PrimaryStorageInventory ps = new PrimaryStorageInventory();
ps.setName("SharedBlockGroup-1");
ps.setUrl("/dev/vg_uuid");
ps.setType("SharedBlock");
ps.setAttachedClusterUuids(Collections.singletonList(uuid()));
reply.setInventories(Collections.singletonList(ps));

return reply;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.zstack.header.storage.primary

import org.zstack.header.errorcode.ErrorCode

doc {

title "发现集群物理机上未受当前平台管控的主存储返回"

field {
name "inventories"
desc "发现的主存储清单列表"
type "List"
since "5.0.0"
}
field {
name "success"
desc "操作是否成功"
type "boolean"
since "5.0.0"
}
ref {
name "error"
path "org.zstack.header.storage.primary.APIDiscoverStrangePrimaryStorageReply.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,39 @@
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;

public APITakeoverPrimaryStorageEvent() {
}

public APITakeoverPrimaryStorageEvent(String apiId) {
super(apiId);
}

public PrimaryStorageInventory getInventory() {
return inventory;
}

public void setInventory(PrimaryStorageInventory inventory) {
this.inventory = inventory;
}

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);
return event;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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;

@APIParam(required = false)
private boolean dryRun;

@Override
public String getPrimaryStorageUuid() {
return uuid;
}

public String getUuid() {
return uuid;
}

public void setUuid(String uuid) {
this.uuid = uuid;
}

public boolean isDryRun() {
return dryRun;
}

public void setDryRun(boolean dryRun) {
this.dryRun = dryRun;
}

public static APITakeoverPrimaryStorageMsg __example__() {
APITakeoverPrimaryStorageMsg msg = new APITakeoverPrimaryStorageMsg();
msg.setUuid(uuid(PrimaryStorageVO.class));
msg.setDryRun(false);
return msg;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package org.zstack.header.storage.primary

import org.zstack.header.storage.primary.APITakeoverPrimaryStorageEvent

doc {
title "TakeoverPrimaryStorage"

category "storage.primary"

desc """接管主存储。将其他ZStack平台的共享块主存储接管到当前平台。
dryRun=true时仅执行一致性预检:若一致(无需接管)则返回错误,若不一致(可接管)则返回成功。
接管操作不可逆(agent侧会执行VG rename、PV UUID reset、sanlock lockspace reset)。
接管完成后自动触发reconnect,通过返回的inventory.status获取重连状态。"""

rest {
request {
url "PUT /v1/primary-storage/{uuid}/takeover"

header (Authorization: 'OAuth the-session-uuid')

clz APITakeoverPrimaryStorageMsg.class

desc """接管指定主存储"""

params {

column {
name "uuid"
enclosedIn "takeoverPrimaryStorage"
desc "主存储的UUID"
location "url"
type "String"
optional false
since "5.0.0"
}
column {
name "dryRun"
enclosedIn "takeoverPrimaryStorage"
desc "预检模式:成功表示可以执行接管,失败表示无需或无法接管"
location "body"
type "boolean"
optional true
since "5.0.0"
}
column {
name "systemTags"
enclosedIn ""
desc "系统标签"
location "body"
type "List"
optional true
since "5.0.0"
}
column {
name "userTags"
enclosedIn ""
desc "用户标签"
location "body"
type "List"
optional true
since "5.0.0"
}
}
}

response {
clz APITakeoverPrimaryStorageEvent.class
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.zstack.header.storage.primary;

import org.zstack.header.core.ReturnValueCompletion;

import java.util.List;

/**
* Extension point for discovering unmanaged (strange) primary storage.
* Each primary storage type can implement this to discover its own PS instances
* that exist on hosts but are not managed by the platform.
*/
public interface PrimaryStorageDiscoverExtensionPoint {
void discoverStrangePrimaryStorage(String clusterUuid, ReturnValueCompletion<List<PrimaryStorageInventory>> completion);
}
Loading