Merge pull request #12613 from zhaoxiangchun/bugfix/zxc-monitor

fix(monitor): monitor host query fix
This commit is contained in:
Zexi Li
2021-11-05 18:37:08 +08:00
committed by GitHub
2 changed files with 21 additions and 0 deletions
+1
View File
@@ -564,6 +564,7 @@ func (c *QueryCondition) getOnecloudResources() ([]jsonutils.JSONObject, error)
//}
switch c.ResType {
case monitor.METRIC_RES_TYPE_HOST:
query := jsonutils.NewDict()
query.Set("host-type", jsonutils.NewString(hostconsts.TELEGRAF_TAG_KEY_HYPERVISOR))
allResources, err = ListAllResources(&mc_mds.Hosts, query)
case monitor.METRIC_RES_TYPE_GUEST:
+20
View File
@@ -461,6 +461,26 @@ func (manager *SMonitorResourceManager) GetResourceObj(id string) (bool, jsonuti
return false, nil
}
func (manager *SMonitorResourceManager) GetResourceObjByResType(typ string) (bool, []jsonutils.JSONObject) {
manager.GetModelSets()
for _, set := range manager.GetModelSets().ModelSetList() {
if _, ok := set.(IMonitorResModelSet); !ok {
continue
}
if set.(IMonitorResModelSet).GetResType() != typ {
continue
}
setRv := reflect.ValueOf(set)
objects := make([]jsonutils.JSONObject, 0)
for _, kRv := range setRv.MapKeys() {
mRv := setRv.MapIndex(kRv)
objects = append(objects, jsonutils.Marshal(mRv.Interface()))
}
return true, objects
}
return false, nil
}
func (manager *SMonitorResourceManager) SyncResources(ctx context.Context, mss *MonitorResModelSets) error {
userCred := auth.AdminCredential()
errs := make([]error, 0)