mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 02:37:24 +08:00
Merge pull request #7359 from ioito/bugfix/qx-dup-secgroup-for-guest
fix: 修复vm绑定重复安全组
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user