Skip to content

Commit

Permalink
fix: 修复vm绑定重复安全组
Browse files Browse the repository at this point in the history
  • Loading branch information
Qu Xuan committed Jul 28, 2020
1 parent 0b8baee commit f03d021
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/compute/models/guests.go
Original file line number Diff line number Diff line change
Expand Up @@ -1713,11 +1713,13 @@ func (guest *SGuest) PostCreate(ctx context.Context, userCred mcclient.TokenCred
guest.setUserData(ctx, userCred, userData)
}
secgroups, _ := jsonutils.GetStringArray(data, "secgroups")
for _, secgroup := range secgroups {
gs := SGuestsecgroup{}
gs.SecgroupId = secgroup
gs.GuestId = guest.Id
GuestsecgroupManager.TableSpec().Insert(ctx, &gs)
for _, secgroupId := range secgroups {
if secgroupId != guest.SecgrpId {
gs := SGuestsecgroup{}
gs.SecgroupId = secgroupId
gs.GuestId = guest.Id
GuestsecgroupManager.TableSpec().Insert(ctx, &gs)
}
}
}

Expand Down

0 comments on commit f03d021

Please sign in to comment.