From 46e7a752566a471046c0415635e98fb344bdbd4a Mon Sep 17 00:00:00 2001 From: michaelkad Date: Tue, 11 Feb 2025 12:15:54 -0600 Subject: [PATCH] Update NSG datasources and resources Add missing attribute Update sdk --- go.mod | 2 +- go.sum | 4 ++++ .../data_source_ibm_pi_network_security_group.go | 14 ++++++++++++++ .../data_source_ibm_pi_network_security_groups.go | 11 +++++++++++ ibm/service/power/resource_ibm_pi_instance.go | 2 +- .../resource_ibm_pi_network_security_group.go | 11 +++++++++++ ...esource_ibm_pi_network_security_group_member.go | 11 +++++++++++ .../resource_ibm_pi_network_security_group_rule.go | 14 +++++++++++++- ...urce_ibm_pi_network_security_group_rule_test.go | 2 +- .../docs/d/pi_network_security_group.html.markdown | 2 ++ .../d/pi_network_security_groups.html.markdown | 2 ++ .../docs/r/pi_network_security_group.html.markdown | 2 ++ .../pi_network_security_group_member.html.markdown | 2 ++ .../r/pi_network_security_group_rule.html.markdown | 2 ++ 14 files changed, 77 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index fa539f9a5e9..b1ee8ef5826 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 509116fb9dd..44cd5b6cdc1 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/ibm/service/power/data_source_ibm_pi_network_security_group.go b/ibm/service/power/data_source_ibm_pi_network_security_group.go index 323dda38fc0..0b992af82b1 100644 --- a/ibm/service/power/data_source_ibm_pi_network_security_group.go +++ b/ibm/service/power/data_source_ibm_pi_network_security_group.go @@ -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.", @@ -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.", @@ -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{}{} @@ -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 diff --git a/ibm/service/power/data_source_ibm_pi_network_security_groups.go b/ibm/service/power/data_source_ibm_pi_network_security_groups.go index b79d24326f7..483ac53bd24 100644 --- a/ibm/service/power/data_source_ibm_pi_network_security_groups.go +++ b/ibm/service/power/data_source_ibm_pi_network_security_groups.go @@ -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.", @@ -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.", @@ -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 { diff --git a/ibm/service/power/resource_ibm_pi_instance.go b/ibm/service/power/resource_ibm_pi_instance.go index ffacde57a42..63042a28d34 100644 --- a/ibm/service/power/resource_ibm_pi_instance.go +++ b/ibm/service/power/resource_ibm_pi_instance.go @@ -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), diff --git a/ibm/service/power/resource_ibm_pi_network_security_group.go b/ibm/service/power/resource_ibm_pi_network_security_group.go index 2fef018292e..1bcb960f874 100644 --- a/ibm/service/power/resource_ibm_pi_network_security_group.go +++ b/ibm/service/power/resource_ibm_pi_network_security_group.go @@ -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.", @@ -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.", @@ -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{}{} diff --git a/ibm/service/power/resource_ibm_pi_network_security_group_member.go b/ibm/service/power/resource_ibm_pi_network_security_group_member.go index 7178c753d11..10f95b52cee 100644 --- a/ibm/service/power/resource_ibm_pi_network_security_group_member.go +++ b/ibm/service/power/resource_ibm_pi_network_security_group_member.go @@ -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.", @@ -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.", @@ -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 { diff --git a/ibm/service/power/resource_ibm_pi_network_security_group_rule.go b/ibm/service/power/resource_ibm_pi_network_security_group_rule.go index 704e775de57..5673d1ea2df 100644 --- a/ibm/service/power/resource_ibm_pi_network_security_group_rule.go +++ b/ibm/service/power/resource_ibm_pi_network_security_group_rule.go @@ -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.", @@ -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.", @@ -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) @@ -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{}{} diff --git a/ibm/service/power/resource_ibm_pi_network_security_group_rule_test.go b/ibm/service/power/resource_ibm_pi_network_security_group_rule_test.go index f6234b2abf0..4df1252502d 100644 --- a/ibm/service/power/resource_ibm_pi_network_security_group_rule_test.go +++ b/ibm/service/power/resource_ibm_pi_network_security_group_rule_test.go @@ -104,7 +104,7 @@ func testAccCheckIBMPINetworkSecurityGroupRuleConfigAddRuleTCP() string { flag = "syn" } tcp_flags { - flag = "psh" + flag = "fin" } type = "tcp" } diff --git a/website/docs/d/pi_network_security_group.html.markdown b/website/docs/d/pi_network_security_group.html.markdown index 15b2a7cc5e1..b90c0e8883d 100644 --- a/website/docs/d/pi_network_security_group.html.markdown +++ b/website/docs/d/pi_network_security_group.html.markdown @@ -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`. diff --git a/website/docs/d/pi_network_security_groups.html.markdown b/website/docs/d/pi_network_security_groups.html.markdown index df405db35c5..4d71e241c9f 100644 --- a/website/docs/d/pi_network_security_groups.html.markdown +++ b/website/docs/d/pi_network_security_groups.html.markdown @@ -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. diff --git a/website/docs/r/pi_network_security_group.html.markdown b/website/docs/r/pi_network_security_group.html.markdown index 578c0b5f892..4b39118875b 100644 --- a/website/docs/r/pi_network_security_group.html.markdown +++ b/website/docs/r/pi_network_security_group.html.markdown @@ -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 `/` - `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`. diff --git a/website/docs/r/pi_network_security_group_member.html.markdown b/website/docs/r/pi_network_security_group_member.html.markdown index 95d632a6432..bc5cff193af 100644 --- a/website/docs/r/pi_network_security_group_member.html.markdown +++ b/website/docs/r/pi_network_security_group_member.html.markdown @@ -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 `//` - `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`. diff --git a/website/docs/r/pi_network_security_group_rule.html.markdown b/website/docs/r/pi_network_security_group_rule.html.markdown index 709fb9a61e0..051bc669a3f 100644 --- a/website/docs/r/pi_network_security_group_rule.html.markdown +++ b/website/docs/r/pi_network_security_group_rule.html.markdown @@ -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 `/` - `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`.