Skip to content

Commit

Permalink
feat(serverprofile): add force param to serverprofile creation (#551)
Browse files Browse the repository at this point in the history
  • Loading branch information
FalcoSuessgott authored Nov 15, 2023
1 parent a81561a commit cf67623
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 13 deletions.
1 change: 1 addition & 0 deletions docs/r/server_profile.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
3 changes: 3 additions & 0 deletions examples/server_profiles/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions examples/server_profiles/update_resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
33 changes: 32 additions & 1 deletion oneview/resource_server_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand All @@ -1981,6 +2011,7 @@ func resourceServerProfileCreate(d *schema.ResourceData, meta interface{}) error
return err
}
}

return resourceServerProfileRead(d, meta)
}

Expand Down
55 changes: 51 additions & 4 deletions vendor/github.com/HewlettPackard/oneview-golang/ov/profiles.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cf67623

Please sign in to comment.