mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #12613 from zhaoxiangchun/bugfix/zxc-monitor
fix(monitor): monitor host query fix
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user