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

Bios data-source migration to TPF #113

Merged
merged 10 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ run:
# If it's not please let us know.
# "/" will be replaced by current OS file path separator to properly work on Windows.
skip-files:
- "redfish/provider/data_source_redfish_bios.go"
- "redfish/provider/data_source_redfish_firmware_inventory.go"
- "redfish/provider/data_source_redfish_storage.go"
- "redfish/provider/data_source_redfish_system_boot.go"
Expand Down
188 changes: 188 additions & 0 deletions docs/data-sources/bios.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
---
# 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.

title: "redfish_bios data source"
linkTitle: "redfish_bios"
page_title: "redfish_bios Data Source - terraform-provider-redfish"
subcategory: ""
description: |-
Data source to fetch bios details via RedFish.
---

# redfish_bios (Data Source)

Data source to fetch bios details via RedFish.

This Terraform datasource is used to query existing Bios configuration. The information fetched from this block can be further used for resource block.
## Example Usage

variables.tf
```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.
*/

variable "rack1" {
type = map(object({
user = string
password = string
endpoint = string
ssl_insecure = bool
}))
}
```

terraform.tfvars
```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.
*/

rack1 = {
"my-server-1" = {
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
},
}
```

provider.tf
```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.
*/

terraform {
required_providers {
redfish = {
version = "1.1.0"
source = "registry.terraform.io/dell/redfish"
}
}
}
```

main.tf
```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.
*/

data "redfish_bios" "bios" {
for_each = var.rack1

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

output "bios_attributes" {
value = data.redfish_bios.bios
sensitive = true
}
```

After the successful execution of the above data block, we can see the output in the state file.

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

### Required

- `redfish_server` (Attributes) Redfish Server (see [below for nested schema](#nestedatt--redfish_server))

### Read-Only

- `attributes` (Map of String) BIOS attributes.
- `id` (String) ID of the BIOS data-source
- `odata_id` (String) OData ID of the BIOS data-source

<a id="nestedatt--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
- `user` (String) User name for login
- `validate_cert` (Boolean) This field indicates whether the SSL/TLS certificate must be verified or not

2 changes: 1 addition & 1 deletion examples/data-sources/redfish_bios/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ limitations under the License.
terraform {
required_providers {
redfish = {
version = "1.0.0"
version = "1.1.0"
source = "registry.terraform.io/dell/redfish"
}
}
Expand Down
13 changes: 13 additions & 0 deletions redfish/models/bios.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package models

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

// BiosDatasource to is struct for bios data-source
type BiosDatasource struct {
ID types.String `tfsdk:"id"`
OdataID types.String `tfsdk:"odata_id"`
RedfishServer RedfishServer `tfsdk:"redfish_server"`
Attributes types.Map `tfsdk:"attributes"`
}
Loading
Loading