From 5bb9036dd0d6e83b1b01aa723cd5fa58f474db31 Mon Sep 17 00:00:00 2001 From: Boris Glimcher Date: Fri, 7 Jun 2024 04:58:30 +0300 Subject: [PATCH] fix: report more progress in new places Signed-off-by: Boris Glimcher --- sztp-agent/pkg/secureagent/daemon.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sztp-agent/pkg/secureagent/daemon.go b/sztp-agent/pkg/secureagent/daemon.go index cdb0f521..db899132 100644 --- a/sztp-agent/pkg/secureagent/daemon.go +++ b/sztp-agent/pkg/secureagent/daemon.go @@ -244,6 +244,7 @@ func (a *Agent) downloadAndValidateImage() error { return errors.New("Checksum mismatch") } log.Println("[INFO] Checksum verified successfully") + _ = a.doReportProgress(ProgressTypeBootImageComplete) return nil default: return errors.New("Unsupported hash algorithm") @@ -254,6 +255,7 @@ func (a *Agent) downloadAndValidateImage() error { func (a *Agent) copyConfigurationFile() error { log.Println("[INFO] Starting the Copy Configuration.") + _ = a.doReportProgress(ProgressTypeConfigInitiated) // Copy the configuration file to the device file, err := os.Create(ARTIFACTS_PATH + a.BootstrapServerOnboardingInfo.IetfSztpConveyedInfoOnboardingInformation.InfoTimestampReference + "-config") if err != nil { @@ -274,24 +276,27 @@ func (a *Agent) copyConfigurationFile() error { return err } log.Println("[INFO] Configuration file copied successfully") + _ = a.doReportProgress(ProgressTypeConfigComplete) return nil } func (a *Agent) launchScriptsConfiguration(typeOf string) error { var script, scriptName string - var report ProgressType + var reportStart, reportEnd ProgressType switch typeOf { case "post": script = a.BootstrapServerOnboardingInfo.IetfSztpConveyedInfoOnboardingInformation.PostConfigurationScript scriptName = "post" - report = ProgressTypePostScriptInitiated + reportStart = ProgressTypePostScriptInitiated + reportEnd = ProgressTypePostScriptComplete default: // pre or default script = a.BootstrapServerOnboardingInfo.IetfSztpConveyedInfoOnboardingInformation.PreConfigurationScript scriptName = "pre" - report = ProgressTypePreScriptInitiated + reportStart = ProgressTypePreScriptInitiated + reportEnd = ProgressTypePreScriptComplete } log.Println("[INFO] Starting the " + scriptName + "-configuration.") - _ = a.doReportProgress(report) + _ = a.doReportProgress(reportStart) file, err := os.Create(ARTIFACTS_PATH + a.BootstrapServerOnboardingInfo.IetfSztpConveyedInfoOnboardingInformation.InfoTimestampReference + scriptName + "configuration.sh") if err != nil { log.Println("[ERROR] creating the "+scriptName+"-configuration script", err.Error()) @@ -318,6 +323,7 @@ func (a *Agent) launchScriptsConfiguration(typeOf string) error { return err } log.Println(string(out)) // remove it + _ = a.doReportProgress(reportEnd) log.Println("[INFO] " + scriptName + "-Configuration script executed successfully") return nil }