From 08c1e9fda04f4755f68451df9464e321039b21b8 Mon Sep 17 00:00:00 2001 From: Lucas Ritzdorf <42657792+LRitzdorf@users.noreply.github.com> Date: Tue, 9 Jul 2024 10:53:51 -0600 Subject: [PATCH] Memstore: fall back to using given name if no SMD results This is the case when no xname can be found for the given MAC address, in which case we consider the possibility that the input isn't a MAC address at all, and use it as directly as a datastore key. --- internal/memstore/ciMemStore.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/memstore/ciMemStore.go b/internal/memstore/ciMemStore.go index fddfe1d..6566c76 100644 --- a/internal/memstore/ciMemStore.go +++ b/internal/memstore/ciMemStore.go @@ -63,6 +63,7 @@ func (m MemStore) Get(name string, sm *smdclient.SMDClient) (citypes.CI, error) id, err := sm.IDfromMAC(name) if err != nil { log.Print(err) + id = name // Fall back to using the given name as an ID } else { log.Printf("xname %s with mac %s found\n", id, name) } @@ -81,7 +82,7 @@ func (m MemStore) Get(name string, sm *smdclient.SMDClient) (citypes.CI, error) } } } else { - log.Printf("ID %s is not a member of any groups\n", name) + log.Printf("ID %s is not a member of any groups\n", id) } if val, ok := m.list[id]; ok {