mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
feat(region,climc): support disk-rebuild
This commit is contained in:
@@ -42,6 +42,7 @@ import (
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.Disks)
|
||||
cmd.Perform("set-class-metadata", &options.ResourceMetadataOptions{})
|
||||
cmd.Perform("rebuild", &options.ResourceIdOptions{})
|
||||
|
||||
type DiskListOptions struct {
|
||||
options.BaseListOptions
|
||||
|
||||
@@ -327,3 +327,5 @@ type DiskResetInput struct {
|
||||
type DiskSnapshotpolicyInput struct {
|
||||
SnapshotpolicyId string `json:"snapshotpolicy_id"`
|
||||
}
|
||||
|
||||
type DiskRebuildInput struct{}
|
||||
|
||||
@@ -2985,3 +2985,18 @@ func (manager *SDiskManager) ListItemExportKeys(ctx context.Context,
|
||||
}
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (disk *SDisk) PerformRebuild(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
query jsonutils.JSONObject,
|
||||
input *api.DiskRebuildInput,
|
||||
) (jsonutils.JSONObject, error) {
|
||||
guests := disk.GetGuests()
|
||||
for _, guest := range guests {
|
||||
if guest.GetStatus() != api.VM_READY {
|
||||
return nil, httperrors.NewInvalidStatusError("Guest %s status is %s", guest.GetId(), guest.GetStatus())
|
||||
}
|
||||
}
|
||||
return nil, disk.StartDiskCreateTask(ctx, userCred, true, disk.SnapshotId, "")
|
||||
}
|
||||
|
||||
@@ -130,6 +130,13 @@ func (self *DiskCreateTask) OnDiskReady(ctx context.Context, disk *models.SDisk,
|
||||
Obj: disk,
|
||||
Action: notifyclient.ActionCreate,
|
||||
})
|
||||
if !self.IsSubtask() {
|
||||
guest := disk.GetGuest()
|
||||
if guest != nil {
|
||||
// just sync guest status
|
||||
guest.StartSyncstatus(ctx, self.GetUserCred(), "")
|
||||
}
|
||||
}
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
|
||||
|
||||
@@ -129,6 +129,18 @@ func (opts *DomainTagValueTreeOptions) Property() string {
|
||||
return "domain-tag-value-tree"
|
||||
}
|
||||
|
||||
type ResourceIdOptions struct {
|
||||
ID string `help:"ID or name of the resource" json:"-"`
|
||||
}
|
||||
|
||||
func (o *ResourceIdOptions) GetId() string {
|
||||
return o.ID
|
||||
}
|
||||
|
||||
func (o *ResourceIdOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
type ResourceMetadataOptions struct {
|
||||
ID string `help:"ID or name of resources" json:"-"`
|
||||
TAGS []string `help:"Tags info, eg: hypervisor=aliyun、os_type=Linux、os_version"`
|
||||
|
||||
Reference in New Issue
Block a user