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

[Datasource][Resource]Update NSG datasources and resources #198

Closed
wants to merge 1 commit into from
Closed
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: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.23.4
require (
github.com/IBM-Cloud/bluemix-go v0.0.0-20241117121028-a3be206688b3
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240725064144-454a2ae23113
github.com/IBM-Cloud/power-go-client v1.9.0
github.com/IBM-Cloud/power-go-client v1.10.0
github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca
github.com/IBM/appconfiguration-go-admin-sdk v0.4.4
github.com/IBM/appid-management-go-sdk v0.0.0-20210908164609-dd0e0eaf732f
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240725064144-454a2ae2311
github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.5.3/go.mod h1:RiUvKuHKTBmBApDMUQzBL14pQUGKcx/IioKQPIcRQjs=
github.com/IBM-Cloud/power-go-client v1.9.0 h1:nnErpb/7TJQe8P7OfIlJPhSJVq5oyuCJlMje9Ry6XEY=
github.com/IBM-Cloud/power-go-client v1.9.0/go.mod h1:UDyXeIKEp6r7yWUXYu3r0ZnFSlNZ2YeQTHwM2Tmlgv0=
github.com/IBM-Cloud/power-go-client v1.10.0-beta7 h1:nxAuY/0axYwOq2jb2jVZqu3nmPP/7/sFC6HCi8RhMUA=
github.com/IBM-Cloud/power-go-client v1.10.0-beta7/go.mod h1:UDyXeIKEp6r7yWUXYu3r0ZnFSlNZ2YeQTHwM2Tmlgv0=
github.com/IBM-Cloud/power-go-client v1.10.0 h1:yBUHWwvNBmLkWpbZJQJEXoxBa1Dm+eJgMSbk9ljmXUU=
github.com/IBM-Cloud/power-go-client v1.10.0/go.mod h1:UDyXeIKEp6r7yWUXYu3r0ZnFSlNZ2YeQTHwM2Tmlgv0=
github.com/IBM-Cloud/softlayer-go v1.0.5-tf h1:koUAyF9b6X78lLLruGYPSOmrfY2YcGYKOj/Ug9nbKNw=
github.com/IBM-Cloud/softlayer-go v1.0.5-tf/go.mod h1:6HepcfAXROz0Rf63krk5hPZyHT6qyx2MNvYyHof7ik4=
github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca h1:crniVcf+YcmgF03NmmfonXwSQ73oJF+IohFYBwknMxs=
Expand Down
14 changes: 14 additions & 0 deletions ibm/service/power/data_source_ibm_pi_network_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ func DataSourceIBMPINetworkSecurityGroup() *schema.Resource {
Description: "The network security group's crn.",
Type: schema.TypeString,
},
Attr_Default: {
Computed: true,
Description: "Indicates if the network security group is the default network security group in the workspace.",
Type: schema.TypeBool,
},
Attr_Members: {
Computed: true,
Description: "The list of IPv4 addresses and, or network interfaces in the network security group.",
Expand All @@ -56,6 +61,11 @@ func DataSourceIBMPINetworkSecurityGroup() *schema.Resource {
Description: "The mac address of a network interface included if the type is network-interface.",
Type: schema.TypeString,
},
Attr_NetworkInterfaceID: {
Computed: true,
Description: "The network ID of a network interface included if the type is network-interface.",
Type: schema.TypeString,
},
Attr_Target: {
Computed: true,
Description: "If ipv4-address type, then IPv4 address or if network-interface type, then network interface ID.",
Expand Down Expand Up @@ -218,6 +228,7 @@ func dataSourceIBMPINetworkSecurityGroupRead(ctx context.Context, d *schema.Reso
}
d.Set(Attr_UserTags, userTags)
}
d.Set(Attr_Default, networkSecurityGroup.Default)

if len(networkSecurityGroup.Members) > 0 {
members := []map[string]interface{}{}
Expand Down Expand Up @@ -248,6 +259,9 @@ func networkSecurityGroupMemberToMap(mbr *models.NetworkSecurityGroupMember) map
if mbr.MacAddress != "" {
mbrMap[Attr_MacAddress] = mbr.MacAddress
}
if mbr.NetworkInterfaceNetworkID != "" {
mbrMap[Attr_NetworkInterfaceID] = mbr.NetworkInterfaceNetworkID
}
mbrMap[Attr_Target] = mbr.Target
mbrMap[Attr_Type] = mbr.Type
return mbrMap
Expand Down
11 changes: 11 additions & 0 deletions ibm/service/power/data_source_ibm_pi_network_security_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ func DataSourceIBMPINetworkSecurityGroups() *schema.Resource {
Description: "The network security group's crn.",
Type: schema.TypeString,
},
Attr_Default: {
Computed: true,
Description: "Indicates if the network security group is the default network security group in the workspace.",
Type: schema.TypeBool,
},
Attr_ID: {
Computed: true,
Description: "The ID of the network security group.",
Expand All @@ -61,6 +66,11 @@ func DataSourceIBMPINetworkSecurityGroups() *schema.Resource {
Description: "The mac address of a network interface included if the type is network-interface.",
Type: schema.TypeString,
},
Attr_NetworkInterfaceID: {
Computed: true,
Description: "The network ID of a network interface included if the type is network-interface.",
Type: schema.TypeString,
},
Attr_Target: {
Computed: true,
Description: "If ipv4-address type, then IPv4 address or if network-interface type, then network interface ID.",
Expand Down Expand Up @@ -243,6 +253,7 @@ func networkSecurityGroupToMap(nsg *models.NetworkSecurityGroup, meta interface{
}
networkSecurityGroup[Attr_UserTags] = userTags
}
networkSecurityGroup[Attr_Default] = nsg.Default

networkSecurityGroup[Attr_ID] = nsg.ID
if len(nsg.Members) > 0 {
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 @@ -1728,7 +1728,7 @@ func createPVMInstance(d *schema.ResourceData, client *instance.IBMPIInstanceCli
SysType: systype,
ImageID: flex.PtrToString(imageid),
ProcType: flex.PtrToString(processortype),
Replicants: replicants,
Replicants: &replicants,
UserData: encodeBase64(userData),
ReplicantNamingScheme: flex.PtrToString(replicationNamingScheme),
ReplicantAffinityPolicy: flex.PtrToString(replicationpolicy),
Expand Down
11 changes: 11 additions & 0 deletions ibm/service/power/resource_ibm_pi_network_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ func ResourceIBMPINetworkSecurityGroup() *schema.Resource {
Description: "The network security group's crn.",
Type: schema.TypeString,
},
Attr_Default: {
Computed: true,
Description: "Indicates if the network security group is the default network security group in the workspace.",
Type: schema.TypeBool,
},
Attr_Members: {
Computed: true,
Description: "The list of IPv4 addresses and, or network interfaces in the network security group.",
Expand All @@ -83,6 +88,11 @@ func ResourceIBMPINetworkSecurityGroup() *schema.Resource {
Description: "The mac address of a network interface included if the type is network-interface.",
Type: schema.TypeString,
},
Attr_NetworkInterfaceID: {
Computed: true,
Description: "The network ID of a network interface included if the type is network-interface.",
Type: schema.TypeString,
},
Attr_Target: {
Computed: true,
Description: "If ipv4-address type, then IPv4 address or if network-interface type, then network interface ID.",
Expand Down Expand Up @@ -280,6 +290,7 @@ func resourceIBMPINetworkSecurityGroupRead(ctx context.Context, d *schema.Resour
}
d.Set(Arg_UserTags, userTags)
}
d.Set(Attr_Default, networkSecurityGroup.Default)

if len(networkSecurityGroup.Members) > 0 {
members := []map[string]interface{}{}
Expand Down
11 changes: 11 additions & 0 deletions ibm/service/power/resource_ibm_pi_network_security_group_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ func ResourceIBMPINetworkSecurityGroupMember() *schema.Resource {
Description: "The network security group's crn.",
Type: schema.TypeString,
},
Attr_Default: {
Computed: true,
Description: "Indicates if the network security group is the default network security group in the workspace.",
Type: schema.TypeBool,
},
Attr_Members: {
Computed: true,
Description: "The list of IPv4 addresses and, or network interfaces in the network security group.",
Expand All @@ -94,6 +99,11 @@ func ResourceIBMPINetworkSecurityGroupMember() *schema.Resource {
Description: "The mac address of a network interface included if the type is network-interface.",
Type: schema.TypeString,
},
Attr_NetworkInterfaceID: {
Computed: true,
Description: "The network ID of a network interface included if the type is network-interface.",
Type: schema.TypeString,
},
Attr_Target: {
Computed: true,
Description: "If ipv4-address type, then IPv4 address or if network-interface type, then network interface ID.",
Expand Down Expand Up @@ -303,6 +313,7 @@ func resourceIBMPINetworkSecurityGroupMemberRead(ctx context.Context, d *schema.
}
d.Set(Attr_UserTags, userTags)
}
d.Set(Attr_Default, networkSecurityGroup.Default)
if len(networkSecurityGroup.Members) > 0 {
members := []map[string]interface{}{}
for _, mbr := range networkSecurityGroup.Members {
Expand Down
14 changes: 13 additions & 1 deletion ibm/service/power/resource_ibm_pi_network_security_group_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ func ResourceIBMPINetworkSecurityGroupRule() *schema.Resource {
Description: "The network security group's crn.",
Type: schema.TypeString,
},
Attr_Default: {
Computed: true,
Description: "Indicates if the network security group is the default network security group in the workspace.",
Type: schema.TypeBool,
},
Attr_Members: {
Computed: true,
Description: "The list of IPv4 addresses and, or network interfaces in the network security group.",
Expand All @@ -193,6 +198,11 @@ func ResourceIBMPINetworkSecurityGroupRule() *schema.Resource {
Description: "The mac address of a network interface included if the type is network-interface.",
Type: schema.TypeString,
},
Attr_NetworkInterfaceID: {
Computed: true,
Description: "The network ID of a network interface included if the type is network-interface.",
Type: schema.TypeString,
},
Attr_Target: {
Computed: true,
Description: "If ipv4-address type, then IPv4 address or if network-interface type, then network interface ID.",
Expand Down Expand Up @@ -385,10 +395,11 @@ func resourceIBMPINetworkSecurityGroupRuleCreate(ctx context.Context, d *schema.
networkSecurityGroupAddRule.SourcePorts = networkSecurityGroupRuleMapToPort(sourcePort)

networkSecurityGroup, err := nsgClient.AddRule(nsgID, &networkSecurityGroupAddRule)
ruleID := *networkSecurityGroup.ID
if err != nil {
return diag.FromErr(err)
}
ruleID := *networkSecurityGroup.ID

_, err = isWaitForIBMPINetworkSecurityGroupRuleAdd(ctx, nsgClient, nsgID, ruleID, d.Timeout(schema.TimeoutCreate))
if err != nil {
return diag.FromErr(err)
Expand Down Expand Up @@ -423,6 +434,7 @@ func resourceIBMPINetworkSecurityGroupRuleRead(ctx context.Context, d *schema.Re
}
d.Set(Attr_UserTags, userTags)
}
d.Set(Attr_Default, networkSecurityGroup.Default)

if len(networkSecurityGroup.Members) > 0 {
members := []map[string]interface{}{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func testAccCheckIBMPINetworkSecurityGroupRuleConfigAddRuleTCP() string {
flag = "syn"
}
tcp_flags {
flag = "psh"
flag = "fin"
}
type = "tcp"
}
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/pi_network_security_group.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ You can specify the following arguments for this data source.
In addition to all argument reference list, you can access the following attribute references after your data source is created.

- `crn` - (String) The network security group's crn.
- `default` - (Boolean) Indicates if the network security group is the default network security group in the workspace.

- `members` - (List) The list of IPv4 addresses and\or network interfaces in the network security group.

Nested schema for `members`:
- `id` - (String) The id of the member in a network security group.
- `mac_address` - (String) The mac address of a network interface included if the type is `network-interface`.
- `network_interface_id` - (String) The network ID of a network interface included if the type is `network-interface`.
- `target` - (String) If `ipv4-address` type, then IPv4 address or if `network-interface` type, then network interface id.
- `type` - (String) The type of member. Supported values are: `ipv4-address`, `network-interface`.

Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/pi_network_security_groups.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ After your data source is created, you can read values from the following attrib

Nested schema for `network_security_groups`:
- `crn` - (String) The network security group's crn.
- `default` - (Boolean) Indicates if the network security group is the default network security group in the workspace.
- `id` - (String) The id of the network security group.
- `members` - (List) The list of IPv4 addresses and\or network Interfaces in the network security group.

Nested schema for `members`:
- `id` - (String) The id of the member in a network security group.
- `mac_address` - (String) The mac address of a network Interface included if the type is `network-interface`.
- `network_interface_id` - (String) The network ID of a network interface included if the type is `network-interface`.
- `target` - (String) If `ipv4-address` type, then IPv4 address or if `network-interface` type, then network interface id.
- `type` - (String) The type of member. Supported values are: `ipv4-address`, `network-interface`.
- `name` - (String) The name of the network security group.
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/pi_network_security_group.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ Review the argument references that you can specify for your resource.
In addition to all argument reference list, you can access the following attribute reference after your resource is created.

- `crn` - (String) The network security group's crn.
- `default` - (Boolean) Indicates if the network security group is the default network security group in the workspace.
- `id` - (String) The unique identifier of the network security group resource. Composed of `<cloud_instance_id>/<network_security_group_id>`
- `members` - (List) The list of IPv4 addresses and\or network interfaces in the network security group.

Nested schema for `members`:
- `id` - (String) The id of the member in a network security group.
- `mac_address` - (String) The mac address of a network interface included if the type is `network-interface`.
- `network_interface_id` - (String) The network ID of a network interface included if the type is `network-interface`.
- `target` - (String) If `ipv4-address` type, then IPv4 address or if `network-interface` type, then network interface id.
- `type` - (String) The type of member. Supported values are: `ipv4-address`, `network-interface`.

Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/pi_network_security_group_member.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ Review the argument references that you can specify for your resource.
In addition to all argument reference list, you can access the following attribute reference after your resource is created.

- `crn` - (String) The network security group's crn.
- `default` - (Boolean) Indicates if the network security group is the default network security group in the workspace.
- `id` - (String) The unique identifier of the network security group resource. Composed of `<cloud_instance_id>/<network_security_group_id>/<network_security_group_member_id>`
- `members` - (List) The list of IPv4 addresses and\or network interfaces in the network security group.

Nested schema for `members`:
- `id` - (String) The id of the member in a network security group.
- `mac_address` - (String) The mac address of a network interface included if the type is `network-interface`.
- `network_interface_id` - (String) The network ID of a network interface included if the type is `network-interface`.
- `target` - (String) If `ipv4-address` type, then IPv4 address or if `network-interface` type, then network interface id.
- `type` - (String) The type of member. Supported values are: `ipv4-address`, `network-interface`.

Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/pi_network_security_group_rule.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,14 @@ Review the argument references that you can specify for your resource.
In addition to all argument reference list, you can access the following attribute reference after your resource is created.

- `crn` - (String) The network security group's crn.
- `default` - (Boolean) Indicates if the network security group is the default network security group in the workspace.
- `id` - (String) The unique identifier of the network security group resource. Composed of `<cloud_instance_id>/<network_security_group_id/rule_id>`
- `members` - (List) The list of IPv4 addresses and\or network interfaces in the network security group.

Nested schema for `members`:
- `id` - (String) The id of the member in a network security group.
- `mac_address` - (String) The mac address of a network interface included if the type is `network-interface`.
- `network_interface_id` - (String) The network ID of a network interface included if the type is `network-interface`.
- `target` - (String) If `ipv4-address` type, then IPv4 address or if `network-interface` type, then network interface id.
- `type` - (String) The type of member. Supported values are: `ipv4-address`, `network-interface`.

Expand Down
Loading