From 50f109c88453d16640adbd772bc83c0deb0c69b5 Mon Sep 17 00:00:00 2001 From: Tom Morelly Date: Tue, 30 Jan 2024 11:16:13 +0100 Subject: [PATCH] fix(profiles): remove os.Exit to avoid oneview TF provider from responding --- ov/profiles.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/ov/profiles.go b/ov/profiles.go index 1db270b9..5d4ae9c9 100644 --- a/ov/profiles.go +++ b/ov/profiles.go @@ -21,7 +21,6 @@ import ( "encoding/json" "errors" "fmt" - "os" "reflect" "strings" @@ -454,18 +453,16 @@ func (c *OVClient) SubmitNewProfile(p ServerProfile, ignoreFlags ...ForceFlag) ( if err != nil || isHardwareAvailable == false { log.Errorf("Error getting available Hardware: %s", p.ServerHardwareURI.String()) if err != nil { - log.Warnf("Error: %s", err) + return fmt.Errorf("error getting available hardware: %v", err) } - os.Exit(1) } server, err = c.GetServerHardwareByUri(p.ServerHardwareURI) } server, err = c.GetServerHardwareByUri(p.ServerHardwareURI) - if err != nil { - log.Warnf("Problem getting server hardware, %s", err) + return fmt.Errorf("problem getting server hardware, %v", err) } // power off the server so that we can add to SP @@ -475,8 +472,9 @@ func (c *OVClient) SubmitNewProfile(p ServerProfile, ignoreFlags ...ForceFlag) ( serverHardwareType, err := c.GetServerHardwareTypeByUri(server.ServerHardwareTypeURI) if err != nil { - log.Warnf("Error getting server hardware type %s", err) + return fmt.Errorf("Error getting server hardware type %v", err) } + serverHarwdareTypeGen := serverHardwareType.Generation var emptyMgmtProcessorsStruct ManagementProcessors @@ -499,15 +497,14 @@ func (c *OVClient) SubmitNewProfile(p ServerProfile, ignoreFlags ...ForceFlag) ( data, err := c.RestAPICall(rest.POST, uri, p, forceFlags) if err != nil { t.TaskIsDone = true - log.Errorf("Error submitting new profile request: %s", err) - return err + return fmt.Errorf("Error submitting new profile request: %v", err) } log.Debugf("Response New Profile %s", data) if err := json.Unmarshal([]byte(data), &t); err != nil { t.TaskIsDone = true - log.Errorf("Error with task un-marshal: %s", err) - return err + + return fmt.Errorf("Error with task un-marshal: %s", err) } err = t.Wait()