Skip to content

Commit

Permalink
Merge pull request #504 from vmware/fabric-network-ids
Browse files Browse the repository at this point in the history
Fix the fabric_network_ids parameter at vra__network_ip_range resource
  • Loading branch information
frodenas authored Sep 20, 2023
2 parents 102ca6f + 773b9f6 commit 7476d3e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions vra/resource_network_ip_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"log"
"strings"

"github.com/vmware/vra-sdk-go/pkg/client/network_ip_range"
"github.com/vmware/vra-sdk-go/pkg/models"
Expand Down Expand Up @@ -164,6 +165,14 @@ func resourceNetworkIPRangeRead(ctx context.Context, d *schema.ResourceData, m i
d.Set("start_ip_address", networkIPRange.StartIPAddress)
d.Set("updated_at", networkIPRange.UpdatedAt)

if fabricNetworkLinks, ok := networkIPRange.Links["fabric-networks"]; ok {
fabricNetworkIds := make([]string, 0, len(fabricNetworkLinks.Hrefs))
for _, fabricNetworkLink := range fabricNetworkLinks.Hrefs {
fabricNetworkIds = append(fabricNetworkIds, strings.TrimPrefix(fabricNetworkLink, "/iaas/api/fabric-networks/"))
}
d.Set("fabric_network_ids", fabricNetworkIds)
}

if err := d.Set("links", flattenLinks(networkIPRange.Links)); err != nil {
return diag.Errorf("error setting network ip range links - error: %#v", err)
}
Expand Down

0 comments on commit 7476d3e

Please sign in to comment.