Merge pull request #1319 in YUNIONIO/onecloud from ~LIZEXI/onecloud:bugfix/lzx-shcedtag-policy to release/2.8.0

* commit '3ba6d4186cb9b69fec7e7c978cc3483d66768bea':
  dynamic schedule support resource type
This commit is contained in:
李泽玺
2019-03-25 11:18:11 +08:00
18 changed files with 264 additions and 136 deletions
+9 -5
View File
@@ -114,14 +114,18 @@ func init() {
})
type DynamicSchedtagEvaluateOptions struct {
ID string `help:"ID or name of the sched policy"`
HOST string `help:"ID or name of the host"`
SERVER string `help:"ID or name of the server"`
ID string `help:"ID or name of the sched policy"`
ResourceType string `help:"Standalone resource type" choices:"host|storage" default:"host"`
VirtaulResourceType string `help:"Virtual resource type" choices:"server|disk" default:"server"`
STANDALONERES string `help:"ID or name of the standalone resource, e.g. host, storage"`
VIRTUALRES string `help:"ID or name of the virtual resource, e.g. server, disk"`
}
R(&DynamicSchedtagEvaluateOptions{}, "dynamic-schedtag-evaluate", "Evaluate dynamic schedtag condition", func(s *mcclient.ClientSession, args *DynamicSchedtagEvaluateOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.HOST), "host")
params.Add(jsonutils.NewString(args.SERVER), "server")
params.Add(jsonutils.NewString(args.ResourceType), "resource_type")
params.Add(jsonutils.NewString(args.VirtaulResourceType), "virtual_resource_type")
params.Add(jsonutils.NewString(args.STANDALONERES), "object_id")
params.Add(jsonutils.NewString(args.VIRTUALRES), "virtual_object_id")
result, err := modules.Dynamicschedtags.PerformAction(s, args.ID, "evaluate", params)
if err != nil {
return err
+5 -3
View File
@@ -124,12 +124,14 @@ func init() {
})
type SchedpoliciesEvaluateOptions struct {
ID string `help:"ID or name of the sched policy"`
SERVER string `help:"ID or name of the server"`
ID string `help:"ID or name of the sched policy"`
OBJECT string `help:"ID or name of the object"`
ResourceType string `help:"Resource type of the object" default:"server" choices:"server|disk" short-token:"t"`
}
R(&SchedpoliciesEvaluateOptions{}, "sched-policy-evaluate", "Evaluate sched policy", func(s *mcclient.ClientSession, args *SchedpoliciesEvaluateOptions) error {
params := jsonutils.NewDict()
params.Add(jsonutils.NewString(args.SERVER), "server")
params.Add(jsonutils.NewString(args.OBJECT), "object")
params.Add(jsonutils.NewString(args.ResourceType), "resource_type")
result, err := modules.Schedpolicies.PerformAction(s, args.ID, "evaluate", params)
if err != nil {
return err