Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manager reset resource #122

Merged
merged 108 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
b69eb2f
Adding inittial lintersin makefile and gha
rounak-adhikary Sep 29, 2023
3a61f94
Fixing wrong vendor
rounak-adhikary Sep 29, 2023
65dd2f1
Adding security checks and exclusions
rounak-adhikary Sep 29, 2023
c8e493c
Chnaging to golangci-lint
rounak-adhikary Sep 29, 2023
4575bac
Fix yaml
rounak-adhikary Sep 29, 2023
e1e0f45
Fix 2
rounak-adhikary Sep 29, 2023
09fc3cc
Fix 3
rounak-adhikary Sep 29, 2023
2c439b3
provider migration + code reorg
Krishnan-Priyanshu Oct 9, 2023
ca8c73b
Adding uppercaseconst comment
rounak-adhikary Oct 10, 2023
285c163
Pulling dev
rounak-adhikary Oct 10, 2023
10236dd
Removing vendor
rounak-adhikary Oct 10, 2023
89cb489
Adding linting and fixing some stuff
rounak-adhikary Oct 10, 2023
bb5fe5b
Adding vendor and golangci
rounak-adhikary Oct 16, 2023
f120e17
Merge pull request #103 from dell/linters
Krishnan-Priyanshu Oct 16, 2023
d8a64c2
rename ssl_insecure to validate_cert
Krishnan-Priyanshu Oct 16, 2023
7856224
moved resouce /datasource templates to template-bcks folder/
Krishnan-Priyanshu Oct 16, 2023
d10616f
fix the attribute name and removed redundant github action jobs
Krishnan-Priyanshu Oct 16, 2023
37d1285
provider model fixed
Krishnan-Priyanshu Oct 16, 2023
ebe723e
fix gen
Krishnan-Priyanshu Oct 16, 2023
1e17be9
Merge pull request #104 from dell/validate_cert
Krishnan-Priyanshu Oct 16, 2023
f33e1af
Adding simple update resource initial
rounak-adhikary Oct 16, 2023
e7f994b
power resource migration
Krishnan-Priyanshu Oct 17, 2023
29595cc
added power template
Krishnan-Priyanshu Oct 17, 2023
fae3d2a
Merge pull request #105 from dell/power_resource
Krishnan-Priyanshu Oct 18, 2023
c15c4b4
Merge branch 'dev' of github.com:dell/terraform-provider-redfish into…
rounak-adhikary Oct 18, 2023
d02aec8
Added debug messages
rounak-adhikary Oct 18, 2023
e0b8ac8
migrate idrac_attribute resource
Krishnan-Priyanshu Oct 22, 2023
c92994b
migration of idrac attribute CRUD
Krishnan-Priyanshu Oct 23, 2023
a449462
fmt fix
Krishnan-Priyanshu Oct 23, 2023
e0d00b2
migrated idrac attribute datasource
Krishnan-Priyanshu Oct 25, 2023
8127155
fix generate
Krishnan-Priyanshu Oct 25, 2023
254e97a
user resource migrated
Sakshi-dell Oct 25, 2023
6744bb5
me more changes
rounak-adhikary Oct 25, 2023
3cdcf2d
Migrated virtual media resource
prajwalpatil25 Oct 26, 2023
2c5b8e7
removed comments
prajwalpatil25 Oct 26, 2023
5f32e17
Fixing lint issues
rounak-adhikary Oct 26, 2023
1c3a999
Updating docs
rounak-adhikary Oct 26, 2023
5fbd320
Fixing linting issues
prajwalpatil25 Oct 26, 2023
f0889f1
fix lint issue
Krishnan-Priyanshu Oct 26, 2023
f2a9004
Update resource_redfish_dell_idrac_attributes.go
Krishnan-Priyanshu Oct 26, 2023
24ed365
initial bios ds
rounak-adhikary Oct 26, 2023
09b6ea8
Working bios ds
rounak-adhikary Oct 26, 2023
3794720
Generating docs
rounak-adhikary Oct 26, 2023
98ceacd
Merge pull request #108 from dell/idrac_attributes
Krishnan-Priyanshu Oct 26, 2023
2c14874
Merge branch 'dev' into su-res
rounak-adhikary Oct 26, 2023
31cacee
Merge branch 'su-res' into bios-ds
rounak-adhikary Oct 26, 2023
ccf84a8
Some cleanup
rounak-adhikary Oct 26, 2023
9a8719f
lint fix
rounak-adhikary Oct 26, 2023
fe0890d
Fixing linter issues
rounak-adhikary Oct 27, 2023
ff49fad
Relaxing checks
rounak-adhikary Oct 27, 2023
9133a10
Gnenerate
rounak-adhikary Oct 27, 2023
5a81e43
Merge branch 'su-res' into bios-ds
rounak-adhikary Oct 27, 2023
dd00c7a
Linter fix 1
rounak-adhikary Oct 27, 2023
694e967
Re-enabled linting for bios-ds
rounak-adhikary Oct 27, 2023
a103236
linting issue fixed
Sakshi-dell Oct 30, 2023
a52ef64
Merge branch 'dev' into User-resource-migration
Sakshi-dell Oct 30, 2023
bc6b47f
ran go generate
Sakshi-dell Oct 30, 2023
b63b5f8
Merge branch 'User-resource-migration' of https://github.com/dell/ter…
Sakshi-dell Oct 30, 2023
e07dddc
Removing skip entries for user and virtual media resources
rounak-adhikary Oct 30, 2023
7a99061
Merge branch 'dev' into bios-ds
rounak-adhikary Oct 30, 2023
205a94d
Removing commented entry
rounak-adhikary Oct 30, 2023
6d7873c
Merge pull request #112 from dell/su-res
Krishnan-Priyanshu Oct 30, 2023
22f91bc
Merge branch 'dev' into User-resource-migration
Krishnan-Priyanshu Oct 30, 2023
2431890
Merge branch 'dev' into virtual_media_migration
Krishnan-Priyanshu Oct 30, 2023
3b73d40
Updating comments
rounak-adhikary Oct 30, 2023
d2174b4
linting issues fixed
Sakshi-dell Oct 30, 2023
40f9f53
Merge branch 'User-resource-migration' of https://github.com/dell/ter…
Sakshi-dell Oct 30, 2023
2bd929d
minor issue fixed
Sakshi-dell Oct 30, 2023
998e96c
minor issue fixed
Sakshi-dell Oct 30, 2023
f6256a2
ran make generate
Sakshi-dell Oct 30, 2023
91f00e0
Merge pull request #109 from dell/User-resource-migration
Krishnan-Priyanshu Oct 30, 2023
6eaf182
Merge pull request #113 from dell/bios-ds
Sakshi-dell Oct 30, 2023
e785792
acceptance tests fix
prajwalpatil25 Oct 31, 2023
913ab8b
Merge branch 'virtual_media_migration' of github.com:dell/terraform-p…
prajwalpatil25 Oct 31, 2023
324033a
Merge branch 'dev' into virtual_media_migration
prajwalpatil25 Oct 31, 2023
2520357
fixed linting issues
prajwalpatil25 Oct 31, 2023
e57f4fe
split create method
prajwalpatil25 Oct 31, 2023
2c4377b
addressed review comment
prajwalpatil25 Oct 31, 2023
d9e4a41
Added doc template
prajwalpatil25 Oct 31, 2023
c58426b
changes in md
prajwalpatil25 Oct 31, 2023
7e61686
changes in md
prajwalpatil25 Oct 31, 2023
47b37f4
added constants to constants.go
prajwalpatil25 Nov 2, 2023
c4b898c
Merge pull request #111 from dell/virtual_media_migration
Krishnan-Priyanshu Nov 2, 2023
691cb16
migrated virtual media datasource
Krishnan-Priyanshu Nov 5, 2023
6af1afe
minor fix in redfish server config - power resource
Krishnan-Priyanshu Nov 5, 2023
407aba2
make generate fix
Krishnan-Priyanshu Nov 5, 2023
5b4736c
fixed liniting issues
Krishnan-Priyanshu Nov 6, 2023
0a338d7
moved 'virtual_media' definition to attributes
Krishnan-Priyanshu Nov 6, 2023
25a8e4d
refactor redfish server schema
Krishnan-Priyanshu Nov 6, 2023
8203938
removed '=' from redfish server config
Krishnan-Priyanshu Nov 7, 2023
dbd480e
remove validate check
Krishnan-Priyanshu Nov 7, 2023
f8e3ee1
Merge pull request #114 from dell/data-virtual-media
Sakshi-dell Nov 7, 2023
1d03578
Storage Datasource TPF Migration (#115)
rounak-adhikary Nov 7, 2023
46b7cc4
added back ssl_insecure & removed version from schema for backward co…
Krishnan-Priyanshu Nov 8, 2023
0f3990e
Firmware inventory datasource (#118)
Sakshi-dell Nov 9, 2023
ba3a53a
bios resource Migrated (#120)
Sakshi-dell Nov 9, 2023
9235286
System boot datasource migration to TPF (#121)
prajwalpatil25 Nov 15, 2023
00b74d9
Storage Volume resource migration to TPF (#119)
prajwalpatil25 Nov 15, 2023
19d948e
Manager reset resource
prajwalpatil25 Nov 17, 2023
895be66
addressing comments
prajwalpatil25 Nov 23, 2023
de89a25
Fixing lint generate issues
prajwalpatil25 Nov 23, 2023
971fe64
fixed doc
prajwalpatil25 Nov 23, 2023
c8d2178
changes in url parsing
prajwalpatil25 Nov 23, 2023
1e72e00
fixed merge conflicts
prajwalpatil25 Nov 23, 2023
287fb31
fixing merge conflicts
prajwalpatil25 Nov 23, 2023
1b2cf71
fixing merge conflicts
prajwalpatil25 Nov 23, 2023
9dc6eff
fixing merge conflicts
prajwalpatil25 Nov 23, 2023
f348c04
modified resource update
prajwalpatil25 Nov 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions docs/resources/manager_reset.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "redfish_manager_reset Resource - terraform-provider-redfish"
subcategory: ""
description: |-
Resource to reset the iDRAC.
---

# redfish_manager_reset (Resource)

Resource to reset the iDRAC.

## Example Usage

```terraform
/*
Copyright (c) 2023 Dell Inc., or its subsidiaries. All Rights Reserved.

Licensed under the Mozilla Public License Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://mozilla.org/MPL/2.0/


Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

resource "redfish_manager_reset" "manager_reset" {
for_each = var.rack1

redfish_server {
user = each.value.user
password = each.value.password
endpoint = each.value.endpoint
ssl_insecure = each.value.ssl_insecure
}

id = "iDRAC.Embedded.1"
reset_type = "GracefulRestart"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `id` (String) The value of the Id property of the Manager resource
- `reset_type` (String) The type of the reset operation to be performed. Accepted value: GracefulRestart

### Optional

- `redfish_server` (Block List) List of server BMCs and their respective user credentials (see [below for nested schema](#nestedblock--redfish_server))

<a id="nestedblock--redfish_server"></a>
### Nested Schema for `redfish_server`

Required:

- `endpoint` (String) Server BMC IP address or hostname

Optional:

- `password` (String, Sensitive) User password for login
- `ssl_insecure` (Boolean) This field indicates whether the SSL/TLS certificate must be verified or not
- `user` (String) User name for login
25 changes: 25 additions & 0 deletions examples/resources/redfish_manager_reset/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
Copyright (c) 2023 Dell Inc., or its subsidiaries. All Rights Reserved.

Licensed under the Mozilla Public License Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://mozilla.org/MPL/2.0/


Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

terraform {
required_providers {
redfish = {
version = "1.1.0"
source = "registry.terraform.io/dell/redfish"
}
}
}
30 changes: 30 additions & 0 deletions examples/resources/redfish_manager_reset/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Copyright (c) 2023 Dell Inc., or its subsidiaries. All Rights Reserved.

Licensed under the Mozilla Public License Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://mozilla.org/MPL/2.0/


Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

resource "redfish_manager_reset" "manager_reset" {
for_each = var.rack1

redfish_server {
user = each.value.user
password = each.value.password
endpoint = each.value.endpoint
ssl_insecure = each.value.ssl_insecure
}

id = "iDRAC.Embedded.1"
reset_type = "GracefulRestart"
}
31 changes: 31 additions & 0 deletions examples/resources/redfish_manager_reset/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Copyright (c) 2023 Dell Inc., or its subsidiaries. All Rights Reserved.

Licensed under the Mozilla Public License Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://mozilla.org/MPL/2.0/


Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

rack1 = {
"my-server-2" = {
user = "admin"
password = "passw0rd"
endpoint = "https://my-server-1.myawesomecompany.org"
ssl_insecure = true
},
"my-server-2" = {
user = "admin"
password = "passw0rd"
endpoint = "https://my-server-2.myawesomecompany.org"
ssl_insecure = true
},
}
25 changes: 25 additions & 0 deletions examples/resources/redfish_manager_reset/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
Copyright (c) 2023 Dell Inc., or its subsidiaries. All Rights Reserved.

Licensed under the Mozilla Public License Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://mozilla.org/MPL/2.0/


Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

variable "rack1" {
type = map(object({
user = string
password = string
endpoint = string
ssl_insecure = bool
}))
}
12 changes: 12 additions & 0 deletions redfish/models/manager_reset.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package models

import (
"github.com/hashicorp/terraform-plugin-framework/types"
)

// RedfishManagerReset to construct terraform schema for manager reset resource.
type RedfishManagerReset struct {
Id types.String `tfsdk:"id"`
ResetType types.String `tfsdk:"reset_type"`
RedfishServer []RedfishServer `tfsdk:"redfish_server"`
}
27 changes: 27 additions & 0 deletions redfish/provider/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"errors"
"fmt"
"log"
"net"
"net/url"
"terraform-provider-redfish/redfish/models"
"time"

Expand Down Expand Up @@ -254,3 +256,28 @@ func (p powerOperator) PowerOperation(resetType string, maximumWaitTime int64, c
tflog.Warn(p.ctx, "The system failed to update the server's power status within the maximum wait time specified!")
return system.PowerState, nil
}

// checkServerStatus checks iDRAC server status after provided interval until the provided timeout time
func checkServerStatus(ctx context.Context, endpoint string, interval int, timeout int) error {
var err error
addr, err := url.Parse(endpoint)
if err != nil {
return err
}

// Intial sleep until iDRAC reboot is triggered
time.Sleep(30 * time.Second)

for start := time.Now(); time.Since(start) < (time.Duration(timeout) * time.Second); {
tflog.Trace(ctx, "Checking server status...")
time.Sleep(time.Duration(interval) * time.Second)
_, err = net.Dial("tcp", net.JoinHostPort(addr.Hostname(), addr.Scheme))
if err == nil {
return nil
}
errctx := tflog.SetField(ctx, "error", err.Error())
tflog.Trace(errctx, "Site unreachable")
}

return err
}
1 change: 1 addition & 0 deletions redfish/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func (*redfishProvider) Resources(_ context.Context) []func() resource.Resource
NewDellIdracAttributesResource,
NewRedfishStorageVolumeResource,
NewBiosResource,
NewManagerResetResource,
}
}

Expand Down
Loading
Loading