Skip to content

Commit

Permalink
lbagent: default-params: default vrrp params from peer lbagents
Browse files Browse the repository at this point in the history
  • Loading branch information
yousong committed Jun 9, 2020
1 parent f441306 commit 71e9f99
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions pkg/compute/models/loadbalanceragents.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,29 @@ func (man *SLoadbalancerAgentManager) AllowGetPropertyDefaultParams(ctx context.
func (man *SLoadbalancerAgentManager) GetPropertyDefaultParams(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) (jsonutils.JSONObject, error) {
params := SLoadbalancerAgentParams{}
params.initDefault(jsonutils.NewDict())
obj := jsonutils.Marshal(params)

{
clusterV := validators.NewModelIdOrNameValidator("cluster", "loadbalancercluster", userCred)
clusterV.Optional(true)
if err := clusterV.Validate(query.(*jsonutils.JSONDict)); err != nil {
return nil, err
}
if clusterV.Model != nil {
cluster := clusterV.Model.(*SLoadbalancerCluster)
lbagents, err := LoadbalancerClusterManager.getLoadbalancerAgents(cluster.Id)
if err != nil {
return nil, httperrors.NewGeneralError(err)
}
if len(lbagents) > 0 {
lbagent := lbagents[0]
params.Vrrp.updateBy(&lbagent.Params.Vrrp)
}
}
}

paramsObj := jsonutils.Marshal(params)
r := jsonutils.NewDict()
r.Set("params", obj)
r.Set("params", paramsObj)
return r, nil
}

Expand Down

0 comments on commit 71e9f99

Please sign in to comment.