Skip to content

Commit

Permalink
Lift interface limit for sros (#2012)
Browse files Browse the repository at this point in the history
* lift interface limit for sros

* use quoted formatter

* simpler check for empty config

* simpler regex
  • Loading branch information
hellt committed Apr 24, 2024
1 parent 13493c3 commit c5896ac
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions nodes/vr_sros/vr-sros.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (s *vrSROS) Init(cfg *types.NodeConfig, opts ...nodes.NodeOption) error {
s.Cfg.Binds = append(s.Cfg.Binds, "/dev:/dev")
}

s.Cfg.Cmd = fmt.Sprintf("--trace --connection-mode %s --hostname %s --variant \"%s\"", s.Cfg.Env["CONNECTION_MODE"],
s.Cfg.Cmd = fmt.Sprintf("--trace --connection-mode %s --hostname %s --variant %q", s.Cfg.Env["CONNECTION_MODE"],
s.Cfg.ShortName,
s.Cfg.NodeType,
)
Expand Down Expand Up @@ -186,12 +186,14 @@ func (s *vrSROS) SaveConfig(_ context.Context) error {

// CheckInterfaceName checks if a name of the interface referenced in the topology file correct.
func (s *vrSROS) CheckInterfaceName() error {
// vsim doesn't seem to support >20 interfaces, yet we allow to set max if number 32 just in case.
// https://regex101.com/r/bx6kzM/1
ifRe := regexp.MustCompile(`eth([1-9]|[12][0-9]|3[0-2])$`)
// vsim doesn't seem to support >30 interfaces on a single line card,
// but since we use a througout enumeration for the multi line card depployment
// we allow any number of interfaces
// https://regex101.com/r/bx6kzM/3
ifRe := regexp.MustCompile(`eth([1-9]+|[1-9]\d+)$`)
for _, e := range s.Endpoints {
if !ifRe.MatchString(e.GetIfaceName()) {
return fmt.Errorf("nokia SR OS interface name %q doesn't match the required pattern. SR OS interfaces should be named as ethX, where X is from 1 to 32", e.GetIfaceName())
return fmt.Errorf("nokia SR OS interface name %q doesn't match the required pattern. SR OS interfaces should be named as ethX, where X is >=1", e.GetIfaceName())
}
}

Expand Down Expand Up @@ -251,7 +253,7 @@ func (s *vrSROS) applyPartialConfig(ctx context.Context, addr, platformName,
}

// check file contains content, otherwise exit early
if len(strings.TrimSpace(string(configContent))) == 0 {
if strings.TrimSpace(string(configContent)) == "" {
return nil
}

Expand Down

0 comments on commit c5896ac

Please sign in to comment.