Skip to content

Commit

Permalink
Bm firmware update (#5519)
Browse files Browse the repository at this point in the history
* SDK Changes

* Development and Documentation

* Added test and maturity param

* SDK update

* SDK update

* Go Version Update

* feature - BMVPC-124 - End user firmware management

* docs

* upgrade vpc-go-sdk version

* refine docs

* review comments

* schema name correction

---------

Co-authored-by: SunithaGudisagar <Sunitha.Gudisagar@ibm.com>
Co-authored-by: Deepak Selvakumar <77007253+deepaksibm@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 22, 2024
1 parent d291fe8 commit f2b2a82
Show file tree
Hide file tree
Showing 11 changed files with 130 additions and 319 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ require (
github.com/IBM/schematics-go-sdk v0.2.3
github.com/IBM/secrets-manager-go-sdk/v2 v2.0.4
github.com/IBM/vpc-beta-go-sdk v0.6.0
github.com/IBM/vpc-go-sdk v0.54.0
github.com/IBM/vpc-go-sdk v0.55.0
github.com/ScaleFT/sshkeys v0.0.0-20200327173127-6142f742bca5
github.com/akamai/AkamaiOPEN-edgegrid-golang v1.2.2
github.com/akamai/AkamaiOPEN-edgegrid-golang/v5 v5.0.0
Expand Down
319 changes: 2 additions & 317 deletions go.sum

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions ibm/service/vpc/data_source_ibm_is_bare_metal_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,11 @@ func DataSourceIBMIsBareMetalServer() *schema.Resource {
Computed: true,
Description: "image name",
},
isBareMetalServerFirmwareUpdateTypeAvailable: {
Type: schema.TypeString,
Computed: true,
Description: "The type of firmware update available",
},
isBareMetalServerProfile: {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -817,6 +822,11 @@ func dataSourceIBMISBareMetalServerRead(context context.Context, d *schema.Resou
if err = d.Set("identifier", *bms.ID); err != nil {
return diag.FromErr(fmt.Errorf("[ERROR] Error setting identifier: %s", err))
}
if bms.Firmware != nil && bms.Firmware.Update != nil {
if err = d.Set(isBareMetalServerFirmwareUpdateTypeAvailable, *bms.Firmware.Update); err != nil {
return diag.FromErr(fmt.Errorf("[ERROR] Error setting availble firmware update type: %s", err))
}
}

//enable secure boot
if err = d.Set(isBareMetalServerEnableSecureBoot, bms.EnableSecureBoot); err != nil {
Expand Down
28 changes: 28 additions & 0 deletions ibm/service/vpc/data_source_ibm_is_bare_metal_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,34 @@ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCKVmnMOlHKcZK8tpt3MP1lqOLAcqcJzhsvJcjscgVE
},
})
}

func TestAccIBMISBMSDataSource_firmwareUpdate(t *testing.T) {
var server string
resName := "data.ibm_is_bare_metal_server.test1"
vpcname := fmt.Sprintf("tf-vpc-%d", acctest.RandIntRange(10, 100))
name := fmt.Sprintf("tf-server-%d", acctest.RandIntRange(10, 100))
subnetname := fmt.Sprintf("tfip-subnet-%d", acctest.RandIntRange(10, 100))
publicKey := strings.TrimSpace(`
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCKVmnMOlHKcZK8tpt3MP1lqOLAcqcJzhsvJcjscgVERRN7/9484SOBJ3HSKxxNG5JN8owAjy5f9yYwcUg+JaUVuytn5Pv3aeYROHGGg+5G346xaq3DAwX6Y5ykr2fvjObgncQBnuU5KHWCECO/4h8uWuwh/kfniXPVjFToc+gnkqA+3RKpAecZhFXwfalQ9mMuYGFxn+fwn8cYEApsJbsEmb0iJwPiZ5hjFC8wREuiTlhPHDgkBLOiycd20op2nXzDbHfCHInquEe/gYxEitALONxm0swBOwJZwlTDOB7C6y2dzlrtxr1L59m7pCkWI4EtTRLvleehBoj3u7jB4usR
`)
sshname := fmt.Sprintf("tf-sshname-%d", acctest.RandIntRange(10, 100))

resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccCheckIBMISBMSDataSourceConfig(vpcname, subnetname, sshname, publicKey, name),
Check: resource.ComposeTestCheckFunc(
testAccCheckIBMISBareMetalServerExists("ibm_is_bare_metal_server.testacc_bms", server),
resource.TestCheckResourceAttr(
resName, "name", name),
resource.TestCheckResourceAttrSet("data.ibm_is_bare_metal_server.test1", "firmware_update_type_available"),
),
},
},
})
}
func TestAccIBMISBMSDataSourceVNI_basic(t *testing.T) {
var server string
resName := "data.ibm_is_bare_metal_server.test1"
Expand Down
8 changes: 8 additions & 0 deletions ibm/service/vpc/data_source_ibm_is_bare_metal_servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,11 @@ func DataSourceIBMIsBareMetalServers() *schema.Resource {
Computed: true,
Description: "image id",
},
isBareMetalServerFirmwareUpdateTypeAvailable: {
Type: schema.TypeString,
Computed: true,
Description: "The type of firmware update available",
},
isBareMetalServerProfile: {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -1080,6 +1085,9 @@ func dataSourceIBMISBareMetalServersRead(context context.Context, d *schema.Reso
}

l[isBareMetalServerImage] = *initialization.Image.ID
if bms.Firmware != nil && bms.Firmware.Update != nil {
l[isBareMetalServerFirmwareUpdateTypeAvailable] = *bms.Firmware.Update
}

keyListList := []string{}
for i := 0; i < len(initialization.Keys); i++ {
Expand Down
28 changes: 28 additions & 0 deletions ibm/service/vpc/data_source_ibm_is_bare_metal_servers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,34 @@ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCKVmnMOlHKcZK8tpt3MP1lqOLAcqcJzhsvJcjscgVE
})
}

func TestAccIBMISBMSsDataSource_firmwareUpdate(t *testing.T) {
resName := "data.ibm_is_bare_metal_servers.test1"
var server string
vpcname := fmt.Sprintf("tf-vpc-%d", acctest.RandIntRange(10, 100))
name := fmt.Sprintf("tf-server-%d", acctest.RandIntRange(10, 100))
subnetname := fmt.Sprintf("tfip-subnet-%d", acctest.RandIntRange(10, 100))
publicKey := strings.TrimSpace(`
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCKVmnMOlHKcZK8tpt3MP1lqOLAcqcJzhsvJcjscgVERRN7/9484SOBJ3HSKxxNG5JN8owAjy5f9yYwcUg+JaUVuytn5Pv3aeYROHGGg+5G346xaq3DAwX6Y5ykr2fvjObgncQBnuU5KHWCECO/4h8uWuwh/kfniXPVjFToc+gnkqA+3RKpAecZhFXwfalQ9mMuYGFxn+fwn8cYEApsJbsEmb0iJwPiZ5hjFC8wREuiTlhPHDgkBLOiycd20op2nXzDbHfCHInquEe/gYxEitALONxm0swBOwJZwlTDOB7C6y2dzlrtxr1L59m7pCkWI4EtTRLvleehBoj3u7jB4usR
`)
sshname := fmt.Sprintf("tf-sshname-%d", acctest.RandIntRange(10, 100))

resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckIBMISBMSsDataSourceConfig(vpcname, subnetname, sshname, publicKey, name),
Check: resource.ComposeTestCheckFunc(
testAccCheckIBMISBareMetalServerExists("ibm_is_bare_metal_server.testacc_bms", server),
resource.TestCheckResourceAttrSet(resName, "servers.0.name"),
resource.TestCheckResourceAttrSet(resName, "servers.0.id"),
resource.TestCheckResourceAttrSet(resName, "servers.0.firmware_update_type_available"),
),
},
},
})
}

func testAccCheckIBMISBMSsDataSourceConfig(vpcname, subnetname, sshname, publicKey, name string) string {
// status filter defaults to empty
return testAccCheckIBMISBareMetalServerConfig(vpcname, subnetname, sshname, publicKey, name) + fmt.Sprintf(`
Expand Down
9 changes: 9 additions & 0 deletions ibm/service/vpc/resource_ibm_is_bare_metal_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const (
isBareMetalServerStatusReasonsMoreInfo = "more_info"
isBareMetalServerDeleteType = "delete_type"
isBareMetalServerImage = "image"
isBareMetalServerFirmwareUpdateTypeAvailable = "firmware_update_type_available"
isBareMetalServerKeys = "keys"
isBareMetalServerUserData = "user_data"
isBareMetalServerNicName = "name"
Expand Down Expand Up @@ -218,6 +219,11 @@ func ResourceIBMIsBareMetalServer() *schema.Resource {
Computed: true,
Description: "The CRN for this bare metal server",
},
isBareMetalServerFirmwareUpdateTypeAvailable: {
Type: schema.TypeString,
Computed: true,
Description: "The type of firmware update available",
},
isBareMetalServerDisks: {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -1948,6 +1954,9 @@ func bareMetalServerGet(context context.Context, d *schema.ResourceData, meta in
}
d.Set(isBareMetalServerCPU, cpuList)
d.Set(isBareMetalServerCRN, *bms.CRN)
if bms.Firmware != nil && bms.Firmware.Update != nil {
d.Set(isBareMetalServerFirmwareUpdateTypeAvailable, *bms.Firmware.Update)
}

//enable secure boot
if err = d.Set(isBareMetalServerEnableSecureBoot, bms.EnableSecureBoot); err != nil {
Expand Down
29 changes: 29 additions & 0 deletions ibm/service/vpc/resource_ibm_is_bare_metal_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,35 @@ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCKVmnMOlHKcZK8tpt3MP1lqOLAcqcJzhsvJcjscgVE
})
}

func TestAccIBMISBareMetalServer_firmwareUpdate(t *testing.T) {
var server string
vpcname := fmt.Sprintf("tf-vpc-%d", acctest.RandIntRange(10, 100))
name := fmt.Sprintf("tf-server-%d", acctest.RandIntRange(10, 100))
subnetname := fmt.Sprintf("tfip-subnet-%d", acctest.RandIntRange(10, 100))
publicKey := strings.TrimSpace(`
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCKVmnMOlHKcZK8tpt3MP1lqOLAcqcJzhsvJcjscgVERRN7/9484SOBJ3HSKxxNG5JN8owAjy5f9yYwcUg+JaUVuytn5Pv3aeYROHGGg+5G346xaq3DAwX6Y5ykr2fvjObgncQBnuU5KHWCECO/4h8uWuwh/kfniXPVjFToc+gnkqA+3RKpAecZhFXwfalQ9mMuYGFxn+fwn8cYEApsJbsEmb0iJwPiZ5hjFC8wREuiTlhPHDgkBLOiycd20op2nXzDbHfCHInquEe/gYxEitALONxm0swBOwJZwlTDOB7C6y2dzlrtxr1L59m7pCkWI4EtTRLvleehBoj3u7jB4usR
`)
sshname := fmt.Sprintf("tf-sshname-%d", acctest.RandIntRange(10, 100))

resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
CheckDestroy: testAccCheckIBMISBareMetalServerDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckIBMISBareMetalServerConfig(vpcname, subnetname, sshname, publicKey, name),
Check: resource.ComposeTestCheckFunc(
testAccCheckIBMISBareMetalServerExists("ibm_is_bare_metal_server.testacc_bms", server),
resource.TestCheckResourceAttr(
"ibm_is_bare_metal_server.testacc_bms", "name", name),
resource.TestCheckResourceAttrSet(
"ibm_is_bare_metal_server.testacc_bms", "firmware_update_type_available"),
),
},
},
})
}

func TestAccIBMISBareMetalServer_bandwidth(t *testing.T) {
var server string
vpcname := fmt.Sprintf("tf-vpc-%d", acctest.RandIntRange(10, 100))
Expand Down
6 changes: 6 additions & 0 deletions website/docs/d/is_bare_metal_server.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ In addition to all argument reference list, you can access the following attribu
- `profile` - (String) The name for this bare metal server profile
- `resource_group` - (String) resource group id of the bare metal server.
- `resource_type` - (String) The type of resource referenced
- `firmware_update_type_available` - (String) The firmware update type available for the bare metal server.

-> **Supported firmware update types**
</br>&#x2022; none
</br>&#x2022; optional
</br>&#x2022; required
- `status` - (String) The status of the bare metal server.

-> **Supported Status**
Expand Down
6 changes: 6 additions & 0 deletions website/docs/d/is_bare_metal_servers.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ Review the attribute references that you can access after you retrieve your data
- `profile` - (String) The name for this bare metal server profile
- `resource_group` - (String) resource group id of the bare metal server.
- `resource_type` - (String) The type of resource referenced
- `firmware_update_type_available` - (String) The firmware update type available for the bare metal server.

->**Supported firmware update types**
</br>&#x2022; none
</br>&#x2022; optional
</br>&#x2022; required
- `status` - (String) The status of the bare metal server.

->**Supported Status:**
Expand Down
4 changes: 3 additions & 1 deletion website/docs/r/is_bare_metal_server.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: |-
Manages IBM bare metal sever.
---

# ibm\_is_bare_metal_server
# ibm_is_bare_metal_server

Create, update, or delete a Bare Metal Server for VPC. For more information, about managing VPC Bare Metal Server, see [About Bare Metal Servers for VPC](https://cloud.ibm.com/docs/vpc?topic=vpc-about-bare-metal-servers).

Expand Down Expand Up @@ -328,6 +328,8 @@ In addition to all argument reference list, you can access the following attribu
- `vlan` - (Integer) Indicates the 802.1Q VLAN ID tag that must be used for all traffic on this interface. [ conflicts with `allowed_vlans`]

- `resource_type` - (String) The type of resource.
- `firmware_update_type_available` - (String) The firmware update type available for the bare metal server.
-> **Supported firmware update types** </br>&#x2022; none </br>&#x2022; optional </br>&#x2022; required
- `status` - (String) The status of the bare metal server.

-> **Supported Status** &#x2022; failed </br>&#x2022; pending </br>&#x2022; restarting </br>&#x2022; running </br>&#x2022; starting </br>&#x2022; stopped </br>&#x2022; stopping
Expand Down

0 comments on commit f2b2a82

Please sign in to comment.