Skip to content

Commit

Permalink
lb: include cluster name info in details
Browse files Browse the repository at this point in the history
  • Loading branch information
yousong committed Jun 24, 2020
1 parent fa521da commit 5f49670
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions pkg/apis/compute/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ type LoadbalancerDetails struct {
ManagedResourceInfo
CloudregionResourceInfo

LoadbalancerClusterResourceInfo

VpcResourceInfoBase
ZoneResourceInfoBase
NetworkResourceInfoBase
Expand Down
3 changes: 3 additions & 0 deletions pkg/compute/models/loadbalanceragents.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,9 @@ func (man *SLoadbalancerAgentManager) CleanPendingDeleteLoadbalancers(ctx contex
}

func (lbagent *SLoadbalancerAgent) ValidateUpdateData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
if data.Contains("cluster_id") {
data.Remove("cluster_id")
}
{
keyV := map[string]validators.IValidator{
"hb_timeout": validators.NewNonNegativeValidator("hb_timeout").Optional(true),
Expand Down
2 changes: 1 addition & 1 deletion pkg/compute/models/loadbalancerclusterresource.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (

type SLoadbalancerClusterResourceBase struct {
// 归属LB集群
ClusterId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" json:"cluster_id"`
ClusterId string `width:"36" charset:"ascii" nullable:"false" list:"user" update:"user" create:"required" json:"cluster_id"`
}

type SLoadbalancerClusterResourceBaseManager struct {
Expand Down
8 changes: 6 additions & 2 deletions pkg/compute/models/loadbalancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ type SLoadbalancerManager struct {

SManagedResourceBaseManager
SCloudregionResourceBaseManager

SLoadbalancerClusterResourceBaseManager
}

var LoadbalancerManager *SLoadbalancerManager
Expand Down Expand Up @@ -107,8 +109,7 @@ type SLoadbalancer struct {
// 虚拟私有网络Id
// VpcId string `width:"36" charset:"ascii" nullable:"true" list:"user" create:"optional"`

// 负载均衡集群Id
ClusterId string `width:"36" charset:"ascii" nullable:"true" list:"user" create:"optional" update:"user" json:"cluster_id"`
SLoadbalancerClusterResourceBase

// 计费类型
ChargeType string `list:"user" get:"user" create:"optional" update:"user" json:"charge_type"`
Expand Down Expand Up @@ -574,6 +575,7 @@ func (man *SLoadbalancerManager) FetchCustomizeColumns(
) []api.LoadbalancerDetails {
rows := make([]api.LoadbalancerDetails, len(objs))

clusterRows := man.SLoadbalancerClusterResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
virtRows := man.SVirtualResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
manRows := man.SManagedResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
regRows := man.SCloudregionResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
Expand All @@ -583,6 +585,8 @@ func (man *SLoadbalancerManager) FetchCustomizeColumns(

for i := range rows {
rows[i] = api.LoadbalancerDetails{
LoadbalancerClusterResourceInfo: clusterRows[i],

VirtualResourceDetails: virtRows[i],
ManagedResourceInfo: manRows[i],
CloudregionResourceInfo: regRows[i],
Expand Down

0 comments on commit 5f49670

Please sign in to comment.