fix: 添加安全组操作日志

This commit is contained in:
Qu Xuan
2020-01-13 15:25:48 +08:00
parent 136423fdf8
commit 63eeafea27
+7
View File
@@ -34,6 +34,7 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/validators"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/logclient"
"yunion.io/x/onecloud/pkg/util/rbacutils"
)
@@ -251,6 +252,9 @@ func (self *SSecurityGroupRule) ValidateUpdateData(ctx context.Context, userCred
return nil, err
}
// 更新操作日志: 对比可以知道改了原有规则哪些内容
data.Add(jsonutils.Marshal(self), "origin")
return self.SResourceBase.ValidateUpdateData(ctx, userCred, query, data)
}
@@ -297,6 +301,7 @@ func (self *SSecurityGroupRule) PostCreate(ctx context.Context, userCred mcclien
log.Debugf("POST Create %s", data)
if secgroup := self.GetSecGroup(); secgroup != nil {
logclient.AddSimpleActionLog(secgroup, logclient.ACT_ALLOCATE, data, userCred, true)
secgroup.DoSync(ctx, userCred)
}
}
@@ -305,6 +310,7 @@ func (self *SSecurityGroupRule) PreDelete(ctx context.Context, userCred mcclient
self.SResourceBase.PreDelete(ctx, userCred)
if secgroup := self.GetSecGroup(); secgroup != nil {
logclient.AddSimpleActionLog(secgroup, logclient.ACT_DELETE, jsonutils.Marshal(self), userCred, true)
secgroup.DoSync(ctx, userCred)
}
}
@@ -314,6 +320,7 @@ func (self *SSecurityGroupRule) PostUpdate(ctx context.Context, userCred mcclien
log.Debugf("POST Update %s", data)
if secgroup := self.GetSecGroup(); secgroup != nil {
logclient.AddSimpleActionLog(secgroup, logclient.ACT_UPDATE, data, userCred, true)
secgroup.DoSync(ctx, userCred)
}
}