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

Update docs to show pool allocation roles #693

Merged
merged 1 commit into from
Jun 28, 2024
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
12 changes: 9 additions & 3 deletions apstra/blueprint/pool_allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"sort"
"strings"
)

type PoolAllocation struct {
Expand All @@ -26,6 +28,9 @@ type PoolAllocation struct {
}

func (o PoolAllocation) ResourceAttributes() map[string]resourceSchema.Attribute {
sortedRoles := utils.AllResourceGroupNameStrings()
sort.Strings(sortedRoles)

return map[string]resourceSchema.Attribute{
"blueprint_id": resourceSchema.StringAttribute{
MarkdownDescription: "Apstra ID of the Blueprint to which the Resource Pool should be allocated.",
Expand All @@ -43,9 +48,10 @@ func (o PoolAllocation) ResourceAttributes() map[string]resourceSchema.Attribute
},
},
"role": resourceSchema.StringAttribute{
MarkdownDescription: "Fabric Role (Apstra Resource Group Name)",
Required: true,
PlanModifiers: []planmodifier.String{stringplanmodifier.RequiresReplace()},
MarkdownDescription: "Fabric Role (Apstra Resource Group Name) must be one of:\n\n - " +
strings.Join(sortedRoles, "\n - ") + "\n",
Required: true,
PlanModifiers: []planmodifier.String{stringplanmodifier.RequiresReplace()},
Validators: []validator.String{
stringvalidator.OneOf(
utils.AllResourceGroupNameStrings()...,
Expand Down
18 changes: 18 additions & 0 deletions apstra/utils/rosetta.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ const (
resourceGroupNameVxlanVnIds = "vni_virtual_network_ids"
resourceGroupNameLeafL3PeerLinksIpv4 = "leaf_l3_peer_links"
resourceGroupNameLeafL3PeerLinksIpv6 = "leaf_l3_peer_links_ipv6"

// search for todos with 'enable_rosetta_for_pools_with_leading_ipv6' to enable rosetta for these items.
// total 18 occurences between this file and the test file
// resourceGroupNameSpineLeafLinkIpv6 = "spine_leaf_link_ips_ipv6" // todo: enable_rosetta_for_pools_with_leading_ipv6
// resourceGroupNameSpineSuperspineLinkIpv6 = "spine_superspine_link_ips_ipv6" // todo: enable_rosetta_for_pools_with_leading_ipv6
// resourceGroupNameToGenericLinkIpv6 = "to_generic_link_ips_ipv6" // todo: enable_rosetta_for_pools_with_leading_ipv6
)

type StringerWithFromString interface {
Expand Down Expand Up @@ -173,6 +179,12 @@ func resourceGroupNameToFriendlyString(in apstra.ResourceGroupName) string {
return resourceGroupNameLeafL3PeerLinksIpv6
case apstra.ResourceGroupNameVxlanVnIds:
return resourceGroupNameVxlanVnIds
// case apstra.ResourceGroupNameSpineLeafIp6: // todo: enable_rosetta_for_pools_with_leading_ipv6
// return resourceGroupNameSpineLeafLinkIpv6 // todo: enable_rosetta_for_pools_with_leading_ipv6
// case apstra.ResourceGroupNameSuperspineSpineIp6: // todo: enable_rosetta_for_pools_with_leading_ipv6
// return resourceGroupNameSpineSuperspineLinkIpv6 // todo: enable_rosetta_for_pools_with_leading_ipv6
// case apstra.ResourceGroupNameToGenericLinkIpv6: // todo: enable_rosetta_for_pools_with_leading_ipv6
// return resourceGroupNameToGenericLinkIpv6 // todo: enable_rosetta_for_pools_with_leading_ipv6
}

return in.String()
Expand Down Expand Up @@ -292,6 +304,12 @@ func resourceGroupNameFromFriendlyString(target *apstra.ResourceGroupName, in ..
*target = apstra.ResourceGroupNameLeafL3PeerLinkLinkIp6
case resourceGroupNameVxlanVnIds:
*target = apstra.ResourceGroupNameVxlanVnIds
// case resourceGroupNameSpineLeafLinkIpv6: // todo: enable_rosetta_for_pools_with_leading_ipv6
// *target = apstra.ResourceGroupNameSpineLeafIp6 // todo: enable_rosetta_for_pools_with_leading_ipv6
// case resourceGroupNameSpineSuperspineLinkIpv6: // todo: enable_rosetta_for_pools_with_leading_ipv6
// *target = apstra.ResourceGroupNameSuperspineSpineIp6 // todo: enable_rosetta_for_pools_with_leading_ipv6
// case resourceGroupNameToGenericLinkIpv6: // todo: enable_rosetta_for_pools_with_leading_ipv6
// *target = apstra.ResourceGroupNameToGenericLinkIpv6 // todo: enable_rosetta_for_pools_with_leading_ipv6
default:
return target.FromString(in[0])
}
Expand Down
4 changes: 4 additions & 0 deletions apstra/utils/rosetta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ func TestRosetta(t *testing.T) {
{string: "vni_virtual_network_ids", stringers: []fmt.Stringer{apstra.ResourceGroupNameVxlanVnIds}},
{string: "leaf_l3_peer_links", stringers: []fmt.Stringer{apstra.ResourceGroupNameLeafL3PeerLinkLinkIp4}},
{string: "leaf_l3_peer_links_ipv6", stringers: []fmt.Stringer{apstra.ResourceGroupNameLeafL3PeerLinkLinkIp6}},

//{string: "spine_leaf_link_ips_ipv6", stringers: []fmt.Stringer{apstra.ResourceGroupNameSpineLeafIp6}}, // todo: enable_rosetta_for_pools_with_leading_ipv6
//{string: "spine_superspine_link_ips_ipv6", stringers: []fmt.Stringer{apstra.ResourceGroupNameSuperspineSpineIp6}}, // todo: enable_rosetta_for_pools_with_leading_ipv6
//{string: "to_generic_link_ips_ipv6", stringers: []fmt.Stringer{apstra.ResourceGroupNameToGenericLinkIpv6}}, // todo: enable_rosetta_for_pools_with_leading_ipv6
}

for i, tc := range testCases {
Expand Down
34 changes: 33 additions & 1 deletion docs/resources/datacenter_resource_pool_allocation.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,39 @@ resource "apstra_datacenter_resource_pool_allocation" "ipv4" {

- `blueprint_id` (String) Apstra ID of the Blueprint to which the Resource Pool should be allocated.
- `pool_ids` (Set of String) Apstra IDs of the Resource Pools to be allocated to the given Blueprint role.
- `role` (String) Fabric Role (Apstra Resource Group Name)
- `role` (String) Fabric Role (Apstra Resource Group Name) must be one of:

- access_asns
- access_l3_peer_link_link_ips
- access_loopback_ips
- evpn_l3_vnis
- generic_asns
- generic_loopback_ips
- generic_loopback_ips_ipv6
- ipv6_spine_leaf_link_ips
- ipv6_spine_superspine_link_ips
- ipv6_to_generic_link_ips
- leaf_asns
- leaf_l3_peer_links
- leaf_l3_peer_links_ipv6
- leaf_leaf_link_ips
- leaf_loopback_ips
- leaf_loopback_ips_ipv6
- mlag_domain_svi_subnets
- mlag_domain_svi_subnets_ipv6
- spine_asns
- spine_leaf_link_ips
- spine_loopback_ips
- spine_loopback_ips_ipv6
- spine_superspine_link_ips
- superspine_asns
- superspine_loopback_ips
- superspine_loopback_ips_ipv6
- to_generic_link_ips
- virtual_network_svi_subnets
- virtual_network_svi_subnets_ipv6
- vni_virtual_network_ids
- vtep_ips

### Optional

Expand Down
Loading