Browse Source

Merge pull request #1950 from gravitl/GRA-985/mq_modify_client_bug

Gra 985/mq modify client bug
dcarns 2 years ago
parent
commit
f844e8435f
3 changed files with 5 additions and 11 deletions
  1. 4 0
      mq/dynsec_clients.go
  2. 1 1
      mq/handlers.go
  3. 0 10
      mq/util.go

+ 4 - 0
mq/dynsec_clients.go

@@ -16,6 +16,10 @@ func ModifyClient(client *MqClient) error {
 			Rolename: HostGenericRole,
 			Priority: -1,
 		},
+		{
+			Rolename: getHostRoleName(client.ID),
+			Priority: -1,
+		},
 	}
 
 	for i := range client.Networks {

+ 1 - 1
mq/handlers.go

@@ -121,7 +121,7 @@ func UpdateNode(client mqtt.Client, msg mqtt.Message) {
 // UpdateHost  message Handler -- handles host updates from clients
 func UpdateHost(client mqtt.Client, msg mqtt.Message) {
 	go func(msg mqtt.Message) {
-		id, err := getHostID(msg.Topic())
+		id, err := getID(msg.Topic())
 		if err != nil {
 			logger.Log(1, "error getting host.ID sent on ", msg.Topic(), err.Error())
 			return

+ 0 - 10
mq/util.go

@@ -94,13 +94,3 @@ func getID(topic string) (string, error) {
 	//the last part of the topic will be the node.ID
 	return parts[count-1], nil
 }
-
-// decodes a message queue topic and returns the embedded host.ID
-func getHostID(topic string) (string, error) {
-	parts := strings.Split(topic, "/")
-	count := len(parts)
-	if count < 4 {
-		return "", fmt.Errorf("invalid topic")
-	}
-	return parts[2], nil
-}