mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
dynamic schedule support resource type
This commit is contained in:
@@ -69,9 +69,9 @@ type schedtagCandidateW struct {
|
||||
func (w schedtagCandidateW) GetDynamicSchedDesc() *jsonutils.JSONDict {
|
||||
ret := jsonutils.NewDict()
|
||||
hostSchedDesc := w.GetSchedDesc()
|
||||
srvSchedDesc := jsonutils.Marshal(w.schedData)
|
||||
ret.Add(hostSchedDesc, "host")
|
||||
ret.Add(srvSchedDesc, "server")
|
||||
srvSchedDesc := w.schedData.ToConditionInput()
|
||||
ret.Add(hostSchedDesc, computemodels.HostManager.Keyword())
|
||||
ret.Add(srvSchedDesc, computemodels.GuestManager.Keyword())
|
||||
return ret
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,12 @@ func (w schedtagStorageW) IndexKey() string {
|
||||
}
|
||||
|
||||
func (w schedtagStorageW) GetDynamicSchedDesc() *jsonutils.JSONDict {
|
||||
return nil
|
||||
ret := jsonutils.NewDict()
|
||||
storageSchedDesc := w.candidater.GetDynamicConditionInput()
|
||||
diskSchedDesc := w.disk.JSON(w.disk)
|
||||
ret.Add(storageSchedDesc, models.StorageManager.Keyword())
|
||||
ret.Add(diskSchedDesc, models.DiskManager.Keyword())
|
||||
return ret
|
||||
}
|
||||
|
||||
func (w schedtagStorageW) GetSchedtags() []models.SSchedtag {
|
||||
|
||||
@@ -187,11 +187,11 @@ func (c *SchedtagChecker) Contains(objectTags []models.SSchedtag, tags []compute
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (p *SchedtagChecker) getDynamicSchedtags(schedDesc *jsonutils.JSONDict) ([]models.SSchedtag, error) {
|
||||
func (p *SchedtagChecker) getDynamicSchedtags(resType string, schedDesc *jsonutils.JSONDict) ([]models.SSchedtag, error) {
|
||||
if schedDesc == nil {
|
||||
return []models.SSchedtag{}, nil
|
||||
}
|
||||
dynamicTags := models.DynamicschedtagManager.GetAllEnabledDynamicSchedtags()
|
||||
dynamicTags := models.DynamicschedtagManager.GetEnabledDynamicSchedtagsByResource(resType)
|
||||
|
||||
tags := []models.SSchedtag{}
|
||||
for _, tag := range dynamicTags {
|
||||
@@ -233,7 +233,7 @@ func (c *SchedtagChecker) mergeSchedtags(candiate ISchedtagCandidate, staticTags
|
||||
|
||||
func (c *SchedtagChecker) GetCandidateSchedtags(candidate ISchedtagCandidate) ([]models.SSchedtag, error) {
|
||||
staticTags := candidate.GetSchedtags()
|
||||
dynamicTags, err := c.getDynamicSchedtags(candidate.GetDynamicSchedDesc())
|
||||
dynamicTags, err := c.getDynamicSchedtags(candidate.ResourceType(), candidate.GetDynamicSchedDesc())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user