Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions pkg/repository/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,6 @@ func (r *switchRepository) Port(ctx context.Context, id, port string, status api
return nil, errorutil.InvalidArgument("port %s does not exist on switch %s", port, id)
}

m, err := r.getConnectedMachineForNic(ctx, nic, sw.MachineConnections)
if err != nil {
return nil, err
}

if m == nil {
return nil, errorutil.FailedPrecondition("port %s is not connected to any machine", port)
}

nic.State.Desired = &metalStatus
err = r.s.ds.Switch().Update(ctx, sw)
if err != nil {
Expand Down
22 changes: 18 additions & 4 deletions pkg/service/admin/switch/switch-service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -664,17 +664,31 @@ func Test_switchServiceServer_Port(t *testing.T) {
wantErr: errorutil.InvalidArgument("port swp1 does not exist on switch %s", sc.P01Rack01Switch1),
},
{
name: "nic is not connected to a machine",
name: "nic is not connected to a machine, port update still works",
rq: &adminv2.SwitchServicePortRequest{
Status: apiv2.SwitchPortStatus_SWITCH_PORT_STATUS_UP,
Id: sc.P01Rack01Switch1,
NicName: "Ethernet1",
},
want: nil,
wantErr: errorutil.FailedPrecondition("port Ethernet1 is not connected to any machine"),
want: func(dc *test.Datacenter) *adminv2.SwitchServicePortResponse {
sw := dc.GetSwitches()[sc.P01Rack01Switch1]
sw.Nics[1].State.Desired = apiv2.SwitchPortStatus_SWITCH_PORT_STATUS_UP.Enum()
return &adminv2.SwitchServicePortResponse{
Switch: sw,
}
},
mods: func() *test.Asserters {
return &test.Asserters{
Switches: func(switches map[string]*apiv2.Switch) {
sw := switches[sc.P01Rack01Switch1]
sw.Nics[1].State.Desired = apiv2.SwitchPortStatus_SWITCH_PORT_STATUS_UP.Enum()
},
}
},
wantErr: nil,
},
{
name: "nic update successful",
name: "nic update for connected nic successful",
rq: &adminv2.SwitchServicePortRequest{
Status: apiv2.SwitchPortStatus_SWITCH_PORT_STATUS_DOWN,
Id: sc.P01Rack01Switch1,
Expand Down