Browse Source

delete host role when client is delete

Abhishek Kondur 2 years ago
parent
commit
f789e92023
2 changed files with 15 additions and 0 deletions
  1. 1 0
      mq/dynsec_clients.go
  2. 14 0
      mq/dynsec_helper.go

+ 1 - 0
mq/dynsec_clients.go

@@ -43,6 +43,7 @@ func ModifyClient(client *MqClient) error {
 
 // DeleteMqClient - removes a client from the DynSec system
 func DeleteMqClient(hostID string) error {
+	deleteHostRole(hostID)
 	event := MqDynsecPayload{
 		Commands: []MqDynSecCmd{
 			{

+ 14 - 0
mq/dynsec_helper.go

@@ -232,6 +232,20 @@ func DeleteNetworkRole(network string) error {
 	return publishEventToDynSecTopic(event)
 }
 
+func deleteHostRole(hostID string) error {
+	// Deletes the hostID role from MQ
+	event := MqDynsecPayload{
+		Commands: []MqDynSecCmd{
+			{
+				Command:  DeleteRoleCmd,
+				RoleName: getHostRoleName(hostID),
+			},
+		},
+	}
+
+	return publishEventToDynSecTopic(event)
+}
+
 // CreateNetworkRole - createss a network role from DynSec system
 func CreateNetworkRole(network string) error {
 	// Create Role with acls for the network