Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the administrative status of the ports to up on SONiC #104

Merged
merged 1 commit into from
Sep 20, 2023
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
18 changes: 14 additions & 4 deletions cmd/internal/switcher/sonic/db/configdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const (
untagged = "untagged"
vrfName = "vrf_name"
portTable = "PORT"
adminStatus = "admin_status"
adminStatusUp = "up"
mtu = "mtu"
fec = "fec"
fecRS = "rs"
Expand All @@ -25,8 +27,9 @@ type ConfigDB struct {
}

type Port struct {
Mtu string
FecRs bool
AdminStatus bool
Mtu string
FecRs bool
}

func newConfigDB(addr string, id int, sep string) *ConfigDB {
Expand Down Expand Up @@ -176,8 +179,9 @@ func (d *ConfigDB) GetPort(ctx context.Context, interfaceName string) (*Port, er
}

return &Port{
Mtu: result[mtu],
FecRs: result[fec] == fecRS,
AdminStatus: result[adminStatus] == adminStatusUp,
Mtu: result[mtu],
FecRs: result[fec] == fecRS,
}, nil
}

Expand All @@ -199,3 +203,9 @@ func (d *ConfigDB) SetPortMtu(ctx context.Context, interfaceName string, val str

return d.c.HSet(ctx, key, Val{mtu: val})
}

func (d *ConfigDB) SetAdminStatusUp(ctx context.Context, interfaceName string) error {
key := Key{portTable, interfaceName}

return d.c.HSet(ctx, key, Val{adminStatus: adminStatusUp})
}
10 changes: 9 additions & 1 deletion cmd/internal/switcher/sonic/redis/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ func (a *Applier) ensurePortConfiguration(ctx context.Context, portName, mtu str

if p.Mtu != mtu {
a.log.Debug("set port mtu to", "port", portName, "mtu", mtu)
return a.db.Config.SetPortMtu(ctx, portName, mtu)
err = a.db.Config.SetPortMtu(ctx, portName, mtu)
if err != nil {
return err
}
}

if !p.AdminStatus {
a.log.Debug("set admin status to", "port", portName, "admin_status", "up")
return a.db.Config.SetAdminStatusUp(ctx, portName)
}

return nil
Expand Down