From 8c31bba0aa30b00c1862d8c70cc2e8eee602141a Mon Sep 17 00:00:00 2001 From: Qu Xuan Date: Tue, 28 Jul 2020 18:11:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dvm=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E5=AE=89=E5=85=A8=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/compute/models/guests.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/compute/models/guests.go b/pkg/compute/models/guests.go index 283070f5d5..bca3d61497 100644 --- a/pkg/compute/models/guests.go +++ b/pkg/compute/models/guests.go @@ -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) + } } }