From d714082a5ca00d851649d89b609a121c16c04b43 Mon Sep 17 00:00:00 2001 From: nabhajit-ray Date: Wed, 27 Mar 2024 18:26:01 +0530 Subject: [PATCH] fixed hw check during profile creation --- ov/profiles.go | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/ov/profiles.go b/ov/profiles.go index 1db270b9..8f450fc8 100644 --- a/ov/profiles.go +++ b/ov/profiles.go @@ -21,7 +21,6 @@ import ( "encoding/json" "errors" "fmt" - "os" "reflect" "strings" @@ -447,19 +446,9 @@ func (c *OVClient) SubmitNewProfile(p ServerProfile, ignoreFlags ...ForceFlag) ( log.Debugf("REST : %s \n %+v\n", uri, p) log.Debugf("task -> %+v", t) - // Get available server hardwares to assign it to SP - if p.ServerHardwareURI != "" { - - isHardwareAvailable, err := c.GetAvailableServers(p.ServerHardwareURI.String()) - if err != nil || isHardwareAvailable == false { - log.Errorf("Error getting available Hardware: %s", p.ServerHardwareURI.String()) - if err != nil { - log.Warnf("Error: %s", err) - } - os.Exit(1) - } - - server, err = c.GetServerHardwareByUri(p.ServerHardwareURI) + // Check if server hardware already has server profile assigned + if server.ServerProfileURI.String() != "null" { + return fmt.Errorf("hardware %s already has server profile assigned", server.Name) } server, err = c.GetServerHardwareByUri(p.ServerHardwareURI)