Skip to content
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
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ github.com/IBM/go-sdk-core/v5 v5.6.3/go.mod h1:tt/B9rxLkRtglE7pvqLuYikgCXaZFL3bt
github.com/IBM/go-sdk-core/v5 v5.9.5/go.mod h1:YlOwV9LeuclmT/qi/LAK2AsobbAP42veV0j68/rlZsE=
github.com/IBM/go-sdk-core/v5 v5.10.2/go.mod h1:WZPFasUzsKab/2mzt29xPcfruSk5js2ywAPwW4VJjdI=
github.com/IBM/go-sdk-core/v5 v5.17.4/go.mod h1:KsAAI7eStAWwQa4F96MLy+whYSh39JzNjklZRbN/8ns=
github.com/IBM/go-sdk-core/v5 v5.20.1 h1:dzeyifh1kfRLw8VfAIIS5okZYuqLTqplPZP/Kcsgdlo=
github.com/IBM/go-sdk-core/v5 v5.20.1/go.mod h1:Q3BYO6iDA2zweQPDGbNTtqft5tDcEpm6RTuqMlPcvbw=
github.com/IBM/go-sdk-core/v5 v5.21.0 h1:DUnYhvC4SoC8T84rx5omnhY3+xcQg/Whyoa3mDPIMkk=
github.com/IBM/go-sdk-core/v5 v5.21.0/go.mod h1:Q3BYO6iDA2zweQPDGbNTtqft5tDcEpm6RTuqMlPcvbw=
github.com/IBM/ibm-backup-recovery-sdk-go v1.0.3 h1:9TZHocmCfgmF8TGVrpP1kFyQbjcqLNW7+bM07lefpKQ=
Expand Down
29 changes: 21 additions & 8 deletions ibm/service/power/data_source_ibm_pi_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"log"

"github.com/IBM-Cloud/power-go-client/clients/instance"
"github.com/IBM-Cloud/power-go-client/helpers"
"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"
Expand All @@ -27,11 +26,20 @@ func DataSourceIBMPINetwork() *schema.Resource {
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
},
Arg_NetworkID: {
AtLeastOneOf: []string{Arg_NetworkID, Arg_NetworkName},
ConflictsWith: []string{Arg_NetworkName},
Description: "The network ID.",
Optional: true,
Type: schema.TypeString,
},
Arg_NetworkName: {
Description: "The unique identifier or name of a network.",
Required: true,
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
AtLeastOneOf: []string{Arg_NetworkID, Arg_NetworkName},
ConflictsWith: []string{Arg_NetworkID},
Deprecated: "The pi_network_name field is deprecated. Please use pi_network_id instead",
Description: "The unique identifier or name of a network.",
Optional: true,
Type: schema.TypeString,
},

// Attributes
Expand Down Expand Up @@ -78,8 +86,7 @@ func DataSourceIBMPINetwork() *schema.Resource {
},
Attr_Name: {
Computed: true,
Deprecated: "This field is deprecated, use pi_network_name instead.",
Description: "The unique identifier or name of a network.",
Description: "The name of the network.",
Type: schema.TypeString,
},
Attr_NetworkAddressTranslation: {
Expand Down Expand Up @@ -140,9 +147,15 @@ func dataSourceIBMPINetworkRead(ctx context.Context, d *schema.ResourceData, met
}

cloudInstanceID := d.Get(Arg_CloudInstanceID).(string)
var networkID string
if v, ok := d.GetOk(Arg_NetworkID); ok {
networkID = v.(string)
} else if v, ok := d.GetOk(Arg_NetworkName); ok {
networkID = v.(string)
}

networkC := instance.NewIBMPINetworkClient(ctx, sess, cloudInstanceID)
networkdata, err := networkC.Get(d.Get(helpers.PINetworkName).(string))
networkdata, err := networkC.Get(networkID)
if err != nil || networkdata == nil {
return diag.FromErr(err)
}
Expand Down
26 changes: 20 additions & 6 deletions ibm/service/power/data_source_ibm_pi_network_port.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"log"

"github.com/IBM-Cloud/power-go-client/clients/instance"
"github.com/IBM-Cloud/power-go-client/helpers"
"github.com/IBM-Cloud/power-go-client/power/models"
"github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns"
"github.com/hashicorp/go-uuid"
Expand All @@ -28,11 +27,20 @@ func DataSourceIBMPINetworkPort() *schema.Resource {
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
},
Arg_NetworkID: {
AtLeastOneOf: []string{Arg_NetworkID, Arg_NetworkName},
ConflictsWith: []string{Arg_NetworkName},
Description: "The network ID.",
Optional: true,
Type: schema.TypeString,
},
Arg_NetworkName: {
Description: "The unique identifier or name of a network.",
Required: true,
Type: schema.TypeString,
ValidateFunc: validation.NoZeroValues,
AtLeastOneOf: []string{Arg_NetworkID, Arg_NetworkName},
ConflictsWith: []string{Arg_NetworkID},
Deprecated: "The pi_network_name field is deprecated. Please use pi_network_id instead",
Description: "The unique identifier or name of a network.",
Optional: true,
Type: schema.TypeString,
},

// Attributes
Expand Down Expand Up @@ -97,9 +105,15 @@ func dataSourceIBMPINetworkPortsRead(ctx context.Context, d *schema.ResourceData
}

cloudInstanceID := d.Get(Arg_CloudInstanceID).(string)
var networkID string
if v, ok := d.GetOk(Arg_NetworkID); ok {
networkID = v.(string)
} else if v, ok := d.GetOk(Arg_NetworkName); ok {
networkID = v.(string)
}

networkportC := instance.NewIBMPINetworkClient(ctx, sess, cloudInstanceID)
networkportdata, err := networkportC.GetAllPorts(d.Get(helpers.PINetworkName).(string))
networkportdata, err := networkportC.GetAllPorts(networkID)
if err != nil {
return diag.FromErr(err)
}
Expand Down
6 changes: 3 additions & 3 deletions ibm/service/power/data_source_ibm_pi_network_port_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestAccIBMPINetworkPortDataSource_basic(t *testing.T) {
func testAccCheckIBMPINetworkPortDataSourceConfig() string {
return fmt.Sprintf(`
data "ibm_pi_network_port" "testacc_ds_network_port" {
pi_network_name = "%s"
pi_cloud_instance_id = "%s"
}`, acc.Pi_network_name, acc.Pi_cloud_instance_id)
pi_cloud_instance_id = "%[2]s"
pi_network_id = "%[1]s"
}`, acc.Pi_network_id, acc.Pi_cloud_instance_id)
}
6 changes: 3 additions & 3 deletions ibm/service/power/data_source_ibm_pi_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestAccIBMPINetworkDataSource_basic(t *testing.T) {
func testAccCheckIBMPINetworkDataSourceConfig() string {
return fmt.Sprintf(`
data "ibm_pi_network" "testacc_ds_network" {
pi_network_name = "%s"
pi_cloud_instance_id = "%s"
}`, acc.Pi_network_name, acc.Pi_cloud_instance_id)
pi_cloud_instance_id = "%[2]s"
pi_network_id = "%[1]s"
}`, acc.Pi_network_id, acc.Pi_cloud_instance_id)
}
6 changes: 4 additions & 2 deletions website/docs/d/pi_network.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Retrieve information about the network that your Power Systems Virtual Server in

```terraform
data "ibm_pi_network" "ds_network" {
pi_network_name = "APP"
pi_cloud_instance_id = "49fba6c9-23f8-40bc-9899-aca322ee7d5b"
pi_network_id = "7f8e2a9d-3b4c-4e4f-8e8d-f7e7e1e23456"
}
```

Expand All @@ -40,7 +40,8 @@ Example usage:
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 name of the network.
- `pi_network_id` - (Optional, String) The network ID.
- `pi_network_name` - (Deprecated, Optional, String) The unique identifier or name of the network. Passing the name of the instance could fail or fetch stale data. Please pass an id and use `pi_network_id` instead.

## Attribute Reference

Expand All @@ -54,6 +55,7 @@ In addition to all argument reference list, you can access the following attribu
- `dns`- (Set) The DNS Servers for the network.
- `gateway` - (String) The network gateway that is attached to your network.
- `id` - (String) The ID of the network.
- `name` - (String) The name of the network.
- `mtu` - (Boolean) Maximum Transmission Unit option of the network.
- `network_address_translation` - (Deprecated, List) Contains the network address translation details (for on-prem locations only).

Expand Down
5 changes: 3 additions & 2 deletions website/docs/d/pi_network_port.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Retrieve information about a network port in the Power Virtual Server Cloud. For

```terraform
data "ibm_pi_network_port" "test-network-port" {
pi_network_name = "Zone1-CFN"
pi_cloud_instance_id = "51e1879c-bcbe-4ee1-a008-49cdba0eaf60"
pi_network_id = "7e1c3b2a-9f0d-4e5f-a1bc-def012345678"
}
```

Expand All @@ -42,7 +42,8 @@ Example usage:
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.
- `pi_network_id` - (Optional, String) The network ID.
- `pi_network_name` - (Deprecated, Optional, String) The unique identifier or name of a network. Please use `pi_network_id` instead.

## Attribute Reference

Expand Down
Loading