From 2e512fc7bd6602e873794064663177108cf5edbe Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Wed, 20 Nov 2024 10:11:54 -0600 Subject: [PATCH] Refactor Network Port --- ibm/service/power/ibm_pi_constants.go | 6 +- .../resource_ibm_pi_network_port_attach.go | 157 +++++++++--------- ...esource_ibm_pi_network_port_attach_test.go | 129 ++++++++++---- website/docs/d/pi_network_port.html.markdown | 8 +- .../r/pi_network_port_attach.html.markdown | 30 ++-- 5 files changed, 208 insertions(+), 122 deletions(-) diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index aac2683c62..dc44d0f938 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -53,6 +53,8 @@ const ( Arg_NetworkID = "pi_network_id" Arg_NetworkInterfaceID = "pi_network_interface_id" Arg_NetworkName = "pi_network_name" + Arg_NetworkPortDescription = "pi_network_port_description" + Arg_NetworkPortIPAddress = "pi_network_port_ipaddress" Arg_NetworkSecurityGroupID = "pi_network_security_group_id" Arg_NetworkSecurityGroupMemberID = "pi_network_security_group_member_id" Arg_NetworkSecurityGroupRuleID = "pi_network_security_group_rule_id" @@ -64,9 +66,6 @@ const ( Arg_Processors = "pi_processors" Arg_ProcType = "pi_proc_type" Arg_Protocol = "pi_protocol" - Arg_PVMInstanceActionType = "pi_action" - Arg_PVMInstanceHealthStatus = "pi_health_status" - Arg_PVMInstanceId = "pi_instance_id" Arg_Remote = "pi_remote" Arg_Remove = "pi_remove" Arg_Replicants = "pi_replicants" @@ -294,6 +293,7 @@ const ( Attr_NetworkInterfaceID = "network_interface_id" Attr_NetworkName = "network_name" Attr_NetworkPorts = "network_ports" + Attr_NetworkPortID = "network_port_id" Attr_Networks = "networks" Attr_NetworkSecurityGroupID = "network_security_group_id" Attr_NetworkSecurityGroupMemberID = "network_security_group_member_id" diff --git a/ibm/service/power/resource_ibm_pi_network_port_attach.go b/ibm/service/power/resource_ibm_pi_network_port_attach.go index 99bb5adb05..c24992ac8e 100644 --- a/ibm/service/power/resource_ibm_pi_network_port_attach.go +++ b/ibm/service/power/resource_ibm_pi_network_port_attach.go @@ -7,22 +7,21 @@ import ( "context" "fmt" "log" + "strings" "time" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - - st "github.com/IBM-Cloud/power-go-client/clients/instance" - "github.com/IBM-Cloud/power-go-client/helpers" + "github.com/IBM-Cloud/power-go-client/clients/instance" "github.com/IBM-Cloud/power-go-client/power/models" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) func ResourceIBMPINetworkPortAttach() *schema.Resource { return &schema.Resource{ - CreateContext: resourceIBMPINetworkPortAttachCreate, ReadContext: resourceIBMPINetworkPortAttachRead, DeleteContext: resourceIBMPINetworkPortAttachDelete, @@ -33,35 +32,40 @@ func ResourceIBMPINetworkPortAttach() *schema.Resource { Delete: schema.DefaultTimeout(60 * time.Minute), }, Schema: map[string]*schema.Schema{ - helpers.PICloudInstanceId: { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Arg_CloudInstanceID: { + Description: "The GUID of the service instance associated with an account.", + ForceNew: true, + Required: true, + Type: schema.TypeString, + ValidateFunc: validation.NoZeroValues, }, - helpers.PIInstanceId: { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "Instance id to attach the network port to", + Arg_InstanceID: { + Description: "Instance id to attach the network port to.", + ForceNew: true, + Required: true, + Type: schema.TypeString, + ValidateFunc: validation.NoZeroValues, }, - helpers.PINetworkName: { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "Network Name - This is the subnet name in the Cloud instance", + Arg_NetworkName: { + Description: "The network ID or name.", + ForceNew: true, + Required: true, + Type: schema.TypeString, + ValidateFunc: validation.NoZeroValues, }, - helpers.PINetworkPortDescription: { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: "A human readable description for this network Port", + Arg_NetworkPortDescription: { Default: "Port Created via Terraform", + Description: "The description for the Network Port.", + ForceNew: true, + Optional: true, + Type: schema.TypeString, }, - helpers.PINetworkPortIPAddress: { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Computed: true, + Arg_NetworkPortIPAddress: { + Computed: true, + Description: "The requested ip address of this port", + ForceNew: true, + Optional: true, + Type: schema.TypeString, }, Arg_UserTags: { Description: "The user tags attached to this resource.", @@ -72,22 +76,26 @@ func ResourceIBMPINetworkPortAttach() *schema.Resource { Type: schema.TypeSet, }, - //Computed Attributes - "macaddress": { - Type: schema.TypeString, - Computed: true, + // Attributes + Attr_MacAddress: { + Computed: true, + Description: "The MAC address of the port.", + Type: schema.TypeString, }, - "network_port_id": { - Type: schema.TypeString, - Computed: true, + Attr_NetworkPortID: { + Computed: true, + Description: "The ID of the port.", + Type: schema.TypeString, }, - "status": { - Type: schema.TypeString, - Computed: true, + Attr_PublicIP: { + Computed: true, + Description: "The public IP associated with the port.", + Type: schema.TypeString, }, - "public_ip": { - Type: schema.TypeString, - Computed: true, + Attr_Status: { + Computed: true, + Description: "The status of the port.", + Type: schema.TypeString, }, }, } @@ -99,13 +107,13 @@ func resourceIBMPINetworkPortAttachCreate(ctx context.Context, d *schema.Resourc if err != nil { return diag.FromErr(err) } - cloudInstanceID := d.Get(helpers.PICloudInstanceId).(string) - networkname := d.Get(helpers.PINetworkName).(string) - instanceID := d.Get(helpers.PIInstanceId).(string) - description := d.Get(helpers.PINetworkPortDescription).(string) + cloudInstanceID := d.Get(Arg_CloudInstanceID).(string) + description := d.Get(Arg_NetworkPortDescription).(string) + instanceID := d.Get(Arg_InstanceID).(string) + networkname := d.Get(Arg_NetworkName).(string) nwportBody := &models.NetworkPortCreate{Description: description} - if v, ok := d.GetOk(helpers.PINetworkPortIPAddress); ok { + if v, ok := d.GetOk(Arg_NetworkPortIPAddress); ok { ipaddress := v.(string) nwportBody.IPAddress = ipaddress } @@ -117,7 +125,7 @@ func resourceIBMPINetworkPortAttachCreate(ctx context.Context, d *schema.Resourc PvmInstanceID: &instanceID, } - client := st.NewIBMPINetworkClient(ctx, sess, cloudInstanceID) + client := instance.NewIBMPINetworkClient(ctx, sess, cloudInstanceID) networkPortResponse, err := client.CreatePort(networkname, nwportBody) if err != nil { @@ -162,19 +170,19 @@ func resourceIBMPINetworkPortAttachRead(ctx context.Context, d *schema.ResourceD networkname := parts[1] portID := parts[2] - networkC := st.NewIBMPINetworkClient(ctx, sess, cloudInstanceID) + networkC := instance.NewIBMPINetworkClient(ctx, sess, cloudInstanceID) networkdata, err := networkC.GetPort(networkname, portID) if err != nil { return diag.FromErr(err) } - d.Set(helpers.PINetworkPortIPAddress, networkdata.IPAddress) - d.Set(helpers.PINetworkPortDescription, networkdata.Description) - d.Set(helpers.PIInstanceId, networkdata.PvmInstance.PvmInstanceID) - d.Set("macaddress", networkdata.MacAddress) - d.Set("status", networkdata.Status) - d.Set("network_port_id", networkdata.PortID) - d.Set("public_ip", networkdata.ExternalIP) + d.Set(Arg_InstanceID, networkdata.PvmInstance.PvmInstanceID) + d.Set(Arg_NetworkPortDescription, networkdata.Description) + d.Set(Arg_NetworkPortIPAddress, networkdata.IPAddress) + d.Set(Attr_MacAddress, networkdata.MacAddress) + d.Set(Attr_NetworkPortID, networkdata.PortID) + d.Set(Attr_PublicIP, networkdata.ExternalIP) + d.Set(Attr_Status, networkdata.Status) return nil } @@ -195,7 +203,7 @@ func resourceIBMPINetworkPortAttachDelete(ctx context.Context, d *schema.Resourc networkname := parts[1] portID := parts[2] - client := st.NewIBMPINetworkClient(ctx, sess, cloudInstanceID) + client := instance.NewIBMPINetworkClient(ctx, sess, cloudInstanceID) log.Printf("Calling the delete with the following params delete with cloud instance (%s) and networkid (%s) and portid (%s) ", cloudInstanceID, networkname, portID) err = client.DeletePort(networkname, portID) @@ -207,12 +215,12 @@ func resourceIBMPINetworkPortAttachDelete(ctx context.Context, d *schema.Resourc return nil } -func isWaitForIBMPINetworkportAvailable(ctx context.Context, client *st.IBMPINetworkClient, id string, networkname string, timeout time.Duration) (interface{}, error) { +func isWaitForIBMPINetworkportAvailable(ctx context.Context, client *instance.IBMPINetworkClient, id string, networkname string, timeout time.Duration) (interface{}, error) { log.Printf("Waiting for Power Network (%s) that was created for Network Zone (%s) to be available.", id, networkname) - stateConf := &resource.StateChangeConf{ - Pending: []string{"retry", helpers.PINetworkProvisioning}, - Target: []string{"DOWN"}, + stateConf := &retry.StateChangeConf{ + Pending: []string{State_Retry, State_Build}, + Target: []string{State_Down}, Refresh: isIBMPINetworkportRefreshFunc(client, id, networkname), Timeout: timeout, Delay: 10 * time.Second, @@ -222,7 +230,7 @@ func isWaitForIBMPINetworkportAvailable(ctx context.Context, client *st.IBMPINet return stateConf.WaitForStateContext(ctx) } -func isIBMPINetworkportRefreshFunc(client *st.IBMPINetworkClient, id, networkname string) resource.StateRefreshFunc { +func isIBMPINetworkportRefreshFunc(client *instance.IBMPINetworkClient, id, networkname string) retry.StateRefreshFunc { log.Printf("Calling the IsIBMPINetwork Refresh Function....with the following id (%s) for network port and following id (%s) for network name and waiting for network to be READY", id, networkname) return func() (interface{}, string, error) { @@ -231,20 +239,21 @@ func isIBMPINetworkportRefreshFunc(client *st.IBMPINetworkClient, id, networknam return nil, "", err } - if *network.Status == "DOWN" { + if strings.ToLower(*network.Status) == State_Down { log.Printf(" The port has been created with the following ip address and attached to an instance ") - return network, "DOWN", nil + return network, State_Down, nil } - return network, helpers.PINetworkProvisioning, nil + return network, State_Build, nil } } -func isWaitForIBMPINetworkPortAttachAvailable(ctx context.Context, client *st.IBMPINetworkClient, id, networkname, instanceid string, timeout time.Duration) (interface{}, error) { + +func isWaitForIBMPINetworkPortAttachAvailable(ctx context.Context, client *instance.IBMPINetworkClient, id, networkname, instanceid string, timeout time.Duration) (interface{}, error) { log.Printf("Waiting for Power Network (%s) that was created for Network Zone (%s) to be available.", id, networkname) - stateConf := &resource.StateChangeConf{ - Pending: []string{"retry", helpers.PINetworkProvisioning}, - Target: []string{"ACTIVE"}, + stateConf := &retry.StateChangeConf{ + Pending: []string{State_Retry, State_Build}, + Target: []string{State_Active}, Refresh: isIBMPINetworkPortAttachRefreshFunc(client, id, networkname, instanceid), Timeout: timeout, Delay: 10 * time.Second, @@ -254,7 +263,7 @@ func isWaitForIBMPINetworkPortAttachAvailable(ctx context.Context, client *st.IB return stateConf.WaitForStateContext(ctx) } -func isIBMPINetworkPortAttachRefreshFunc(client *st.IBMPINetworkClient, id, networkname, instanceid string) resource.StateRefreshFunc { +func isIBMPINetworkPortAttachRefreshFunc(client *instance.IBMPINetworkClient, id, networkname, instanceid string) retry.StateRefreshFunc { log.Printf("Calling the IsIBMPINetwork Refresh Function....with the following id (%s) for network port and following id (%s) for network name and waiting for network to be READY", id, networkname) return func() (interface{}, string, error) { @@ -263,11 +272,11 @@ func isIBMPINetworkPortAttachRefreshFunc(client *st.IBMPINetworkClient, id, netw return nil, "", err } - if *network.Status == "ACTIVE" && network.PvmInstance.PvmInstanceID == instanceid { + if strings.ToLower(*network.Status) == State_Active && network.PvmInstance.PvmInstanceID == instanceid { log.Printf(" The port has been created with the following ip address and attached to an instance ") - return network, "ACTIVE", nil + return network, State_Active, nil } - return network, helpers.PINetworkProvisioning, nil + return network, State_Build, nil } } diff --git a/ibm/service/power/resource_ibm_pi_network_port_attach_test.go b/ibm/service/power/resource_ibm_pi_network_port_attach_test.go index 7980808608..ec6ccd4431 100644 --- a/ibm/service/power/resource_ibm_pi_network_port_attach_test.go +++ b/ibm/service/power/resource_ibm_pi_network_port_attach_test.go @@ -10,29 +10,32 @@ import ( "testing" acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" + + "github.com/IBM-Cloud/power-go-client/clients/instance" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - - st "github.com/IBM-Cloud/power-go-client/clients/instance" ) func TestAccIBMPINetworkPortAttachbasic(t *testing.T) { - name := fmt.Sprintf("tf-pi-network-port-attach-%d", acctest.RandIntRange(10, 100)) + name := fmt.Sprintf("tf-pi-instance-%d", acctest.RandIntRange(10, 100)) + networkName := fmt.Sprintf("tf-pi-network-port-attach-test-%d", acctest.RandIntRange(10, 100)) + networkName2 := fmt.Sprintf("tf-pi-network-port-attach-test-%d", acctest.RandIntRange(10, 100)) + health := "OK" + resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, CheckDestroy: testAccCheckIBMPINetworkPortAttachDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckIBMPINetworkPortAttachConfig(name), + Config: testAccCheckIBMPINetworkPortAttachConfig(name, networkName, networkName2, health), Check: resource.ComposeTestCheckFunc( testAccCheckIBMPINetworkPortAttachExists("ibm_pi_network_port_attach.power_network_port_attach"), resource.TestCheckResourceAttr( - "ibm_pi_network_port_attach.power_network_port_attach", "pi_network_name", name), + "ibm_pi_network_port_attach.power_network_port_attach", "pi_network_name", networkName2), resource.TestCheckResourceAttrSet("ibm_pi_network_port_attach.power_network_port_attach", "id"), resource.TestCheckResourceAttrSet("ibm_pi_network_port_attach.power_network_port_attach", "network_port_id"), resource.TestCheckResourceAttrSet("ibm_pi_network_port_attach.power_network_port_attach", "public_ip"), @@ -43,18 +46,22 @@ func TestAccIBMPINetworkPortAttachbasic(t *testing.T) { } func TestAccIBMPINetworkPortAttachVlanbasic(t *testing.T) { - name := fmt.Sprintf("tf-pi-network-port-attach-%d", acctest.RandIntRange(10, 100)) + name := fmt.Sprintf("tf-pi-instance-%d", acctest.RandIntRange(10, 100)) + networkName := fmt.Sprintf("tf-pi-network-port-attach-test-%d", acctest.RandIntRange(10, 100)) + networkName2 := fmt.Sprintf("tf-pi-network-port-attach-test-%d", acctest.RandIntRange(10, 100)) + health := "OK" + resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, CheckDestroy: testAccCheckIBMPINetworkPortAttachDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckIBMPINetworkPortAttachVlanConfig(name), + Config: testAccCheckIBMPINetworkPortAttachVlanConfig(name, networkName, networkName2, health), Check: resource.ComposeTestCheckFunc( testAccCheckIBMPINetworkPortAttachExists("ibm_pi_network_port_attach.power_network_port_attach"), resource.TestCheckResourceAttr( - "ibm_pi_network_port_attach.power_network_port_attach", "pi_network_name", name), + "ibm_pi_network_port_attach.power_network_port_attach", "pi_network_name", networkName2), resource.TestCheckResourceAttrSet("ibm_pi_network_port_attach.power_network_port_attach", "id"), resource.TestCheckResourceAttrSet("ibm_pi_network_port_attach.power_network_port_attach", "network_port_id"), ), @@ -62,6 +69,7 @@ func TestAccIBMPINetworkPortAttachVlanbasic(t *testing.T) { }, }) } + func testAccCheckIBMPINetworkPortAttachDestroy(s *terraform.State) error { sess, err := acc.TestAccProvider.Meta().(conns.ClientSession).IBMPISession() if err != nil { @@ -78,7 +86,7 @@ func testAccCheckIBMPINetworkPortAttachDestroy(s *terraform.State) error { cloudInstanceID := parts[0] networkname := parts[1] portID := parts[2] - networkC := st.NewIBMPINetworkClient(context.Background(), sess, cloudInstanceID) + networkC := instance.NewIBMPINetworkClient(context.Background(), sess, cloudInstanceID) _, err = networkC.GetPort(networkname, portID) if err == nil { return fmt.Errorf("PI Network Port still exists: %s", rs.Primary.ID) @@ -87,6 +95,7 @@ func testAccCheckIBMPINetworkPortAttachDestroy(s *terraform.State) error { return nil } + func testAccCheckIBMPINetworkPortAttachExists(n string) resource.TestCheckFunc { return func(s *terraform.State) error { @@ -111,35 +120,95 @@ func testAccCheckIBMPINetworkPortAttachExists(n string) resource.TestCheckFunc { cloudInstanceID := parts[0] networkname := parts[1] portID := parts[2] - client := st.NewIBMPINetworkClient(context.Background(), sess, cloudInstanceID) + client := instance.NewIBMPINetworkClient(context.Background(), sess, cloudInstanceID) _, err = client.GetPort(networkname, portID) if err != nil { return err } return nil - } } -func testAccCheckIBMPINetworkPortAttachConfig(name string) string { - return testAccCheckIBMPINetworkConfig(name) + fmt.Sprintf(` - resource "ibm_pi_network_port_attach" "power_network_port_attach" { - pi_cloud_instance_id = "%s" - pi_network_name = ibm_pi_network.power_networks.pi_network_name - pi_network_port_description = "IP Reserved for Test UAT" - pi_instance_id = "%s" - } - `, acc.Pi_cloud_instance_id, acc.Pi_instance_name) +func testAccCheckIBMPINetworkPortAttachConfig(name, networkName, networkName2, health string) string { + return fmt.Sprintf(` + data "ibm_pi_image" "power_image" { + pi_cloud_instance_id = "%[1]s" + pi_image_name = "%[3]s" + } + resource "ibm_pi_network" "power_networks" { + pi_cloud_instance_id = "%[1]s" + pi_cidr = "192.168.15.0/24" + pi_network_name = "%[5]s" + pi_network_type = "vlan" + } + resource "ibm_pi_network" "power_networks2" { + pi_cloud_instance_id = "%[1]s" + pi_network_name = "%[6]s" + pi_network_type = "pub-vlan" + } + resource "ibm_pi_instance" "power_instance" { + pi_cloud_instance_id = "%[1]s" + pi_image_id = data.ibm_pi_image.power_image.id + pi_instance_name = "%[2]s" + pi_memory = "2" + pi_proc_type = "shared" + pi_processors = "0.25" + pi_storage_pool = data.ibm_pi_image.power_image.storage_pool + pi_storage_type = "%[4]s" + pi_health_status = "%[7]s" + pi_sys_type = "s922" + pi_network { + network_id = resource.ibm_pi_network.power_networks.network_id + } + } + resource "ibm_pi_network_port_attach" "power_network_port_attach" { + pi_cloud_instance_id = "%[1]s" + pi_instance_id = resource.ibm_pi_instance.power_instance.instance_id + pi_network_name = resource.ibm_pi_network.power_networks2.pi_network_name + pi_network_port_description = "IP Reserved for Test UAT" + } + `, acc.Pi_cloud_instance_id, name, acc.Pi_image, acc.PiStorageType, networkName, networkName2, health) } -func testAccCheckIBMPINetworkPortAttachVlanConfig(name string) string { - return testAccCheckIBMPINetworkGatewayConfig(name) + fmt.Sprintf(` - resource "ibm_pi_network_port_attach" "power_network_port_attach" { - pi_cloud_instance_id = "%s" - pi_network_name = ibm_pi_network.power_networks.pi_network_name - pi_network_port_description = "IP Reserved for Test UAT" - pi_instance_id = "%s" - } - `, acc.Pi_cloud_instance_id, acc.Pi_instance_name) +func testAccCheckIBMPINetworkPortAttachVlanConfig(name, networkName, networkName2, health string) string { + return fmt.Sprintf(` + data "ibm_pi_image" "power_image" { + pi_cloud_instance_id = "%[1]s" + pi_image_name = "%[3]s" + } + resource "ibm_pi_network" "power_networks" { + pi_cloud_instance_id = "%[1]s" + pi_cidr = "192.168.15.0/24" + pi_network_name = "%[5]s" + pi_network_type = "vlan" + } + resource "ibm_pi_network" "power_networks2" { + pi_cloud_instance_id = "%[1]s" + pi_cidr = "192.97.57.0/24" + pi_network_name = "%[6]s" + pi_network_type = "vlan" + } + resource "ibm_pi_instance" "power_instance" { + pi_cloud_instance_id = "%[1]s" + pi_image_id = data.ibm_pi_image.power_image.id + pi_instance_name = "%[2]s" + pi_memory = "2" + pi_proc_type = "shared" + pi_processors = "0.25" + pi_storage_pool = data.ibm_pi_image.power_image.storage_pool + pi_storage_type = "%[4]s" + pi_health_status = "%[7]s" + pi_sys_type = "s922" + pi_network { + network_id = resource.ibm_pi_network.power_networks.network_id + } + } + resource "ibm_pi_network_port_attach" "power_network_port_attach" { + pi_cloud_instance_id = "%[1]s" + pi_instance_id = resource.ibm_pi_instance.power_instance.instance_id + pi_network_name = ibm_pi_network.power_networks2.pi_network_name + pi_network_port_description = "IP Reserved for Test UAT" + } + `, acc.Pi_cloud_instance_id, name, acc.Pi_image, acc.PiStorageType, networkName, networkName2, health) } diff --git a/website/docs/d/pi_network_port.html.markdown b/website/docs/d/pi_network_port.html.markdown index 9d46bee2d0..7950cc2e04 100644 --- a/website/docs/d/pi_network_port.html.markdown +++ b/website/docs/d/pi_network_port.html.markdown @@ -7,9 +7,11 @@ description: |- --- # ibm_pi_network_port + Retrieve information about a network port in the Power Virtual Server Cloud. For more information, about networks in IBM power virtual server, see [adding or removing a public network](https://cloud.ibm.com/docs/power-iaas?topic=power-iaas-modifying-server#adding-removing-network). ## Example usage + ```terraform data "ibm_pi_network_port" "test-network-port" { pi_network_name = "Zone1-CFN" @@ -17,13 +19,15 @@ data "ibm_pi_network_port" "test-network-port" { } ``` -**Notes** +### Notes + - Please find [supported Regions](https://cloud.ibm.com/apidocs/power-cloud#endpoint) for endpoints. - If a Power cloud instance is provisioned at `lon04`, The provider level attributes should be as follows: - `region` - `lon` - `zone` - `lon04` Example usage: + ```terraform provider "ibm" { region = "lon" @@ -32,12 +36,14 @@ Example usage: ``` ## Argument reference + Review the argument references that you can specify for your data source. - `pi_cloud_instance_id` - (Required, String) The GUID of the service instance associated with an account. - `pi_network_name` - (Required, String) The unique identifier or name of a network. ## Attribute reference + In addition to all argument reference list, you can access the following attribute reference after your data source is created. - `network_ports` - (List) List of all in use network ports for a network. diff --git a/website/docs/r/pi_network_port_attach.html.markdown b/website/docs/r/pi_network_port_attach.html.markdown index e55c6badc4..232098d66d 100644 --- a/website/docs/r/pi_network_port_attach.html.markdown +++ b/website/docs/r/pi_network_port_attach.html.markdown @@ -8,8 +8,8 @@ description: |- --- # ibm_pi_network_port_attach -Attaches network port in the Power Virtual Server Cloud. For more information, about network in IBM power virutal server, see [adding or removing a public network -](https://cloud.ibm.com/docs/power-iaas?topic=power-iaas-modifying-server#adding-removing-network).. + +Attaches a network port to a Power Systems Virtual Server instance. For more information, see [getting started with IBM Power Systems Virtual Servers](https://cloud.ibm.com/docs/power-iaas?topic=power-iaas-getting-started). ## Example usage @@ -24,13 +24,14 @@ resource "ibm_pi_network_port_attach" "test-network-port-attach" { } ``` -**Note** -* Please find [supported Regions](https://cloud.ibm.com/apidocs/power-cloud#endpoint) for endpoints. -* If a Power cloud instance is provisioned at `lon04`, The provider level attributes should be as follows: - * `region` - `lon` - * `zone` - `lon04` +### Notes + +- Please find [supported Regions](https://cloud.ibm.com/apidocs/power-cloud#endpoint) for endpoints. +- If a Power cloud instance is provisioned at `lon04`, The provider level attributes should be as follows: + - `region` - `lon` + - `zone` - `lon04` - Example usage: +Example usage: ```terraform provider "ibm" { @@ -47,31 +48,32 @@ ibm_pi_network_port_attach provides the following [timeouts](https://www.terrafo - **delete** - (Default 60 minutes) Used for detaching a network port. ## Argument reference + Review the argument references that you can specify for your resource. - `pi_cloud_instance_id` - (Required, String) The GUID of the service instance associated with an account. -- `pi_instance_id` - (Required, String) The ID of the pvm instance to attach the network port to. +- `pi_instance_id` - (Required, String) Instance id to attach the network port to. - `pi_network_name` - (Required, String) The network ID or name. - `pi_network_port_description` - (Optional, String) The description for the Network Port. - `pi_network_port_ipaddress` - (Optional, String) The requested ip address of this port. - `pi_user_tags` - (Optional, List) The user tags attached to this resource. ## Attribute reference + In addition to all argument reference list, you can access the following attribute reference after your resource is created. -- `id` - (String) The unique identifier of the instance. The ID is composed of `//`. +- `id` - (String) The unique identifier of the instance. The ID is composed of `//`. - `macaddress` - (String) The MAC address of the port. - `network_port_id` - (String) The ID of the port. - `public_ip` - (String) The public IP associated with the port. - `status` - (String) The status of the port. - ## Import The `ibm_pi_network_port` resource can be imported by using `power_instance_id`, `pi_network_name` and `network_port_id`. -**Example** +### Example -``` -$ terraform import ibm_pi_network_port_attach.example d7bec597-4726-451f-8a63-e62e6f19c32c/network-name/cea6651a-bc0a-4438-9f8a-a0770bbf3ebb +```bash +terraform import ibm_pi_network_port_attach.example d7bec597-4726-451f-8a63-e62e6f19c32c/pi_network_name/cea6651a-bc0a-4438-9f8a-a0770bbf3ebb ```