Skip to content

Commit

Permalink
Make IOL NVRAM filename generate based on IOL PID (#2264)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaelemc authored Oct 27, 2024
1 parent 17b295e commit 5e9647b
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions nodes/iol/iol.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ const (
typeL2 = "l2"

iol_workdir = "/iol"
nvram_file1 = "nvram_00001"
nvram_file2 = "nvram_00003"
)

var (
Expand Down Expand Up @@ -61,8 +59,9 @@ func Register(r *nodes.NodeRegistry) {
type iol struct {
nodes.DefaultNode

isL2Node bool
Pid string
isL2Node bool
Pid string
nvramFile string
}

func (n *iol) Init(cfg *types.NodeConfig, opts ...nodes.NodeOption) error {
Expand Down Expand Up @@ -95,10 +94,11 @@ func (n *iol) Init(cfg *types.NodeConfig, opts ...nodes.NodeOption) error {
n.Cfg.NodeType, strings.Join(validTypes, ", "))
}

n.nvramFile = fmt.Sprint("nvram_", fmt.Sprintf("%05s", n.Pid))

n.Cfg.Binds = append(n.Cfg.Binds,
// mount nvram so that config persists
fmt.Sprint(path.Join(n.Cfg.LabDir, nvram_file1), ":", path.Join(iol_workdir, nvram_file1)),
fmt.Sprint(path.Join(n.Cfg.LabDir, nvram_file2), ":", path.Join(iol_workdir, nvram_file2)),
fmt.Sprint(path.Join(n.Cfg.LabDir, n.nvramFile), ":", path.Join(iol_workdir, n.nvramFile)),

// mount launch config
fmt.Sprint(filepath.Join(n.Cfg.LabDir, "startup.cfg"), ":/iol/config.txt"),
Expand Down Expand Up @@ -135,14 +135,9 @@ func (n *iol) PostDeploy(ctx context.Context, params *nodes.PostDeployParams) er
func (n *iol) CreateIOLFiles(ctx context.Context) error {
// If NVRAM already exists, don't need to create
// otherwise saved configs in NVRAM are overwritten.
if !utils.FileExists(path.Join(n.Cfg.LabDir, nvram_file1)) {
// create nvram file
utils.CreateFile(path.Join(n.Cfg.LabDir, nvram_file1), "")
}

if !utils.FileExists(path.Join(n.Cfg.LabDir, nvram_file2)) {
if !utils.FileExists(path.Join(n.Cfg.LabDir, n.nvramFile)) {
// create nvram file
utils.CreateFile(path.Join(n.Cfg.LabDir, nvram_file2), "")
utils.CreateFile(path.Join(n.Cfg.LabDir, n.nvramFile), "")
}

// create these files so the bind monut doesn't automatically
Expand Down

0 comments on commit 5e9647b

Please sign in to comment.