Skip to content
Snippets Groups Projects
Unverified Commit a595c08b authored by Zexi Li's avatar Zexi Li Committed by GitHub
Browse files

Merge pull request #14327 from ioito/automated-cherry-pick-of-#14326-upstream-release-3.8

Automated cherry pick of #14326: fix(region): add filter for eip
parents 42bf0853 507c2922
No related branches found
No related tags found
No related merge requests found
......@@ -221,6 +221,17 @@ func (manager *SElasticipManager) ListItemFilter(
sqlchemy.IsNullOrEmpty(q.Field("associate_id")),
),
)
case api.EIP_ASSOCIATE_TYPE_LOADBALANCER:
_lb, err := validators.ValidateModel(userCred, LoadbalancerManager, &query.UsableEipForAssociateId)
if err != nil {
return nil, err
}
lb := _lb.(*SLoadbalancer)
q = q.Equals("cloudregion_id", lb.CloudregionId)
if len(lb.ManagerId) > 0 {
q = q.Equals("manager_id", lb.ManagerId)
}
q = q.IsNullOrEmpty("associate_type")
default:
return nil, httperrors.NewInputParameterError("Not support associate type %s, only support %s", associateType, api.EIP_ASSOCIATE_VALID_TYPES)
}
......
......@@ -24,7 +24,7 @@ type ElasticipListOptions struct {
Region string `help:"List eips in cloudregion"`
Usable *bool `help:"List all zones that is usable"`
UsableEipForAssociateType string `help:"With associate id filter which eip can associate" choices:"server|natgateway"`
UsableEipForAssociateType string `help:"With associate id filter which eip can associate" choices:"server|natgateway|loadbalancer"`
UsableEipForAssociateId string `help:"With associate type filter which eip can associate"`
options.BaseListOptions
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment