Skip to content

Commit

Permalink
Set the administrative status of the ports to up on SONiC (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertvolkmann authored Sep 20, 2023
1 parent afda7ce commit 723da4a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
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

0 comments on commit 723da4a

Please sign in to comment.