diff --git a/controller/nucleus/deviceFilesystemStore.go b/controller/nucleus/deviceFilesystemStore.go index 3f1bf140fe4f2ae807d72c4aa7a9e10ca788c8e7..fc57e48cfce24269e906cff34d6f2fb8ac013786 100644 --- a/controller/nucleus/deviceFilesystemStore.go +++ b/controller/nucleus/deviceFilesystemStore.go @@ -76,12 +76,12 @@ func (s *FilesystemDeviceStore) Get(query store.Query) (device.LoadedDevice, err } for _, device := range devices { - if device.ID == query.ID.String() { + if device.ID == query.ID.String() || device.Name == query.Name { return device, nil } } - return device, &errors.ErrNotFound{ID: query.ID} + return device, &errors.ErrNotFound{ID: query.ID, Name: query.Name} } // GetAll returns all stored devices. @@ -143,7 +143,7 @@ func (s *FilesystemDeviceStore) Update(deviceToUpdate device.Device) error { } } - return &errors.ErrNotFound{ID: deviceToUpdate.ID().String()} + return &errors.ErrNotFound{ID: deviceToUpdate.ID().String(), Name: deviceToUpdate.Name()} } // Delete deletes a device from the device store. @@ -171,5 +171,5 @@ func (s *FilesystemDeviceStore) Delete(deviceToDelete device.Device) error { } } - return &errors.ErrNotFound{ID: deviceToDelete.ID} + return &errors.ErrNotFound{ID: deviceToDelete.ID, Name: deviceToDelete.Name()} } diff --git a/controller/nucleus/errors/errors.go b/controller/nucleus/errors/errors.go index 3e38ba8b6e7628b85d3f5811b574a97f5b6f43f3..7883c35987cb9557c16d6d9af66aceb6617b167d 100644 --- a/controller/nucleus/errors/errors.go +++ b/controller/nucleus/errors/errors.go @@ -24,11 +24,12 @@ func (e *ErrNil) Error() string { // ErrNotFound implements the Error interface and is called if a specific ID // of a storable item could not be found. type ErrNotFound struct { - ID interface{} + ID interface{} + Name interface{} } func (e *ErrNotFound) Error() string { - return fmt.Sprintf("%v not found", e.ID) + return fmt.Sprintf("ID: %v or Name: %vnot found", e.ID, e.Name) } // ErrAlreadyExists implements the Error interface and is called if a specific ID diff --git a/controller/nucleus/memoryPndStore.go b/controller/nucleus/memoryPndStore.go index 471947aabed96a3413ca4232548ca017a7a1c9d0..6274703647d32e85856f749b500505c1d45debd5 100644 --- a/controller/nucleus/memoryPndStore.go +++ b/controller/nucleus/memoryPndStore.go @@ -45,7 +45,7 @@ func (t *MemoryPndStore) Delete(item networkdomain.NetworkDomain) error { func (t *MemoryPndStore) Get(query store.Query) (networkdomain.NetworkDomain, error) { item, ok := t.Store[query.ID] if !ok { - return nil, &nerrors.ErrNotFound{ID: query.ID} + return nil, &nerrors.ErrNotFound{ID: query.ID, Name: query.Name} } return item, nil diff --git a/controller/nucleus/pndFilesystemStore.go b/controller/nucleus/pndFilesystemStore.go index c9c15c055b3f7615c438b8bbd00a7e0126d2ab4b..61a42808c0b25112083c1ee0d11e094abd3052aa 100644 --- a/controller/nucleus/pndFilesystemStore.go +++ b/controller/nucleus/pndFilesystemStore.go @@ -132,7 +132,7 @@ func (t *FilesystemPndStore) Delete(item networkdomain.NetworkDomain) error { } } - return &errors.ErrNotFound{ID: item.ID} + return &errors.ErrNotFound{ID: item.ID, Name: item.GetName()} } // Get provides a the query interface to find a stored pnd. @@ -146,12 +146,12 @@ func (t *FilesystemPndStore) Get(query store.Query) (networkdomain.NetworkDomain } for _, pnd := range pnds { - if pnd.ID() == query.ID { + if pnd.ID() == query.ID || pnd.GetName() == query.Name { return pnd, nil } } - return nil, &errors.ErrNotFound{ID: query.ID} + return nil, &errors.ErrNotFound{ID: query.ID, Name: query.Name} } // GetAll returns all pnds currently on the store. diff --git a/controller/nucleus/sbiFilesystemStore.go b/controller/nucleus/sbiFilesystemStore.go index 9337d37e646eb0f3e59ca22f5f2f298bd8e16b02..52d0f98944ee93b1d8bef02f2f128d3af85f4b6b 100644 --- a/controller/nucleus/sbiFilesystemStore.go +++ b/controller/nucleus/sbiFilesystemStore.go @@ -97,8 +97,8 @@ func (s *FilesystemSbiStore) Delete(sbiToDelete southbound.SouthboundInterface) return err } - for i, device := range sbis { - if device.ID == sbiToDelete.ID().String() { + for i, sbi := range sbis { + if sbi.ID == sbiToDelete.ID().String() { //remove item from slice sbis[i] = sbis[len(sbis)-1] sbis = sbis[:len(sbis)-1] @@ -111,7 +111,7 @@ func (s *FilesystemSbiStore) Delete(sbiToDelete southbound.SouthboundInterface) return nil } } - return &errors.ErrNotFound{ID: sbiToDelete.ID} + return &errors.ErrNotFound{ID: sbiToDelete.ID, Name: sbiToDelete.Name()} } // Get takes a SouthboundInterface's UUID or name and returns the SouthboundInterface. If the requested @@ -127,13 +127,13 @@ func (s *FilesystemSbiStore) Get(query store.Query) (southbound.LoadedSbi, error return sbi, err } - for _, device := range sbis { - if device.ID == query.ID.String() { - return device, nil + for _, sbi := range sbis { + if sbi.ID == query.ID.String() { + return sbi, nil } } - return sbi, &errors.ErrNotFound{ID: query.ID} + return sbi, &errors.ErrNotFound{ID: query.ID, Name: query.Name} } // GetAll returns all SBIs diff --git a/csbi/deployment.go b/csbi/deployment.go index 47ae9e3a1596e9e709f496d5aeb5cd48dceea68a..a07aae382cffa01ecf95b2de9a4c9703c593c649 100644 --- a/csbi/deployment.go +++ b/csbi/deployment.go @@ -80,7 +80,7 @@ func (store DeploymentStore) Delete(id uuid.UUID) error { log.Tracef("requested %v from store", id) deployment := <-store.in if deployment.ID != id { - return &errors.ErrNotFound{} + return &errors.ErrNotFound{ID: id} } log.Tracef("received %v from store", id) deployment.State = pb.State_STATE_DECOMMISSIONED