VOL-2658, VOL-2840 - remove core compete code
Change-Id: Ic34d030bc805c6948369c65db6f77f9739320570
(cherry picked from commit fd27f4b45b3c8d89174a8da7192598b768b4907d)
diff --git a/rw_core/core/id.go b/rw_core/core/id.go
index 399bf1d..cb87377 100644
--- a/rw_core/core/id.go
+++ b/rw_core/core/id.go
@@ -17,41 +17,28 @@
package core
import (
- "crypto/rand"
- "encoding/hex"
"errors"
"fmt"
- m "math/rand"
+ "math/rand"
"strconv"
+
+ "github.com/google/uuid"
)
-func randomHex(n int) (string, error) {
- bytes := make([]byte, n)
- if _, err := rand.Read(bytes); err != nil {
- return "", err
- }
- return hex.EncodeToString(bytes), nil
-}
-
-// CreateDeviceID produces a device ID. DeviceId is 16 hex long - lower 12 hex is the device id.
-// TODO: A cluster unique ID may be required
+// CreateDeviceID produces a device ID. The device ID is a UUID
func CreateDeviceID() string {
- val, _ := randomHex(12)
- return val
+ return uuid.New().String()
}
-// CreateLogicalDeviceID is not used for now as the logical device ID is derived from the
-// OLT MAC address
+// CreateLogicalDeviceID produces a logical device ID. The logical device ID is a UUID
func CreateLogicalDeviceID() string {
- // logical device id is 16 hex long - lower 12 hex is the logical device id. For now just generate the 12 hex
- val, _ := randomHex(12)
- return val
+ return uuid.New().String()
}
// CreateLogicalPortID produces a random port ID for a logical device.
func CreateLogicalPortID() uint32 {
// A logical port is a uint32
- return m.Uint32()
+ return rand.Uint32()
}
// CreateDataPathID creates uint64 pathid from string pathid