diff --git a/CHANGELOG.md b/CHANGELOG.md index c427fcd2..85250e08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Add `nxos_vpc_keepalive` resource and data source - Add `nxos_vpc_peerlink` resource and data source - Fix `bandwidth_reference_unit` of `nxos_ospf_vrf` resource and data source +- Add `force` attribute to `nxos_port_channel_interface_member` resource and data source ## 0.5.1 diff --git a/docs/data-sources/port_channel_interface_member.md b/docs/data-sources/port_channel_interface_member.md index 685da52e..a59b7cba 100644 --- a/docs/data-sources/port_channel_interface_member.md +++ b/docs/data-sources/port_channel_interface_member.md @@ -36,4 +36,5 @@ data "nxos_port_channel_interface_member" "example" { ### Read-Only +- `force` (Boolean) Channel group force - `id` (String) The distinguished name of the object. diff --git a/docs/guides/changelog.md b/docs/guides/changelog.md index d62c139d..210ac83a 100644 --- a/docs/guides/changelog.md +++ b/docs/guides/changelog.md @@ -12,6 +12,7 @@ description: |- - Add `nxos_vpc_keepalive` resource and data source - Add `nxos_vpc_peerlink` resource and data source - Fix `bandwidth_reference_unit` of `nxos_ospf_vrf` resource and data source +- Add `force` attribute to `nxos_port_channel_interface_member` resource and data source ## 0.5.1 diff --git a/docs/resources/port_channel_interface_member.md b/docs/resources/port_channel_interface_member.md index 027796ec..bad50b33 100644 --- a/docs/resources/port_channel_interface_member.md +++ b/docs/resources/port_channel_interface_member.md @@ -31,6 +31,7 @@ This resource can manage a port-channel interface member. resource "nxos_port_channel_interface_member" "example" { interface_id = "po1" interface_dn = "sys/intf/phys-[eth1/11]" + force = false } ``` @@ -45,6 +46,7 @@ resource "nxos_port_channel_interface_member" "example" { ### Optional - `device` (String) A device name from the provider configuration. +- `force` (Boolean) Channel group force ### Read-Only diff --git a/examples/resources/nxos_port_channel_interface_member/resource.tf b/examples/resources/nxos_port_channel_interface_member/resource.tf index a2ccda5a..98aaabb8 100644 --- a/examples/resources/nxos_port_channel_interface_member/resource.tf +++ b/examples/resources/nxos_port_channel_interface_member/resource.tf @@ -1,4 +1,5 @@ resource "nxos_port_channel_interface_member" "example" { interface_id = "po1" interface_dn = "sys/intf/phys-[eth1/11]" + force = false } diff --git a/gen/definitions/port_channel_interface_member.yaml b/gen/definitions/port_channel_interface_member.yaml index 67c29160..bc3f8a07 100644 --- a/gen/definitions/port_channel_interface_member.yaml +++ b/gen/definitions/port_channel_interface_member.yaml @@ -24,6 +24,11 @@ attributes: id: true description: "DN of interface. For example: `sys/intf/phys-[eth1/1]`." example: sys/intf/phys-[eth1/11] + - nxos_name: isMbrForce + tf_name: force + type: Bool + description: Channel group force + example: false test_prerequisites: - dn: sys/intf/aggr-[po1] class_name: pcAggrIf diff --git a/internal/provider/data_source_nxos_port_channel_interface_member.go b/internal/provider/data_source_nxos_port_channel_interface_member.go index c18529c2..022c0280 100644 --- a/internal/provider/data_source_nxos_port_channel_interface_member.go +++ b/internal/provider/data_source_nxos_port_channel_interface_member.go @@ -71,6 +71,10 @@ func (d *PortChannelInterfaceMemberDataSource) Schema(ctx context.Context, req d MarkdownDescription: "DN of interface. For example: `sys/intf/phys-[eth1/1]`.", Required: true, }, + "force": schema.BoolAttribute{ + MarkdownDescription: "Channel group force", + Computed: true, + }, }, } } diff --git a/internal/provider/data_source_nxos_port_channel_interface_member_test.go b/internal/provider/data_source_nxos_port_channel_interface_member_test.go index fbc77c5c..25fb8773 100644 --- a/internal/provider/data_source_nxos_port_channel_interface_member_test.go +++ b/internal/provider/data_source_nxos_port_channel_interface_member_test.go @@ -34,6 +34,7 @@ func TestAccDataSourceNxosPortChannelInterfaceMember(t *testing.T) { Config: testAccDataSourceNxosPortChannelInterfaceMemberPrerequisitesConfig + testAccDataSourceNxosPortChannelInterfaceMemberConfig, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("data.nxos_port_channel_interface_member.test", "interface_dn", "sys/intf/phys-[eth1/11]"), + resource.TestCheckResourceAttr("data.nxos_port_channel_interface_member.test", "force", "false"), ), }, }, @@ -56,6 +57,7 @@ const testAccDataSourceNxosPortChannelInterfaceMemberConfig = ` resource "nxos_port_channel_interface_member" "test" { interface_id = "po1" interface_dn = "sys/intf/phys-[eth1/11]" + force = false depends_on = [nxos_rest.PreReq0, ] } diff --git a/internal/provider/model_nxos_port_channel_interface_member.go b/internal/provider/model_nxos_port_channel_interface_member.go index e932e561..d14382d2 100644 --- a/internal/provider/model_nxos_port_channel_interface_member.go +++ b/internal/provider/model_nxos_port_channel_interface_member.go @@ -21,7 +21,9 @@ package provider import ( "fmt" + "strconv" + "github.com/CiscoDevNet/terraform-provider-nxos/internal/provider/helpers" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/netascode/go-nxos" "github.com/tidwall/gjson" @@ -33,6 +35,7 @@ type PortChannelInterfaceMember struct { Dn types.String `tfsdk:"id"` InterfaceId types.String `tfsdk:"interface_id"` InterfaceDn types.String `tfsdk:"interface_dn"` + Force types.Bool `tfsdk:"force"` } func (data PortChannelInterfaceMember) getDn() string { @@ -49,6 +52,9 @@ func (data PortChannelInterfaceMember) toBody() nxos.Body { if (!data.InterfaceDn.IsUnknown() && !data.InterfaceDn.IsNull()) || true { body, _ = sjson.Set(body, data.getClassName()+".attributes."+"tDn", data.InterfaceDn.ValueString()) } + if (!data.Force.IsUnknown() && !data.Force.IsNull()) || true { + body, _ = sjson.Set(body, data.getClassName()+".attributes."+"isMbrForce", strconv.FormatBool(data.Force.ValueBool())) + } return nxos.Body{body} } @@ -59,4 +65,9 @@ func (data *PortChannelInterfaceMember) fromBody(res gjson.Result, all bool) { } else { data.InterfaceDn = types.StringNull() } + if !data.Force.IsNull() || all { + data.Force = types.BoolValue(helpers.ParseNxosBoolean(res.Get(data.getClassName() + ".attributes.isMbrForce").String())) + } else { + data.Force = types.BoolNull() + } } diff --git a/internal/provider/resource_nxos_port_channel_interface_member.go b/internal/provider/resource_nxos_port_channel_interface_member.go index 9b8e017c..4891dad0 100644 --- a/internal/provider/resource_nxos_port_channel_interface_member.go +++ b/internal/provider/resource_nxos_port_channel_interface_member.go @@ -81,6 +81,10 @@ func (r *PortChannelInterfaceMemberResource) Schema(ctx context.Context, req res stringplanmodifier.RequiresReplace(), }, }, + "force": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Channel group force").String, + Optional: true, + }, }, } } diff --git a/internal/provider/resource_nxos_port_channel_interface_member_test.go b/internal/provider/resource_nxos_port_channel_interface_member_test.go index c5ad5d32..10203717 100644 --- a/internal/provider/resource_nxos_port_channel_interface_member_test.go +++ b/internal/provider/resource_nxos_port_channel_interface_member_test.go @@ -35,6 +35,7 @@ func TestAccNxosPortChannelInterfaceMember(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("nxos_port_channel_interface_member.test", "interface_id", "po1"), resource.TestCheckResourceAttr("nxos_port_channel_interface_member.test", "interface_dn", "sys/intf/phys-[eth1/11]"), + resource.TestCheckResourceAttr("nxos_port_channel_interface_member.test", "force", "false"), ), }, { @@ -72,6 +73,7 @@ func testAccNxosPortChannelInterfaceMemberConfig_all() string { resource "nxos_port_channel_interface_member" "test" { interface_id = "po1" interface_dn = "sys/intf/phys-[eth1/11]" + force = false depends_on = [nxos_rest.PreReq0, ] } ` diff --git a/templates/guides/changelog.md.tmpl b/templates/guides/changelog.md.tmpl index d62c139d..210ac83a 100644 --- a/templates/guides/changelog.md.tmpl +++ b/templates/guides/changelog.md.tmpl @@ -12,6 +12,7 @@ description: |- - Add `nxos_vpc_keepalive` resource and data source - Add `nxos_vpc_peerlink` resource and data source - Fix `bandwidth_reference_unit` of `nxos_ospf_vrf` resource and data source +- Add `force` attribute to `nxos_port_channel_interface_member` resource and data source ## 0.5.1