mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
region: storage support set schedtags (#223)
This commit is contained in:
@@ -518,21 +518,4 @@ func init() {
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type HostSetSchedtagOptions struct {
|
||||
ID string `help:"ID or Name of host"`
|
||||
Schedtag []string `help:"Ids of schedtag"`
|
||||
}
|
||||
R(&HostSetSchedtagOptions{}, "host-set-schedtag", "Set schedtags to a host", func(s *mcclient.ClientSession, args *HostSetSchedtagOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
for idx, tag := range args.Schedtag {
|
||||
params.Add(jsonutils.NewString(tag), fmt.Sprintf("schedtag.%d", idx))
|
||||
}
|
||||
result, err := modules.Hosts.PerformAction(s, args.ID, "set-schedtag", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ func (h *schedtagModelHelper) register() {
|
||||
h.list(man.Slave, man.Slave.GetKeyword())
|
||||
h.add(man, man.Slave.GetKeyword())
|
||||
h.remove(man, man.Slave.GetKeyword())
|
||||
h.setTags(man, man.Slave.GetKeyword())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,6 +98,25 @@ func (h *schedtagModelHelper) remove(man modules.JointResourceManager, kw string
|
||||
})
|
||||
}
|
||||
|
||||
func (h *schedtagModelHelper) setTags(man modules.JointResourceManager, kw string) {
|
||||
R(
|
||||
&options.SchedtagSetOptions{},
|
||||
fmt.Sprintf("%s-set-schedtag", kw),
|
||||
fmt.Sprintf("Set schedtags to %v", kw),
|
||||
func(s *mcclient.ClientSession, args *options.SchedtagSetOptions) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ret, err := man.Slave.PerformAction(s, args.ID, "set-schedtag", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(ret)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func init() {
|
||||
newSchedtagModelHelper(
|
||||
modules.Schedtaghosts,
|
||||
|
||||
@@ -228,5 +228,4 @@ func init() {
|
||||
printObject(storage)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user