diff --git a/docs/r/server_profile.html.markdown b/docs/r/server_profile.html.markdown
index 133317e3..d202c500 100644
--- a/docs/r/server_profile.html.markdown
+++ b/docs/r/server_profile.html.markdown
@@ -149,6 +149,7 @@ The following arguments are supported:
* `Operation_type` - (Optional) patch operation can be performed by giving the update string for given type of update.
- - -
+* `force_flags` - (Optional) a list of supported force flags, ignoring certain warnings when creating the server profile.
* `public_connection` - (Optional) The name of the network that is going out to the public.
diff --git a/examples/server_profiles/main.tf b/examples/server_profiles/main.tf
index fa616cae..804d7ab1 100644
--- a/examples/server_profiles/main.tf
+++ b/examples/server_profiles/main.tf
@@ -26,6 +26,9 @@ resource "oneview_server_profile" "SPWithLocalStorage" {
hardware_name = "0000A66101, bay 5"
type = "ServerProfileV12"
enclosure_group = "Auto-EG"
+
+ force_flags = ["ignoreServerHealth"] // supported: ignoreSANWarnings, ignoreServerHealth, ignoreLSWarnings, all; default: none
+
initial_scope_uris = [data.oneview_scope.scope.uri]
bios_option {
manage_bios = true
diff --git a/examples/server_profiles/update_resource.tf b/examples/server_profiles/update_resource.tf
index 0d7431f6..c8312fef 100644
--- a/examples/server_profiles/update_resource.tf
+++ b/examples/server_profiles/update_resource.tf
@@ -13,6 +13,9 @@ resource "oneview_server_profile" "SP" {
hardware_name = "0000A66102, bay 3"
type = "ServerProfileV12"
enclosure_group = "EG"
+
+ force_flags = ["ignoreServerHealth"] // supported: ignoreSANWarnings, ignoreServerHealth, ignoreLSWarnings, all; default: none
+
bios_option {
manage_bios = true
overridden_settings {
diff --git a/go.mod b/go.mod
index b71e3e3c..3826b765 100644
--- a/go.mod
+++ b/go.mod
@@ -3,7 +3,7 @@ module github.com/HewlettPackard/terraform-provider-oneview
go 1.15
require (
- github.com/HewlettPackard/oneview-golang v8.6.0+incompatible
+ github.com/HewlettPackard/oneview-golang v8.6.1-0.20231109094213-30a3fb89caf6+incompatible
github.com/docker/machine v0.16.2 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-getter v1.6.2 // indirect
diff --git a/go.sum b/go.sum
index 86126ac4..af625bdd 100644
--- a/go.sum
+++ b/go.sum
@@ -34,14 +34,10 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
-github.com/HewlettPackard/oneview-golang v8.3.1-0.20230529095956-f6039fe84f3f+incompatible h1:8COeVoPlFSy1Bo79TazBKGLhj2L1gLcLHHAh/BnFuuc=
-github.com/HewlettPackard/oneview-golang v8.3.1-0.20230529095956-f6039fe84f3f+incompatible/go.mod h1:GJcjWgNHrKtt2lUl4xcaV3NRiuBlG138DNrFygXj4JE=
-github.com/HewlettPackard/oneview-golang v8.4.0+incompatible h1:IR44tRzdZrPmp0Mm1+Adk+z9eDWV+LA2FU23JYKSJOI=
-github.com/HewlettPackard/oneview-golang v8.4.0+incompatible/go.mod h1:GJcjWgNHrKtt2lUl4xcaV3NRiuBlG138DNrFygXj4JE=
-github.com/HewlettPackard/oneview-golang v8.5.0+incompatible h1:Fy7Ce1PUcLk7iuuof494D5cfoSwj/nIWpBkAWnZ4rZY=
-github.com/HewlettPackard/oneview-golang v8.5.0+incompatible/go.mod h1:GJcjWgNHrKtt2lUl4xcaV3NRiuBlG138DNrFygXj4JE=
github.com/HewlettPackard/oneview-golang v8.6.0+incompatible h1:5/s9xGTGiVyISxWaxT/QlVYx/bIQvCyQo4UA9VgX0Ek=
github.com/HewlettPackard/oneview-golang v8.6.0+incompatible/go.mod h1:GJcjWgNHrKtt2lUl4xcaV3NRiuBlG138DNrFygXj4JE=
+github.com/HewlettPackard/oneview-golang v8.6.1-0.20231109094213-30a3fb89caf6+incompatible h1:wldabw1+dMd4Pa2ByJ3iV18uFC8pFMxPZO5Q4D3dnq0=
+github.com/HewlettPackard/oneview-golang v8.6.1-0.20231109094213-30a3fb89caf6+incompatible/go.mod h1:GJcjWgNHrKtt2lUl4xcaV3NRiuBlG138DNrFygXj4JE=
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
diff --git a/oneview/resource_server_profile.go b/oneview/resource_server_profile.go
index 26444191..7f1d106c 100644
--- a/oneview/resource_server_profile.go
+++ b/oneview/resource_server_profile.go
@@ -40,6 +40,12 @@ func resourceServerProfile() *schema.Resource {
Type: schema.TypeString,
Required: true,
},
+ "force_flags": {
+ Type: schema.TypeList,
+ Optional: true,
+ Computed: true,
+ Elem: &schema.Schema{Type: schema.TypeString},
+ },
"boot": {
Type: schema.TypeList,
Optional: true,
@@ -1970,7 +1976,31 @@ func resourceServerProfileCreate(d *schema.ResourceData, meta interface{}) error
}
//Cleaning up SP by removing spt related fields
config.ovClient.Cleanup(&serverProfile)
- err := config.ovClient.SubmitNewProfile(serverProfile)
+
+ providedForceFlags := d.Get("force_flags").([]interface{})
+ forceFlags := []ov.ForceFlag{}
+
+ for _, f := range providedForceFlags {
+ // see https://github.com/HewlettPackard/oneview-golang/blob/master/ov/profiles.go#L52 for supported force flags
+ switch f.(string) {
+ case "ignoreSANWarnings":
+ forceFlags = append(forceFlags, ov.ForceIgnoreSANWarnings)
+ case "ignoreServerHealth":
+ forceFlags = append(forceFlags, ov.ForceIgnoreServerHealth)
+ case "ignoreLSWarnings":
+ forceFlags = append(forceFlags, ov.ForceIgnoreLSWarnings)
+ case "all":
+ forceFlags = append(forceFlags, ov.ForceIgnoreAll)
+ case "none":
+ forceFlags = append(forceFlags, ov.ForceIgnoreNone)
+ default:
+ return fmt.Errorf("invalid force flag." +
+ "(supported values: \"ignoreSANWarnings\", \"ignoreServerHealth\", \"ignoreLSWarnings\", \"all\", \"none\")")
+ }
+ }
+
+ err := config.ovClient.SubmitNewProfile(serverProfile, forceFlags...)
+
d.SetId(d.Get("name").(string))
if err != nil {
@@ -1981,6 +2011,7 @@ func resourceServerProfileCreate(d *schema.ResourceData, meta interface{}) error
return err
}
}
+
return resourceServerProfileRead(d, meta)
}
diff --git a/vendor/github.com/HewlettPackard/oneview-golang/ov/profiles.go b/vendor/github.com/HewlettPackard/oneview-golang/ov/profiles.go
index 7eff75cc..1db270b9 100644
--- a/vendor/github.com/HewlettPackard/oneview-golang/ov/profiles.go
+++ b/vendor/github.com/HewlettPackard/oneview-golang/ov/profiles.go
@@ -23,12 +23,44 @@ import (
"fmt"
"os"
"reflect"
+ "strings"
"github.com/HewlettPackard/oneview-golang/rest"
"github.com/HewlettPackard/oneview-golang/utils"
"github.com/docker/machine/libmachine/log"
)
+type ForceFlag int
+
+const (
+ // ForceIgnoreSANWarnings When provided, the operation will ignore warnings for non-critical issues detected in the SAN storage configuration.
+ ForceIgnoreSANWarnings ForceFlag = iota
+
+ // ForceIgnoreServerHealth When provided, the operation will ignore the check to verify that the selected server's health is OK.
+ ForceIgnoreServerHealth
+
+ // ForceIgnoreLSWarnings When provided, the operation will ignore the validation warnings from local storage.
+ ForceIgnoreLSWarnings
+
+ // ForceIgnoreAll When provided, all warnings will be ignored.
+ ForceIgnoreAll
+
+ // ForceIgnoreNone When provided, none of the warnings will be ignored.
+ ForceIgnoreNone
+)
+
+func (f ForceFlag) String() string {
+ forceFlagMap := map[ForceFlag]string{
+ ForceIgnoreSANWarnings: "ignoreSANWarnings",
+ ForceIgnoreServerHealth: "ignoreServerHealth",
+ ForceIgnoreLSWarnings: "ignoreLSWarnings",
+ ForceIgnoreAll: "all",
+ ForceIgnoreNone: "none",
+ }
+
+ return forceFlagMap[f]
+}
+
// FirmwareOption structure for firware settings
type FirmwareOption struct {
ComplianceControl string `json:"complianceControl,omitempty"` // complianceControl
@@ -395,12 +427,16 @@ func (c *OVClient) GetAvailableServers(ServerHardwareUri string) (bool, error) {
}
// SubmitNewProfile - submit new profile template
-func (c *OVClient) SubmitNewProfile(p ServerProfile) (err error) {
+func (c *OVClient) SubmitNewProfile(p ServerProfile, ignoreFlags ...ForceFlag) (err error) {
log.Infof("Initializing creation of server profile for %s.", p.Name)
var (
uri = "/rest/server-profiles"
server ServerHardware
t *Task
+ // if no warning flags has been provided, use default value:
+ forceFlags = map[string]interface{}{
+ "force": ForceIgnoreNone,
+ }
)
// refresh login
c.RefreshLogin()
@@ -449,7 +485,18 @@ func (c *OVClient) SubmitNewProfile(p ServerProfile) (err error) {
p.ManagementProcessor = mp
}
- data, err := c.RestAPICall(rest.POST, uri, p)
+ // append force flags comma separated
+ if len(ignoreFlags) > 0 {
+ var flags []string
+
+ for _, i := range ignoreFlags {
+ flags = append(flags, i.String())
+ }
+
+ forceFlags["force"] = strings.Join(flags, ",")
+ }
+
+ data, err := c.RestAPICall(rest.POST, uri, p, forceFlags)
if err != nil {
t.TaskIsDone = true
log.Errorf("Error submitting new profile request: %s", err)
@@ -472,7 +519,7 @@ func (c *OVClient) SubmitNewProfile(p ServerProfile) (err error) {
}
// create profile from template
-func (c *OVClient) CreateProfileFromTemplate(name string, template ServerProfile, blade ServerHardware) error {
+func (c *OVClient) CreateProfileFromTemplate(name string, template ServerProfile, blade ServerHardware, ignoreFlags ...ForceFlag) error {
log.Debugf("TEMPLATE : %+v\n", template)
var (
new_template ServerProfile
@@ -513,7 +560,7 @@ func (c *OVClient) CreateProfileFromTemplate(name string, template ServerProfile
new_template.Name = name
log.Debugf("new_template -> %+v", new_template)
- err = c.SubmitNewProfile(new_template)
+ err = c.SubmitNewProfile(new_template, ignoreFlags...)
return err
}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 1dc1a967..c00d4339 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -8,7 +8,7 @@ cloud.google.com/go/internal/trace
cloud.google.com/go/internal/version
# cloud.google.com/go/storage v1.10.0
cloud.google.com/go/storage
-# github.com/HewlettPackard/oneview-golang v8.6.0+incompatible
+# github.com/HewlettPackard/oneview-golang v8.6.1-0.20231109094213-30a3fb89caf6+incompatible
## explicit
github.com/HewlettPackard/oneview-golang/liboneview
github.com/HewlettPackard/oneview-golang/ov