mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-24 23:41:52 +08:00
Merge pull request #9224 from tb365/bugfix/tb-bugfix-1207
Bugfix/tb bugfix 1207
This commit is contained in:
@@ -37,11 +37,11 @@ type LoadbalancerListenerListInput struct {
|
||||
apis.VirtualResourceListInput
|
||||
apis.ExternalizedResourceBaseListInput
|
||||
LoadbalancerFilterListInput
|
||||
// filter by acl
|
||||
LoadbalancerAclResourceInput
|
||||
|
||||
// filter by backend_group
|
||||
BackendGroup string `json:"backend_group"`
|
||||
// filter by acl
|
||||
Acl string `json:"acl"`
|
||||
|
||||
ListenerType []string `json:"listener_type"`
|
||||
ListenerPort []int `json:"listener_port"`
|
||||
|
||||
@@ -301,7 +301,7 @@ func (manager *SLoadbalancerAclManager) FetchCustomizeColumns(
|
||||
}
|
||||
|
||||
for i := range objs {
|
||||
q := LoadbalancerListenerManager.Query().Equals("acl_id", objs[i].(*SLoadbalancerAcl).GetId())
|
||||
q := LoadbalancerListenerManager.Query().IsFalse("pending_deleted").Equals("acl_id", objs[i].(*SLoadbalancerAcl).GetId())
|
||||
ownerId, queryScope, err := db.FetchCheckQueryOwnerScope(ctx, userCred, query, LoadbalancerListenerManager, policy.PolicyActionList, true)
|
||||
if err != nil {
|
||||
log.Errorf("FetchCheckQueryOwnerScope error: %v", err)
|
||||
|
||||
@@ -149,7 +149,7 @@ func (manager *SLoadbalancerCertificateManager) FetchCustomizeColumns(
|
||||
}
|
||||
|
||||
for i := range objs {
|
||||
q := LoadbalancerListenerManager.Query().Equals("certificate_id", objs[i].(*SLoadbalancerCertificate).GetId())
|
||||
q := LoadbalancerListenerManager.Query().IsFalse("pending_deleted").Equals("certificate_id", objs[i].(*SLoadbalancerCertificate).GetId())
|
||||
ownerId, queryScope, err := db.FetchCheckQueryOwnerScope(ctx, userCred, query, LoadbalancerListenerManager, policy.PolicyActionList, true)
|
||||
if err != nil {
|
||||
log.Errorf("FetchCheckQueryOwnerScope error: %v", err)
|
||||
|
||||
@@ -235,7 +235,7 @@ func (man *SLoadbalancerListenerManager) ListItemFilter(
|
||||
q, err = validators.ApplyModelFilters(q, data, []*validators.ModelFilterOptions{
|
||||
// {Key: "loadbalancer", ModelKeyword: "loadbalancer", OwnerId: userCred},
|
||||
{Key: "backend_group", ModelKeyword: "loadbalancerbackendgroup", OwnerId: userCred},
|
||||
{Key: "acl", ModelKeyword: "cachedloadbalanceracl", OwnerId: userCred},
|
||||
// {Key: "acl", ModelKeyword: "cachedloadbalanceracl", OwnerId: userCred},
|
||||
// {Key: "cloudregion", ModelKeyword: "cloudregion", OwnerId: userCred},
|
||||
// {Key: "manager", ModelKeyword: "cloudprovider", OwnerId: userCred},
|
||||
})
|
||||
@@ -264,6 +264,11 @@ func (man *SLoadbalancerListenerManager) ListItemFilter(
|
||||
if len(query.AclType) > 0 {
|
||||
q = q.In("acl_type", query.AclType)
|
||||
}
|
||||
if len(query.AclId) > 0 {
|
||||
q = q.Equals("acl_id", query.AclId)
|
||||
} else if len(query.Acl) > 0 {
|
||||
q = q.Equals("acl_id", query.Acl)
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
@@ -130,7 +130,11 @@ func (self *SElasticcache) GetId() string {
|
||||
}
|
||||
|
||||
func (self *SElasticcache) GetName() string {
|
||||
return self.InstanceName
|
||||
if len(self.InstanceName) > 0 {
|
||||
return self.InstanceName
|
||||
}
|
||||
|
||||
return self.InstanceID
|
||||
}
|
||||
|
||||
func (self *SElasticcache) GetGlobalId() string {
|
||||
@@ -242,11 +246,13 @@ func (self *SElasticcache) GetVpcId() string {
|
||||
}
|
||||
|
||||
func (self *SElasticcache) GetZoneId() string {
|
||||
zone, err := self.region.getZoneById(transZoneIdToEcsZoneId(self.region, "redis", self.ZoneID))
|
||||
zoneId := transZoneIdToEcsZoneId(self.region, "redis", self.ZoneID)
|
||||
zone, err := self.region.getZoneById(fetchMasterZoneId(zoneId))
|
||||
if err != nil {
|
||||
log.Errorf("failed to find zone for elasticcache %s error: %v", self.GetId(), err)
|
||||
return ""
|
||||
}
|
||||
|
||||
return zone.GetGlobalId()
|
||||
}
|
||||
|
||||
|
||||
@@ -479,3 +479,17 @@ func transRegionIdFromEcsRegionId(region *SRegion, service string) string {
|
||||
|
||||
return region.GetId()
|
||||
}
|
||||
|
||||
func fetchMasterZoneId(zoneId string) string {
|
||||
// cn-shenzhen-finance-1MAZ2(d,e)
|
||||
i := strings.Index(zoneId, "MAZ")
|
||||
if i > 0 {
|
||||
s := strings.Index(zoneId, "(")
|
||||
e := strings.Index(zoneId, ",")
|
||||
if s >= 0 && e >= 0 {
|
||||
return zoneId[0:i] + zoneId[s+1:e]
|
||||
}
|
||||
}
|
||||
|
||||
return zoneId
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user