Skip to content

Commit

Permalink
update change with new sdk version
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkad committed Feb 11, 2025
1 parent 8fe9999 commit 4633210
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 8 deletions.
4 changes: 2 additions & 2 deletions ibm/service/power/ibm_pi_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ const (
Arg_VTL = "vtl"

// Attributes
Attr_NetworkSecurityGroupIDs = "network_security_group_ids"
Attr_Access = "access"
Attr_AccessConfig = "access_config"
Attr_Action = "action"
Expand Down Expand Up @@ -345,10 +344,11 @@ const (
Attr_NetworkInterfaceID = "network_interface_id"
Attr_NetworkName = "network_name"
Attr_NetworkPeers = "network_peers"
Attr_NetworkPorts = "network_ports"
Attr_NetworkPortID = "network_port_id"
Attr_NetworkPorts = "network_ports"
Attr_Networks = "networks"
Attr_NetworkSecurityGroupID = "network_security_group_id"
Attr_NetworkSecurityGroupIDs = "network_security_group_ids"
Attr_NetworkSecurityGroupMemberID = "network_security_group_member_id"
Attr_NetworkSecurityGroups = "network_security_groups"
Attr_NetworkSecurityGroupsHref = "network_security_groups_href"
Expand Down
2 changes: 1 addition & 1 deletion ibm/service/power/resource_ibm_pi_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -639,13 +639,13 @@ func resourceIBMPIInstanceRead(ctx context.Context, d *schema.ResourceData, meta
for _, n := range powervmdata.Networks {
if n != nil {
v := map[string]interface{}{
Attr_ExternalIP: n.ExternalIP,
Attr_IPAddress: n.IPAddress,
Attr_MacAddress: n.MacAddress,
Attr_NetworkID: n.NetworkID,
Attr_NetworkInterfaceID: n.NetworkInterfaceID,
Attr_NetworkName: n.NetworkName,
Attr_Type: n.Type,
Attr_ExternalIP: n.ExternalIP,
}
if len(n.NetworkSecurityGroupIDs) > 0 {
v[Attr_NetworkSecurityGroupIDs] = n.NetworkSecurityGroupIDs
Expand Down
50 changes: 47 additions & 3 deletions ibm/service/power/resource_ibm_pi_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ func testAccCheckIBMPIInstanceUserTagsConfig(name, instanceHealthStatus string,
func testAccCheckIBMPIInstanceStorageConnectionConfig(name, instanceHealthStatus string) string {
return fmt.Sprintf(`
resource "ibm_pi_volume" "power_volume" {
pi_cloud_instance_id = "%[1]s"
pi_volume_size = 1
pi_volume_name = "%[2]s"
pi_cloud_instance_id = "%[1]s"
pi_volume_size = 1
pi_volume_name = "%[2]s"
pi_volume_type = "tier3"
}
resource "ibm_pi_instance" "power_instance" {
Expand All @@ -323,6 +323,50 @@ func testAccCheckIBMPIInstanceStorageConnectionConfig(name, instanceHealthStatus
}
`, acc.Pi_cloud_instance_id, name, acc.Pi_image, acc.Pi_network_name, acc.Pi_storage_connection, instanceHealthStatus)
}
func testAccCheckIBMPIInstanceNetworkSecurityGroupConfig(name, instanceHealthStatus string) string {
return fmt.Sprintf(`
resource "ibm_pi_volume" "power_volume" {
pi_cloud_instance_id = "%[1]s"
pi_volume_size = 1
pi_volume_name = "%[2]s"
pi_volume_type = "tier3"
}
resource "ibm_pi_instance" "power_instance" {
pi_cloud_instance_id = "%[1]s"
pi_memory = "2"
pi_processors = "1"
pi_instance_name = "%[2]s"
pi_proc_type = "shared"
pi_image_id = "%[3]s"
pi_sys_type = "s922"
pi_network {
network_id = "%[4]s"
network_security_group_ids = ["%[6]s"]
}
pi_health_status = "%[5]s"
pi_volume_ids = [ibm_pi_volume.power_volume.volume_id]
}
`, acc.Pi_cloud_instance_id, name, acc.Pi_image, acc.Pi_network_name, instanceHealthStatus, acc.Pi_network_security_group_id)
}
func TestAccIBMPIInstanceNetworkSecurityGroup(t *testing.T) {
instanceRes := "ibm_pi_instance.power_instance"
name := fmt.Sprintf("tf-pi-instance-%d", acctest.RandIntRange(10, 100))
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
CheckDestroy: testAccCheckIBMPIInstanceDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckIBMPIInstanceNetworkSecurityGroupConfig(name, power.OK),
Check: resource.ComposeTestCheckFunc(
testAccCheckIBMPIInstanceExists(instanceRes),
resource.TestCheckResourceAttr(instanceRes, "pi_instance_name", name),
resource.TestCheckResourceAttr(instanceRes, "pi_network.0.network_security_group_ids.0", acc.Pi_network_security_group_id),
),
},
},
})
}
func testAccCheckIBMPIInstanceDestroy(s *terraform.State) error {
sess, err := acc.TestAccProvider.Meta().(conns.ClientSession).IBMPISession()
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion website/docs/d/pi_instances.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,3 @@ In addition to all argument reference list, you can access the following attribu
Nested scheme for `virtual_serial_number`:
- `description` - (String) Description for virtual serial number.
- `serial` - (String) Virtual serial number.

5 changes: 4 additions & 1 deletion website/docs/r/pi_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,15 @@ In addition to all argument reference list, you can access the following attribu
- `pin_policy` - (String) The pinning policy of the instance.
- `pi_network` - (List of Map) - A list of networks that are assigned to the instance.
Nested scheme for `pi_network`:
- `external_ip` - (String) The external IP address of the network.
- `ip_address` - (String) The IP address of the network.
- `mac_address` - (String) The MAC address of the network.
- `network_id` - (String) The ID of the network.
- `network_interface_id` - (String) ID of the network interface.
- `network_name` - (String) The name of the network.
- `network_security_group_ids` - (List) The Network security groups that the network interface is a member of. There is a limit of 1 network security group in the array. If not specified, default network security group is used.
- `network_security_groups_href` - (List) Links to the network security groups that the network interface is a member of.
- `type` - (String) The type of network.
- `external_ip` - (String) The external IP address of the network.
- `progress` - (Float) - Specifies the overall progress of the instance deployment process in percentage.
- `shared_processor_pool_id` - (String) The ID of the shared processor pool for the instance.
- `status` - (String) The status of the instance.
Expand Down

0 comments on commit 4633210

Please sign in to comment.