-
Notifications
You must be signed in to change notification settings - Fork 33
[minor_change] Add mso_fabric_resource_policies_virtual_port_channel_interface resource and datasource. (DCNE-388) #456
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
Open
samiib
wants to merge
18
commits into
CiscoDevNet:master
Choose a base branch
from
samiib:vpc_interface_policy
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
f6a3e93
[minor_change] Add mso_fabric_resource_policies_virtual_port_channel_…
samiib d9763b9
[ignore] Add vpc interface docs.
samiib 6a15570
[ignore] Fix required node_2_interface.
samiib ecc99a1
[ignore] Fix go format
samiib 7aa1da3
[ignore] Update tests
samiib 26ec84c
[ignore] return set data errors
samiib d85d6a2
[ignore] Update tests for interface description being unset
samiib 572b8ed
[ignore] Add unit tests for split comma string util
samiib a5b7c90
[ignore] Add test with interface_policy_group_uuid resource
samiib 6755e0a
[ignore] Code review comment fixes
samiib 5971e2c
[ignore] Don't send interface description when unset on update.
samiib 5bcde97
[ignore] Add test for unset interface description
samiib 2afea8d
[ignore] Allow name to be updated without ForceNew.
samiib 52960cf
[ignore] Allow descriptions to be cleared.
samiib 553759f
[ignore] Change interface description from List to Set in resource.
samiib 01ba737
[ignore] Change node 1 & 2 interfaces to TypeSet
samiib 06694cc
[ignore] Update test check for sets.
samiib fc8af47
[ignore] Fix test and doc alignment
samiib File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
examples/fabric_resource_policies_virtual_port_channel_interface/main.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| terraform { | ||
| required_providers { | ||
| mso = { | ||
| source = "CiscoDevNet/mso" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| provider "mso" { | ||
| username = "" # <MSO username> | ||
| password = "" # <MSO pwd> | ||
| url = "" # <MSO URL> | ||
| insecure = true | ||
| } | ||
|
|
||
| resource "mso_template" "fabric_policy_template" { | ||
| template_name = "fabric_policy_template" | ||
| template_type = "fabric_policy" | ||
| } | ||
|
|
||
| resource "mso_fabric_policies_interface_setting" "port_channel_interface" { | ||
| template_id = mso_template.fabric_policy_template.id | ||
| type = "portchannel" | ||
| name = "port_channel_interface" | ||
| } | ||
|
|
||
| resource "mso_template" "fabric_resource_template" { | ||
| template_name = "fabric_resource_template" | ||
| template_type = "fabric_resource" | ||
| } | ||
|
|
||
| resource "mso_fabric_resource_policies_virtual_port_channel_interface" "vpc_if" { | ||
| template_id = mso_template.fabric_resource_template.id | ||
| name = "tf_vpc_if" | ||
| description = "Example VPC Interface" | ||
| node_1 = "101" | ||
| node_2 = "102" | ||
| node_1_interfaces = ["1/1", "1/10-11"] | ||
| node_2_interfaces = ["1/2"] | ||
| interface_policy_group_uuid = mso_fabric_policies_interface_setting.port_channel_interface.uuid | ||
| interface_descriptions { | ||
| node = "101" | ||
| interface = "1/1" | ||
| description = "Interface Description 1/1" | ||
| } | ||
| interface_descriptions { | ||
| node = "102" | ||
| interface = "1/10" | ||
| description = "Interface Description 1/10" | ||
| } | ||
| } |
78 changes: 78 additions & 0 deletions
78
mso/datasource_mso_fabric_resource_policies_virtual_port_channel_interface.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| package mso | ||
|
|
||
| import ( | ||
| "log" | ||
|
|
||
| "github.com/ciscoecosystem/mso-go-client/client" | ||
| "github.com/hashicorp/terraform-plugin-sdk/helper/schema" | ||
| "github.com/hashicorp/terraform-plugin-sdk/helper/validation" | ||
| ) | ||
|
|
||
| func dataSourceMSOVirtualPortChannelInterface() *schema.Resource { | ||
| return &schema.Resource{ | ||
| Read: dataSourceMSOFabricResourcePoliciesVirtualPortChannelInterfaceRead, | ||
|
|
||
| SchemaVersion: version, | ||
|
|
||
| Schema: map[string]*schema.Schema{ | ||
| "template_id": { | ||
| Type: schema.TypeString, | ||
| Required: true, | ||
| ValidateFunc: validation.StringIsNotEmpty, | ||
| Description: "Fabric Resource template ID.", | ||
| }, | ||
| "name": { | ||
| Type: schema.TypeString, | ||
| Required: true, | ||
| ValidateFunc: validation.StringIsNotEmpty, | ||
| Description: "Virtual Port Channel Interface name.", | ||
| }, | ||
| "uuid": {Type: schema.TypeString, Computed: true}, | ||
| "description": {Type: schema.TypeString, Computed: true}, | ||
|
|
||
| "node_1": {Type: schema.TypeString, Computed: true}, | ||
| "node_2": {Type: schema.TypeString, Computed: true}, | ||
|
|
||
| "node_1_interfaces": { | ||
| Type: schema.TypeList, | ||
| Computed: true, | ||
| Elem: &schema.Schema{Type: schema.TypeString}, | ||
| }, | ||
| "node_2_interfaces": { | ||
| Type: schema.TypeList, | ||
| Computed: true, | ||
| Elem: &schema.Schema{Type: schema.TypeString}, | ||
| }, | ||
|
|
||
| "interface_policy_group_uuid": {Type: schema.TypeString, Computed: true}, | ||
|
|
||
| "interface_descriptions": { | ||
| Type: schema.TypeList, | ||
| Computed: true, | ||
| Elem: &schema.Resource{ | ||
| Schema: map[string]*schema.Schema{ | ||
| "node": {Type: schema.TypeString, Computed: true}, | ||
| "interface": {Type: schema.TypeString, Computed: true}, | ||
| "description": {Type: schema.TypeString, Computed: true}, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| func dataSourceMSOFabricResourcePoliciesVirtualPortChannelInterfaceRead(d *schema.ResourceData, m any) error { | ||
| log.Printf("[DEBUG] MSO VPC Interface Data Source - Beginning Read: %v", d.Id()) | ||
| msoClient := m.(*client.Client) | ||
|
|
||
| templateId := d.Get("template_id").(string) | ||
| name := d.Get("name").(string) | ||
|
|
||
| err := setVPCInterfaceData(d, msoClient, templateId, name) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| log.Printf("[DEBUG] MSO VPC Interface Data Source - Read Complete: %v", d.Id()) | ||
| return nil | ||
| } |
53 changes: 53 additions & 0 deletions
53
mso/datasource_mso_fabric_resource_policies_virtual_port_channel_interface_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| package mso | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "testing" | ||
|
|
||
| "github.com/hashicorp/terraform-plugin-sdk/helper/resource" | ||
| ) | ||
|
|
||
| func TestAccMSOVirtualPortChannelInterfaceDataSource(t *testing.T) { | ||
| resource.Test(t, resource.TestCase{ | ||
| PreCheck: func() { testAccPreCheck(t) }, | ||
| Providers: testAccProviders, | ||
| Steps: []resource.TestStep{ | ||
| { | ||
| PreConfig: func() { fmt.Println("Test: VPC Interface Data Source") }, | ||
| Config: testAccMSOVirtualPortChannelInterfaceDataSource(), | ||
| Check: resource.ComposeAggregateTestCheckFunc( | ||
| resource.TestCheckResourceAttr("data.mso_fabric_resource_policies_virtual_port_channel_interface.vpc_if", "name", "tf_test_vpc_if"), | ||
| resource.TestCheckResourceAttr("data.mso_fabric_resource_policies_virtual_port_channel_interface.vpc_if", "description", "Terraform test VPC Interface"), | ||
| resource.TestCheckResourceAttr("data.mso_fabric_resource_policies_virtual_port_channel_interface.vpc_if", "node_1", "101"), | ||
| resource.TestCheckResourceAttr("data.mso_fabric_resource_policies_virtual_port_channel_interface.vpc_if", "node_2", "102"), | ||
| resource.TestCheckResourceAttr("data.mso_fabric_resource_policies_virtual_port_channel_interface.vpc_if", "node_1_interfaces.#", "2"), | ||
| resource.TestCheckResourceAttr("data.mso_fabric_resource_policies_virtual_port_channel_interface.vpc_if", "node_1_interfaces.1", "1/1"), | ||
| resource.TestCheckResourceAttr("data.mso_fabric_resource_policies_virtual_port_channel_interface.vpc_if", "node_1_interfaces.0", "1/10-11"), | ||
| resource.TestCheckResourceAttr("data.mso_fabric_resource_policies_virtual_port_channel_interface.vpc_if", "node_2_interfaces.#", "1"), | ||
| resource.TestCheckResourceAttr("data.mso_fabric_resource_policies_virtual_port_channel_interface.vpc_if", "node_2_interfaces.0", "1/2"), | ||
| resource.TestCheckResourceAttr("data.mso_fabric_resource_policies_virtual_port_channel_interface.vpc_if", "interface_descriptions.#", "1"), | ||
| resource.TestCheckResourceAttrSet("data.mso_fabric_resource_policies_virtual_port_channel_interface.vpc_if", "uuid"), | ||
| resource.TestCheckResourceAttrSet("data.mso_fabric_resource_policies_virtual_port_channel_interface.vpc_if", "interface_policy_group_uuid"), | ||
| customTestCheckResourceTypeSetAttr( | ||
| "data.mso_fabric_resource_policies_virtual_port_channel_interface.vpc_if", | ||
| "interface_descriptions", | ||
| map[string]string{ | ||
| "node": "101", | ||
| "interface": "1/1", | ||
| "description": "Terraform test interface description", | ||
| }, | ||
| ), | ||
| ), | ||
| }, | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| func testAccMSOVirtualPortChannelInterfaceDataSource() string { | ||
| return fmt.Sprintf(`%s | ||
| data "mso_fabric_resource_policies_virtual_port_channel_interface" "vpc_if" { | ||
| template_id = mso_fabric_resource_policies_virtual_port_channel_interface.vpc_if.template_id | ||
| name = "tf_test_vpc_if" | ||
| } | ||
| `, testAccMSOVirtualPortChannelInterfaceConfigCreate()) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.