mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #6263 from ioito/hotfix/qx-vpc-count
fix: globalvpc count vpc
This commit is contained in:
@@ -26,6 +26,9 @@ type GlobalVpcDetails struct {
|
||||
apis.EnabledStatusInfrasResourceBaseDetails
|
||||
|
||||
SGlobalVpc
|
||||
|
||||
// vpc数量
|
||||
VpcCount int `json:"vpc_count"`
|
||||
}
|
||||
|
||||
type GlobalVpcResourceInfo struct {
|
||||
|
||||
@@ -69,9 +69,13 @@ func (self *SGlobalVpc) ValidateDeleteCondition(ctx context.Context) error {
|
||||
return self.SEnabledStatusInfrasResourceBase.ValidateDeleteCondition(ctx)
|
||||
}
|
||||
|
||||
func (self *SGlobalVpc) GetVpcQuery() *sqlchemy.SQuery {
|
||||
return VpcManager.Query().Equals("globalvpc_id", self.Id)
|
||||
}
|
||||
|
||||
func (self *SGlobalVpc) GetVpcs() ([]SVpc, error) {
|
||||
vpcs := []SVpc{}
|
||||
q := VpcManager.Query().Equals("globalvpc_id", self.Id)
|
||||
q := self.GetVpcQuery()
|
||||
err := db.FetchModelObjects(VpcManager, q, &vpcs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -79,6 +83,10 @@ func (self *SGlobalVpc) GetVpcs() ([]SVpc, error) {
|
||||
return vpcs, nil
|
||||
}
|
||||
|
||||
func (self *SGlobalVpc) GetVpcCount() (int, error) {
|
||||
return self.GetVpcQuery().CountWithError()
|
||||
}
|
||||
|
||||
func (self *SGlobalVpc) GetExtraDetails(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, isList bool) (api.GlobalVpcDetails, error) {
|
||||
return api.GlobalVpcDetails{}, nil
|
||||
}
|
||||
@@ -97,6 +105,8 @@ func (manager *SGlobalVpcManager) FetchCustomizeColumns(
|
||||
rows[i] = api.GlobalVpcDetails{
|
||||
EnabledStatusInfrasResourceBaseDetails: stdRows[i],
|
||||
}
|
||||
gv := objs[i].(*SGlobalVpc)
|
||||
rows[i].VpcCount, _ = gv.GetVpcCount()
|
||||
}
|
||||
return rows
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user