diff --git a/pkg/compute/models/elasticips.go b/pkg/compute/models/elasticips.go index b0d9c7afd2..506deffc31 100644 --- a/pkg/compute/models/elasticips.go +++ b/pkg/compute/models/elasticips.go @@ -222,6 +222,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) } diff --git a/pkg/mcclient/options/compute/eips.go b/pkg/mcclient/options/compute/eips.go index 67ef87ccdb..4f4422a8e1 100644 --- a/pkg/mcclient/options/compute/eips.go +++ b/pkg/mcclient/options/compute/eips.go @@ -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