diff --git a/pkg/compute/models/hosts.go b/pkg/compute/models/hosts.go index 43cb57db53..b03a24b6ce 100644 --- a/pkg/compute/models/hosts.go +++ b/pkg/compute/models/hosts.go @@ -4350,6 +4350,7 @@ func (self *SHost) addNetif(ctx context.Context, userCred mcclient.TokenCredenti if err != nil { return err } + hw.syncClassMetadata(ctx) } else { db.Update(hw, func() error { hw.Bridge = bridge @@ -4359,6 +4360,7 @@ func (self *SHost) addNetif(ctx context.Context, userCred mcclient.TokenCredenti hw.IsMaster = isMaster return nil }) + hw.syncClassMetadata(ctx) } } } diff --git a/pkg/compute/models/hostwires.go b/pkg/compute/models/hostwires.go index 12bd0d94e4..29f2f5b47f 100644 --- a/pkg/compute/models/hostwires.go +++ b/pkg/compute/models/hostwires.go @@ -299,10 +299,16 @@ func (hw *SHostwire) PostCreate( data jsonutils.JSONObject, ) { hw.SHostJointsBase.PostCreate(ctx, userCred, ownerId, query, data) + hw.syncClassMetadata(ctx) +} + +func (hw *SHostwire) syncClassMetadata(ctx context.Context) error { host := hw.GetHost() wire := hw.GetWire() err := db.InheritFromTo(ctx, wire, host) if err != nil { log.Errorf("Inherit class metadata from host to wire fail: %s", err) + return errors.Wrap(err, "InheritFromTo") } + return nil }