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
4 changes: 4 additions & 0 deletions conf/serviceConfig/volumeSnapshot.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
<serviceId>query</serviceId>
</message>

<message>
<name>org.zstack.header.storage.snapshot.group.APIGetVolumeSnapshotGroupTreeMsg</name>
</message>

<message>
<name>org.zstack.header.vm.devices.APIQueryVmInstanceResourceMetadataArchiveMsg</name>
<serviceId>query</serviceId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.zstack.header.storage.snapshot;

import org.zstack.header.errorcode.ErrorCode;
import org.zstack.header.message.MessageReply;

import java.util.List;
Expand All @@ -10,6 +11,8 @@
public class CreateVolumesSnapshotOverlayInnerReply extends MessageReply {
private List<VolumeSnapshotInventory> inventories;
private List<String> hostBackupFileUuidList;
private List<CreateVolumesSnapshotsJobStruct> failedSnapshotJobs;
private ErrorCode partialError;

public List<VolumeSnapshotInventory> getInventories() {
return inventories;
Expand All @@ -26,4 +29,20 @@ public List<String> getHostBackupFileUuidList() {
public void setHostBackupFileUuidList(List<String> hostBackupFileUuidList) {
this.hostBackupFileUuidList = hostBackupFileUuidList;
}

public List<CreateVolumesSnapshotsJobStruct> getFailedSnapshotJobs() {
return failedSnapshotJobs;
}

public void setFailedSnapshotJobs(List<CreateVolumesSnapshotsJobStruct> failedSnapshotJobs) {
this.failedSnapshotJobs = failedSnapshotJobs;
}

public ErrorCode getPartialError() {
return partialError;
}

public void setPartialError(ErrorCode partialError) {
this.partialError = partialError;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.zstack.header.storage.snapshot;

import org.zstack.header.errorcode.ErrorCode;
import org.zstack.header.message.MessageReply;

import java.util.List;
Expand All @@ -10,6 +11,8 @@
public class CreateVolumesSnapshotReply extends MessageReply {
private List<VolumeSnapshotInventory> inventories;
private List<String> hostBackupFileUuidList;
private List<CreateVolumesSnapshotsJobStruct> failedSnapshotJobs;
private ErrorCode partialError;

public List<VolumeSnapshotInventory> getInventories() {
return inventories;
Expand All @@ -26,4 +29,20 @@ public List<String> getHostBackupFileUuidList() {
public void setHostBackupFileUuidList(List<String> hostBackupFileUuidList) {
this.hostBackupFileUuidList = hostBackupFileUuidList;
}

public List<CreateVolumesSnapshotsJobStruct> getFailedSnapshotJobs() {
return failedSnapshotJobs;
}

public void setFailedSnapshotJobs(List<CreateVolumesSnapshotsJobStruct> failedSnapshotJobs) {
this.failedSnapshotJobs = failedSnapshotJobs;
}

public ErrorCode getPartialError() {
return partialError;
}

public void setPartialError(ErrorCode partialError) {
this.partialError = partialError;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.zstack.header.storage.snapshot.group;

import org.springframework.http.HttpMethod;
import org.zstack.header.message.APIParam;
import org.zstack.header.message.APISyncCallMessage;
import org.zstack.header.rest.RestRequest;
import org.zstack.header.vm.VmInstanceVO;

@RestRequest(
path = "/volume-snapshots/group/trees",
optionalPaths = {"/volume-snapshots/group/trees/{uuid}"},
method = HttpMethod.GET,
responseClass = APIGetVolumeSnapshotGroupTreeReply.class
)
public class APIGetVolumeSnapshotGroupTreeMsg extends APISyncCallMessage {
@APIParam(required = false, resourceType = VmInstanceVO.class)
private String uuid;

@APIParam(required = false, resourceType = VmInstanceVO.class)
private String vmInstanceUuid;

public String getUuid() {
return uuid;
}

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

public String getVmInstanceUuid() {
return vmInstanceUuid;
}

public void setVmInstanceUuid(String vmInstanceUuid) {
this.vmInstanceUuid = vmInstanceUuid;
}

public static APIGetVolumeSnapshotGroupTreeMsg __example__() {
APIGetVolumeSnapshotGroupTreeMsg msg = new APIGetVolumeSnapshotGroupTreeMsg();
msg.setVmInstanceUuid(uuid());
return msg;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.zstack.header.storage.snapshot.group

import org.zstack.header.storage.snapshot.group.APIGetVolumeSnapshotGroupTreeReply

doc {
title "GetVolumeSnapshotGroupTree"

category "snapshot.volume"

desc """查询指定云主机的快照组树"""

rest {
request {
url "GET /v1/volume-snapshots/group/trees"
url "GET /v1/volume-snapshots/group/trees/{uuid}"

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

clz APIGetVolumeSnapshotGroupTreeMsg.class

desc """"""

params APIGetVolumeSnapshotGroupTreeMsg.class
}

response {
clz APIGetVolumeSnapshotGroupTreeReply.class
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.zstack.header.storage.snapshot.group;

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

import java.sql.Timestamp;
import java.util.Collections;
import java.util.List;

@RestResponse(allTo = "inventories")
public class APIGetVolumeSnapshotGroupTreeReply extends APIReply {
private List<VolumeSnapshotGroupTreeInventory> inventories;

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

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

public static APIGetVolumeSnapshotGroupTreeReply __example__() {
VolumeSnapshotGroupTreeInventory inv = new VolumeSnapshotGroupTreeInventory();
inv.setUuid(uuid());
inv.setName("group");
inv.setVmInstanceUuid(uuid());
inv.setCurrent(true);
inv.setCreateDate(new Timestamp(org.zstack.header.message.DocUtils.date));
inv.setLastOpDate(new Timestamp(org.zstack.header.message.DocUtils.date));

APIGetVolumeSnapshotGroupTreeReply reply = new APIGetVolumeSnapshotGroupTreeReply();
reply.setInventories(Collections.singletonList(inv));
return reply;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.zstack.header.storage.snapshot.group

import org.zstack.header.errorcode.ErrorCode

doc {
title "快照组树清单"

field {
name "success"
desc ""
type "boolean"
since "0.6"
}
ref {
name "error"
path "org.zstack.header.storage.snapshot.group.APIGetVolumeSnapshotGroupTreeReply.error"
desc "错误码,若不为null,则表示操作失败, 操作成功时该字段为null",false
type "ErrorCode"
since "0.6"
clz ErrorCode.class
}
ref {
name "inventories"
path "org.zstack.header.storage.snapshot.group.APIGetVolumeSnapshotGroupTreeReply.inventories"
desc "指定云主机的快照组树清单"
type "List"
since "5.0"
clz VolumeSnapshotGroupTreeInventory.class
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
package org.zstack.header.storage.snapshot.group;

import org.zstack.header.query.Unqueryable;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

public class VolumeSnapshotGroupTreeInventory {
private String uuid;
private String name;
private String description;
private String vmInstanceUuid;
private Timestamp createDate;
private Timestamp lastOpDate;
@Unqueryable
private boolean current;
@Unqueryable
private boolean incomplete;
@Unqueryable
private String parentGroupUuid;
@Unqueryable
private List<VolumeSnapshotGroupTreeInventory> children = new ArrayList<>();
@Unqueryable
private List<VolumeSnapshotGroupTreeRefInventory> refs = new ArrayList<>();

public static VolumeSnapshotGroupTreeInventory valueOf(VolumeSnapshotGroupVO vo) {
VolumeSnapshotGroupTreeInventory inv = new VolumeSnapshotGroupTreeInventory();
inv.setUuid(vo.getUuid());
inv.setName(vo.getName());
inv.setDescription(vo.getDescription());
inv.setVmInstanceUuid(vo.getVmInstanceUuid());
inv.setCreateDate(vo.getCreateDate());
inv.setLastOpDate(vo.getLastOpDate());
return inv;
}

public static List<VolumeSnapshotGroupTreeInventory> valueOf(Collection<VolumeSnapshotGroupVO> vos) {
return vos.stream().map(VolumeSnapshotGroupTreeInventory::valueOf).collect(Collectors.toList());
}

public String getUuid() {
return uuid;
}

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

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public String getVmInstanceUuid() {
return vmInstanceUuid;
}

public void setVmInstanceUuid(String vmInstanceUuid) {
this.vmInstanceUuid = vmInstanceUuid;
}

public Timestamp getCreateDate() {
return createDate;
}

public void setCreateDate(Timestamp createDate) {
this.createDate = createDate;
}

public Timestamp getLastOpDate() {
return lastOpDate;
}

public void setLastOpDate(Timestamp lastOpDate) {
this.lastOpDate = lastOpDate;
}

public boolean isCurrent() {
return current;
}

public void setCurrent(boolean current) {
this.current = current;
}

public boolean isIncomplete() {
return incomplete;
}

public void setIncomplete(boolean incomplete) {
this.incomplete = incomplete;
}

public String getParentGroupUuid() {
return parentGroupUuid;
}

public void setParentGroupUuid(String parentGroupUuid) {
this.parentGroupUuid = parentGroupUuid;
}

public List<VolumeSnapshotGroupTreeInventory> getChildren() {
return children;
}

public void setChildren(List<VolumeSnapshotGroupTreeInventory> children) {
this.children = children;
}

public List<VolumeSnapshotGroupTreeRefInventory> getRefs() {
return refs;
}

public void setRefs(List<VolumeSnapshotGroupTreeRefInventory> refs) {
this.refs = refs;
}
}
Loading