修正:1. storagecache.CacheImage接口需要指定format 2.

PerformAction默认返回ActionNotFound Error
This commit is contained in:
Qiu Jian
2019-01-04 17:36:54 +08:00
parent 9b74919020
commit e5aa26f0af
19 changed files with 55 additions and 34 deletions
+4 -3
View File
@@ -419,9 +419,10 @@ func init() {
})
type HostCacheImageActionOptions struct {
ID string `help:"ID or name of host"`
IMAGE string `help:"ID or name of image"`
Force bool `help:"Force refresh cache, even if the image exists in cache"`
ID string `help:"ID or name of host"`
IMAGE string `help:"ID or name of image"`
Force bool `help:"Force refresh cache, even if the image exists in cache"`
Format string `help:"image format" choices:"iso|vmdk|qcow2|vhd"`
}
R(&HostCacheImageActionOptions{}, "host-cache-image", "Ask a host to cache a image", func(s *mcclient.ClientSession, args *HostCacheImageActionOptions) error {
params := jsonutils.NewDict()
+7 -3
View File
@@ -46,9 +46,10 @@ func init() {
})
type StorageCacheImageActionOptions struct {
ID string `help:"ID or name of storage"`
IMAGE string `help:"ID or name of image"`
Force bool `help:"Force refresh cache, even if the image exists in cache"`
ID string `help:"ID or name of storage"`
IMAGE string `help:"ID or name of image"`
Force bool `help:"Force refresh cache, even if the image exists in cache"`
Format string `help:"image format" choices:"iso|qcow2|vmdk|vhd"`
}
R(&StorageCacheImageActionOptions{}, "storagecache-cache-image", "Ask a storage cache to cache a image", func(s *mcclient.ClientSession, args *StorageCacheImageActionOptions) error {
params := jsonutils.NewDict()
@@ -56,6 +57,9 @@ func init() {
if args.Force {
params.Add(jsonutils.JSONTrue, "is_force")
}
if len(args.Format) > 0 {
params.Add(jsonutils.NewString(args.Format), "format")
}
storage, err := modules.Storagecaches.PerformAction(s, args.ID, "cache-image", params)
if err != nil {
return err
+7 -3
View File
@@ -172,9 +172,10 @@ func init() {
})
type StorageCacheImageActionOptions struct {
ID string `help:"ID or name of storage"`
IMAGE string `help:"ID or name of image"`
Force bool `help:"Force refresh cache, even if the image exists in cache"`
ID string `help:"ID or name of storage"`
IMAGE string `help:"ID or name of image"`
Force bool `help:"Force refresh cache, even if the image exists in cache"`
Format string `help:"Image force" choices:"iso|vmdk|qcow2|vhd"`
}
R(&StorageCacheImageActionOptions{}, "storage-cache-image", "Ask a storage to cache a image", func(s *mcclient.ClientSession, args *StorageCacheImageActionOptions) error {
params := jsonutils.NewDict()
@@ -182,6 +183,9 @@ func init() {
if args.Force {
params.Add(jsonutils.JSONTrue, "is_force")
}
if len(args.Format) > 0 {
params.Add(jsonutils.NewString(args.Format), "format")
}
storage, err := modules.Storages.PerformAction(s, args.ID, "cache-image", params)
if err != nil {
return err