From da483dca8f3619dcb6d798b00b1172af8cfda5b8 Mon Sep 17 00:00:00 2001 From: Roman Dodin Date: Mon, 22 Nov 2021 21:26:03 +0100 Subject: [PATCH] do not regen ceos system mac file --- nodes/ceos/ceos.go | 10 ++++++++-- utils/file.go | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/nodes/ceos/ceos.go b/nodes/ceos/ceos.go index 8952a5fb2..3f65123c6 100644 --- a/nodes/ceos/ceos.go +++ b/nodes/ceos/ceos.go @@ -138,8 +138,14 @@ func createCEOSFiles(node *types.NodeConfig) error { return err } m[5] = m[5] + 1 - utils.CreateFile(path.Join(node.LabDir, "flash", "system_mac_address"), m.String()) - return nil + + sysMacPath := path.Join(node.LabDir, "flash", "system_mac_address") + + if !utils.FileExists(sysMacPath) { + err = utils.CreateFile(sysMacPath, m.String()) + } + + return err } // ceosPostDeploy runs postdeploy actions which are required for ceos nodes diff --git a/utils/file.go b/utils/file.go index 1fd7f9503..5cfdeada7 100644 --- a/utils/file.go +++ b/utils/file.go @@ -18,6 +18,7 @@ var errNonRegularFile = errors.New("non-regular file") var errFileNotExist = errors.New("file does not exist") var errHTTPFetch = errors.New("failed to fetch http(s) resource") +// FileExists returns true if a file referenced by filename exists func FileExists(filename string) bool { f, err := os.Stat(filename) if os.IsNotExist(err) {