Skip to content
Snippets Groups Projects
Commit ff928b38 authored by André Sterba's avatar André Sterba
Browse files

WIP

parent 5110dbdf
No related branches found
No related tags found
1 merge request!150Let user set a name for a device or autogenerate it
This commit is part of merge request !150. Comments created here will be created in the context of that merge request.
...@@ -6,6 +6,18 @@ import ( ...@@ -6,6 +6,18 @@ import (
"github.com/openconfig/ygot/ygot" "github.com/openconfig/ygot/ygot"
) )
type DeviceIdentifier interface {
IsDeviceIdentifier()
}
type StringIdentifier string
func (si StringIdentifier) IsDeviceIdentifier() {}
type UUIDIdentifier uuid.UUID
func (ui UUIDIdentifier) IsDeviceIdentifier() {}
// Device represents an Orchestrated Network Device (OND) which is managed by // Device represents an Orchestrated Network Device (OND) which is managed by
// nucleus // nucleus
type Device struct { type Device struct {
......
...@@ -223,6 +223,20 @@ func (pnd *pndImplementation) addDevice(device *Device) error { ...@@ -223,6 +223,20 @@ func (pnd *pndImplementation) addDevice(device *Device) error {
return nil return nil
} }
func (pnd *pndImplementation) getDevice(identifier DeviceIdentifier) (*Device, error) {
stringIdentifier, ok := identifier.(StringIdentifier)
if ok {
return pnd.getDeviceByName(string(stringIdentifier))
}
uuidIdentifier, ok := identifier.(UUIDIdentifier)
if ok {
return pnd.getDeviceByUUID(uuid.UUID(uuidIdentifier))
}
return nil, &ErrNotFound{id: identifier}
}
func (pnd *pndImplementation) getDeviceByUUID(id uuid.UUID) (*Device, error) { func (pnd *pndImplementation) getDeviceByUUID(id uuid.UUID) (*Device, error) {
return pnd.devices.get(id) return pnd.devices.get(id)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment