Browse Source

Merge pull request #2148 from gravitl/GRA-1459-extclient

Gra 1459 extclient
Alex Feiszli 2 years ago
parent
commit
cdf0738577
1 changed files with 17 additions and 0 deletions
  1. 17 0
      logic/extpeers.go

+ 17 - 0
logic/extpeers.go

@@ -194,6 +194,23 @@ func UpdateExtClient(newclientid string, network string, enabled bool, client *m
 	if err != nil {
 	if err != nil {
 		return client, err
 		return client, err
 	}
 	}
+	if newclientid != client.ClientID {
+		//name change only
+		client.ClientID = newclientid
+		client.LastModified = time.Now().Unix()
+		data, err := json.Marshal(&client)
+		if err != nil {
+			return nil, err
+		}
+		key, err := GetRecordKey(client.ClientID, client.Network)
+		if err != nil {
+			return nil, err
+		}
+		if err = database.Insert(key, string(data), database.EXT_CLIENT_TABLE_NAME); err != nil {
+			return client, err
+		}
+		return client, nil
+	}
 	client.ClientID = newclientid
 	client.ClientID = newclientid
 	client.Enabled = enabled
 	client.Enabled = enabled
 	SetClientACLs(client, newACLs)
 	SetClientACLs(client, newACLs)