updated routes to use uuid

This commit is contained in:
0xdcarns 2022-01-11 12:00:14 -05:00
parent 9888a84e8a
commit c70041ddd0

View file

@ -48,7 +48,7 @@ func DeleteNodeByMacAddress(node *models.Node, exterminate bool) error {
var key = node.ID var key = node.ID
if !exterminate { if !exterminate {
args := strings.Split(key, "###") args := strings.Split(key, "###")
node, err := GetNode(args[0], args[1]) node, err := GetNodeByMacAddress(args[0], args[1])
if err != nil { if err != nil {
return err return err
} }
@ -160,29 +160,29 @@ func SetNetworkNodesLastModified(networkName string) error {
return nil return nil
} }
// GetNode - fetches a node from database // // GetNode - fetches a node from database
func GetNode(macaddress string, network string) (models.Node, error) { // func GetNode(macaddress string, network string) (models.Node, error) {
var node models.Node // var node models.Node
key, err := GetRecordKey(macaddress, network) // key, err := GetRecordKey(macaddress, network)
if err != nil { // if err != nil {
return node, err // return node, err
} // }
data, err := database.FetchRecord(database.NODES_TABLE_NAME, key) // data, err := database.FetchRecord(database.NODES_TABLE_NAME, key)
if err != nil { // if err != nil {
if data == "" { // if data == "" {
data, _ = database.FetchRecord(database.DELETED_NODES_TABLE_NAME, key) // data, _ = database.FetchRecord(database.DELETED_NODES_TABLE_NAME, key)
err = json.Unmarshal([]byte(data), &node) // err = json.Unmarshal([]byte(data), &node)
} // }
return node, err // return node, err
} // }
if err = json.Unmarshal([]byte(data), &node); err != nil { // if err = json.Unmarshal([]byte(data), &node); err != nil {
return node, err // return node, err
} // }
SetNodeDefaults(&node) // SetNodeDefaults(&node)
return node, err // return node, err
} // }
// DeleteNodeByID - deletes a node from database or moves into delete nodes table // DeleteNodeByID - deletes a node from database or moves into delete nodes table
func DeleteNodeByID(node *models.Node, exterminate bool) error { func DeleteNodeByID(node *models.Node, exterminate bool) error {