Skip to content

Commit

Permalink
Merge pull request #108 from gmacf/resolve
Browse files Browse the repository at this point in the history
Include resolved bpb.Chassis in GetBootstrapData method.
  • Loading branch information
gmacf authored Dec 6, 2023
2 parents afc4082 + b373447 commit fab44e3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion server/entitymanager/entitymanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func populateBootConfig(conf *epb.BootConfig) (*bpb.BootConfig, error) {
}

// GetBootstrapData fetches and returns the bootstrap data response from the server.
func (m *InMemoryEntityManager) GetBootstrapData(ctx context.Context, lookup *service.EntityLookup, controllerCard *bpb.ControlCard) (*bpb.BootstrapDataResponse, error) {
func (m *InMemoryEntityManager) GetBootstrapData(ctx context.Context, ch *bpb.Chassis, lookup *service.EntityLookup, controllerCard *bpb.ControlCard) (*bpb.BootstrapDataResponse, error) {
serial := lookup.SerialNumber
if controllerCard != nil {
serial = controllerCard.GetSerialNumber()
Expand Down
3 changes: 2 additions & 1 deletion server/entitymanager/entitymanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,8 @@ func TestGetBootstrapData(t *testing.T) {

for _, test := range tests {
t.Run(test.desc, func(t *testing.T) {
got, err := em.GetBootstrapData(ctx, &service.EntityLookup{SerialNumber: test.chassisSerial, Manufacturer: test.chassisManufacturer}, test.input)
//TODO(https://github.com/openconfig/bootz/issues/105): Populate bpb.Chassis once epb.Chassis has been de-duplicated.
got, err := em.GetBootstrapData(ctx, &bpb.Chassis{}, &service.EntityLookup{SerialNumber: test.chassisSerial, Manufacturer: test.chassisManufacturer}, test.input)
if (err != nil) != test.wantErr {
t.Errorf("GetBootstrapData(%v) err = %v, want %v", test.input, err, test.wantErr)
}
Expand Down
6 changes: 3 additions & 3 deletions server/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type EntityLookup struct {
// EntityManager maintains the entities and their states.
type EntityManager interface {
ResolveChassis(context.Context, *EntityLookup, string) (*bpb.Chassis, error)
GetBootstrapData(context.Context, *EntityLookup, *bpb.ControlCard) (*bpb.BootstrapDataResponse, error)
GetBootstrapData(context.Context, *bpb.Chassis, *EntityLookup, *bpb.ControlCard) (*bpb.BootstrapDataResponse, error)
SetStatus(context.Context, *bpb.ReportStatusRequest) error
Sign(context.Context, *bpb.GetBootstrapDataResponse, *EntityLookup, string) error
}
Expand Down Expand Up @@ -124,15 +124,15 @@ func (s *Service) GetBootstrapData(ctx context.Context, req *bpb.GetBootstrapDat
log.Infof("=============================================================================")
var responses []*bpb.BootstrapDataResponse
for _, v := range chassisDesc.GetControlCards() {
bootdata, err := s.em.GetBootstrapData(ctx, lookup, v)
bootdata, err := s.em.GetBootstrapData(ctx, chassis, lookup, v)
if err != nil {
errs.Add(err)
log.Infof("Error occurred while retrieving data for Serial Number %v", v.SerialNumber)
}
responses = append(responses, bootdata)
}
if fixedChasis {
bootdata, err := s.em.GetBootstrapData(ctx, lookup, nil)
bootdata, err := s.em.GetBootstrapData(ctx, chassis, lookup, nil)
if err != nil {
errs.Add(err)
log.Infof("Error occurred while retrieving data for fixed chassis with serail number %v", lookup.SerialNumber)
Expand Down

0 comments on commit fab44e3

Please sign in to comment.