fix: 修复secgrouprule-list 500错误

This commit is contained in:
Qu Xuan
2020-03-19 19:11:52 +08:00
parent 78688a8ba2
commit 4ea96848cb
3 changed files with 54 additions and 1 deletions
+23
View File
@@ -0,0 +1,23 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package compute
import "yunion.io/x/onecloud/pkg/apis"
type SecgroupRuleDetails struct {
apis.ResourceBaseDetails
SSecurityGroupRule
SecurityGroupResourceInfo
}
+1 -1
View File
@@ -103,7 +103,7 @@ func (manager *SSecurityGroupResourceBaseManager) ListItemFilter(
return nil, errors.Wrap(err, "SecurityGroupManager.FetchByIdOrName")
}
}
q = q.Equals("secgroup", secgrpObj.GetId())
q = q.Equals("secgroup_id", secgrpObj.GetId())
}
return q, nil
}
+30
View File
@@ -36,6 +36,7 @@ import (
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/logclient"
"yunion.io/x/onecloud/pkg/util/rbacutils"
"yunion.io/x/onecloud/pkg/util/stringutils2"
)
type SSecurityGroupRuleManager struct {
@@ -195,6 +196,35 @@ func (manager *SSecurityGroupRuleManager) ListItemFilter(
return sql, nil
}
func (self *SSecurityGroupRule) GetExtraDetails(
ctx context.Context,
userCred mcclient.TokenCredential,
query jsonutils.JSONObject,
isList bool,
) (api.SecgroupRuleDetails, error) {
return api.SecgroupRuleDetails{}, nil
}
func (manager *SSecurityGroupRuleManager) FetchCustomizeColumns(
ctx context.Context,
userCred mcclient.TokenCredential,
query jsonutils.JSONObject,
objs []interface{},
fields stringutils2.SSortedStrings,
isList bool,
) []api.SecgroupRuleDetails {
rows := make([]api.SecgroupRuleDetails, len(objs))
bRows := manager.SResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
secRows := manager.SSecurityGroupResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
for i := range rows {
rows[i] = api.SecgroupRuleDetails{
ResourceBaseDetails: bRows[i],
SecurityGroupResourceInfo: secRows[i],
}
}
return rows
}
func (manager *SSecurityGroupRuleManager) OrderByExtraFields(
ctx context.Context,
q *sqlchemy.SQuery,