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

DL Route Report changes #4570

Merged
merged 6 commits into from
Jul 14, 2023
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/IBM/ibm-hpcs-tke-sdk v0.0.0-20211109141421-a4b61b05f7d1
github.com/IBM/ibm-hpcs-uko-sdk v0.0.20-beta
github.com/IBM/keyprotect-go-client v0.10.0
github.com/IBM/networking-go-sdk v0.42.1
github.com/IBM/networking-go-sdk v0.42.2
github.com/IBM/platform-services-go-sdk v0.38.1
github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5
github.com/IBM/scc-go-sdk/v3 v3.1.6
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ github.com/IBM/ibm-hpcs-uko-sdk v0.0.20-beta/go.mod h1:MLVNHMYoKsvovJZ4v1gQCpIYt
github.com/IBM/keyprotect-go-client v0.5.1/go.mod h1:5TwDM/4FRJq1ZOlwQL1xFahLWQ3TveR88VmL1u3njyI=
github.com/IBM/keyprotect-go-client v0.10.0 h1:UdVOwJfyVNmL4O3Aw2eGluiEr5FpV5h8EaNVJKCtLvY=
github.com/IBM/keyprotect-go-client v0.10.0/go.mod h1:yr8h2noNgU8vcbs+vhqoXp3Lmv73PI0zAc6VMgFvWwM=
github.com/IBM/networking-go-sdk v0.42.1 h1:79ktSkNGsPS7zxJoVVKxPpQZCLdD3u+MHOqCS4Gm+L8=
github.com/IBM/networking-go-sdk v0.42.1/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo=
github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCBmvdyqkA=
github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo=
github.com/IBM/platform-services-go-sdk v0.38.1 h1:wyjn61SLcoCvdRMZu7wZIkScaVswXwjrTl8Gif/uESc=
github.com/IBM/platform-services-go-sdk v0.38.1/go.mod h1:rb1IaHGwT8QI8pCYgNbf2VbkuKMgOowl91pZ2QWZuJ4=
github.com/IBM/project-go-sdk v0.0.10 h1:vHSuemwZ4S4c6BEb22tzsEcPTs/5LnZ0yKpP3GG/GL8=
Expand Down
3 changes: 3 additions & 0 deletions ibm/service/directlink/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const (
dlVirtualConnectionName = "virtual_connection_name"
dlVirtualConnectionType = "virtual_connection_type"
dlActive = "active"
dlAsPath = "as_path"
dlAdvertisedRoutes = "advertised_routes"
dlAsPrepends = "as_prepends"
dlAuthenticationKey = "authentication_key"
dlBfdInterval = "bfd_interval"
Expand Down Expand Up @@ -48,6 +50,7 @@ const (
dlKeyServerPriority = "key_server_priority"
dlLength = "length"
dlLoaRejectReason = "loa_reject_reason"
dlLocalPreference = "local_preference"
dlLocationDisplayName = "location_display_name"
dlLocationName = "location_name"
dlLinkStatus = "link_status"
Expand Down
54 changes: 53 additions & 1 deletion ibm/service/directlink/data_source_ibm_dl_route_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@ func DataSourceIBMDLRouteReport() *schema.Resource {
ForceNew: true,
Description: "Id of the route report",
},
dlAdvertisedRoutes: {
Type: schema.TypeList,
Description: "List of connection prefixes advertised to the on-prem network",
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
dlAsPath: {
Type: schema.TypeString,
Computed: true,
Description: "The BGP AS path of the route",
},
dlPrefix: {
Type: schema.TypeString,
Computed: true,
Description: "Prefix for gateway routes",
},
},
},
},
dlGatewayRoutes: {
Type: schema.TypeList,
Description: "List of gateway routes",
Expand All @@ -51,6 +70,11 @@ func DataSourceIBMDLRouteReport() *schema.Resource {
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
dlAsPath: {
Type: schema.TypeString,
Computed: true,
Description: "The BGP AS path of the route",
},
dlPrefix: {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -127,7 +151,17 @@ func DataSourceIBMDLRouteReport() *schema.Resource {
dlPrefix: {
Type: schema.TypeString,
Computed: true,
Description: "Prefix for overlapping routes",
Description: "Prefix for virtual connection routes",
},
dlActive: {
Type: schema.TypeBool,
Computed: true,
Description: "Indicates whether the route is the preferred path of the prefix",
},
dlLocalPreference: {
Type: schema.TypeString,
Computed: true,
Description: "The local preference of the route. This attribute can manipulate the chosen path on routes",
},
},
},
Expand Down Expand Up @@ -183,6 +217,20 @@ func dataSourceIBMDLRouteReportRead(d *schema.ResourceData, meta interface{}) er
d.Set(dlRouteReportStatus, *report.Status)
}

// Build Advertised Routes
advRoutes := make([]map[string]interface{}, 0)
if report.AdvertisedRoutes != nil {
for _, adRoute := range report.AdvertisedRoutes {
route := map[string]interface{}{}
route[dlAsPath] = adRoute.AsPath
route[dlPrefix] = adRoute.Prefix
advRoutes = append(advRoutes, route)
}
}

log.Println("[Info] Length DL Route Reports advertised routes:", len(advRoutes))
d.Set(dlAdvertisedRoutes, advRoutes)

// Build Gateway Routes
gatewayRoutes := make([]map[string]interface{}, 0)
if report.GatewayRoutes != nil {
Expand All @@ -202,6 +250,8 @@ func dataSourceIBMDLRouteReportRead(d *schema.ResourceData, meta interface{}) er
for _, onPremRoute := range report.OnPremRoutes {
route := map[string]interface{}{}
route[dlPrefix] = onPremRoute.Prefix
route[dlAsPath] = onPremRoute.AsPath
route[dlRouteReportNextHop] = onPremRoute.NextHop
onPremRoutes = append(onPremRoutes, route)
}

Expand Down Expand Up @@ -248,6 +298,8 @@ func dataSourceIBMDLRouteReportRead(d *schema.ResourceData, meta interface{}) er
for _, r := range c.Routes {
routes := map[string]interface{}{}
routes[dlPrefix] = r.Prefix
routes[dlLocalPreference] = r.LocalPreference
routes[dlActive] = r.Active
connectionRoutes = append(connectionRoutes, routes)
}

Expand Down
56 changes: 54 additions & 2 deletions ibm/service/directlink/data_source_ibm_dl_route_reports.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,26 @@ func DataSourceIBMDLRouteReports() *schema.Resource {
Computed: true,
Description: "Id of the route report",
},

dlAdvertisedRoutes: {
Type: schema.TypeList,
Description: "List of connection prefixes advertised to the on-prem network",
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
dlAsPath: {
Type: schema.TypeString,
Computed: true,
Description: "The BGP AS path of the route",
},
dlPrefix: {
Type: schema.TypeString,
Computed: true,
Description: "Prefix for advertised routes",
},
},
},
},
dlGatewayRoutes: {
Type: schema.TypeList,
Description: "List of gateway routes",
Expand All @@ -52,6 +72,11 @@ func DataSourceIBMDLRouteReports() *schema.Resource {
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
dlAsPath: {
Type: schema.TypeString,
Computed: true,
Description: "The BGP AS path of the route",
},
dlPrefix: {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -128,7 +153,17 @@ func DataSourceIBMDLRouteReports() *schema.Resource {
dlPrefix: {
Type: schema.TypeString,
Computed: true,
Description: "Prefix for overlapping routes",
Description: "Prefix for virtual connection routes",
},
dlActive: {
Type: schema.TypeBool,
Computed: true,
Description: "Indicates whether the route is the preferred path of the prefix",
},
dlLocalPreference: {
Type: schema.TypeString,
Computed: true,
Description: "The local preference of the route. This attribute can manipulate the chosen path on routes",
},
},
},
Expand Down Expand Up @@ -183,6 +218,20 @@ func dataSourceIBMDLRouteReportsRead(d *schema.ResourceData, meta interface{}) e
routeReport[dlRouteReportStatus] = *instance.Status
}

// Build Advertised Routes
advRoutes := make([]map[string]interface{}, 0)
if instance.AdvertisedRoutes != nil {
for _, adRoute := range instance.AdvertisedRoutes {
route := map[string]interface{}{}
route[dlAsPath] = adRoute.AsPath
route[dlPrefix] = adRoute.Prefix
advRoutes = append(advRoutes, route)
}
}

log.Println("[Info] Length DL Route Reports advertised routes:", len(advRoutes))
routeReport[dlAdvertisedRoutes] = advRoutes

// Build Gateway Routes
gatewayRoutes := make([]map[string]interface{}, 0)
if instance.GatewayRoutes != nil {
Expand All @@ -203,9 +252,10 @@ func dataSourceIBMDLRouteReportsRead(d *schema.ResourceData, meta interface{}) e
for _, onPremRoute := range instance.OnPremRoutes {
route := map[string]interface{}{}
route[dlPrefix] = onPremRoute.Prefix
route[dlAsPath] = onPremRoute.AsPath
route[dlRouteReportNextHop] = onPremRoute.NextHop
onPremRoutes = append(onPremRoutes, route)
}

}

log.Println("[INFO] length DL Onprem routes", len(onPremRoutes))
Expand Down Expand Up @@ -249,6 +299,8 @@ func dataSourceIBMDLRouteReportsRead(d *schema.ResourceData, meta interface{}) e
for _, r := range c.Routes {
routes := map[string]interface{}{}
routes[dlPrefix] = r.Prefix
routes[dlLocalPreference] = r.LocalPreference
routes[dlActive] = r.Active
connectionRoutes = append(connectionRoutes, routes)
}

Expand Down
55 changes: 54 additions & 1 deletion ibm/service/directlink/resource_ibm_dl_route_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,25 @@ func ResourceIBMDLGatewayRouteReport() *schema.Resource {
Computed: true,
Description: "Id of the route report",
},
dlAdvertisedRoutes: {
Type: schema.TypeList,
Description: "List of connection prefixes advertised to the on-prem network",
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
dlAsPath: {
Type: schema.TypeString,
Computed: true,
Description: "The BGP AS path of the route",
},
dlPrefix: {
Type: schema.TypeString,
Computed: true,
Description: "Prefix for gateway routes",
},
},
},
},
dlGatewayRoutes: {
Type: schema.TypeList,
Description: "List of gateway routes",
Expand All @@ -58,6 +77,11 @@ func ResourceIBMDLGatewayRouteReport() *schema.Resource {
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
dlAsPath: {
Type: schema.TypeString,
Computed: true,
Description: "The BGP AS path of the route",
},
dlPrefix: {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -134,7 +158,17 @@ func ResourceIBMDLGatewayRouteReport() *schema.Resource {
dlPrefix: {
Type: schema.TypeString,
Computed: true,
Description: "Prefix for overlapping routes",
Description: "Prefix for virtual connection routes",
},
dlActive: {
Type: schema.TypeBool,
Computed: true,
Description: "Indicates whether the route is the preferred path of the prefix",
},
dlLocalPreference: {
Type: schema.TypeString,
Computed: true,
Description: "The local preference of the route. This attribute can manipulate the chosen path on routes",
},
},
},
Expand Down Expand Up @@ -264,6 +298,21 @@ func resourceIBMDLRouteReportRead(d *schema.ResourceData, meta interface{}) erro
d.Set(dlRouteReportStatus, *report.Status)
}

// Build Advertised Routes
advRoutes := make([]map[string]interface{}, 0)
if report.AdvertisedRoutes != nil {
for _, adRoute := range report.AdvertisedRoutes {
route := map[string]interface{}{}
route[dlAsPath] = adRoute.AsPath
route[dlPrefix] = adRoute.Prefix
advRoutes = append(advRoutes, route)
}

}

log.Println("[Info] Length DL Route Reports advertised routes:", len(advRoutes))
d.Set(dlAdvertisedRoutes, advRoutes)

// Build Gateway Routes
gatewayRoutes := make([]map[string]interface{}, 0)
if report.GatewayRoutes != nil {
Expand All @@ -283,6 +332,8 @@ func resourceIBMDLRouteReportRead(d *schema.ResourceData, meta interface{}) erro
for _, onPremRoute := range report.OnPremRoutes {
route := map[string]interface{}{}
route[dlPrefix] = onPremRoute.Prefix
route[dlAsPath] = onPremRoute.AsPath
route[dlRouteReportNextHop] = onPremRoute.NextHop
onPremRoutes = append(onPremRoutes, route)
}

Expand Down Expand Up @@ -329,6 +380,8 @@ func resourceIBMDLRouteReportRead(d *schema.ResourceData, meta interface{}) erro
for _, r := range c.Routes {
routes := map[string]interface{}{}
routes[dlPrefix] = r.Prefix
routes[dlLocalPreference] = r.LocalPreference
routes[dlActive] = r.Active
connectionRoutes = append(connectionRoutes, routes)
}

Expand Down
17 changes: 9 additions & 8 deletions website/docs/d/dl_route_report.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,33 @@ The argument reference that you need to specify for the data source.
## Attribute reference
In addition to all argument references list, you can access the following attribute references after your data source is created.
- `created_at` - (String) The date and time resource created.
- `advertised_routes` - (List) List of connection prefixes advertised to the on-prem network.
Nested scheme for `advertised_routes`:
- `as_path` - (String) The BGP AS path of the route.
- `prefix` - (String) The prefix used in the route.
- `gateway_routes` - (List) List of local/direct routes.

Nested scheme for `gateway_routes`:
- `prefix` - (String) The prefix used in the route.
- `on_prem_routes` - (List) List of on premises routes

Nested scheme for `on_prem_routes`:
- `as_path` - (String) The BGP AS path of the route.
- `next_hop` - (String) Next hop address.
- `prefix` - (String) The prefix used in the route.
- `overlapping_routes` - (List) List of overlapping routes.

Nested scheme for `overlapping_routes`:
- `routes` - (List) List of overlapping connection/prefix pairs.

Nested scheme for `routes`:
- `prefix` - (String) The overlapping prefix.
- `type` - (String) The type of route.
- `virtual_connection_id` - (String) Virtual Connection ID. This is set only when type of route is virtual_connection.

- `status` - (String) The route report status.
- `updated_at` - (String) The date and time resource was updated.
- `virtual_connection_routes` - (List) List of routes on virtual connections.

Nested scheme for `virtual_connection_routes`
- `routes` - (List) List of connection routes.

- `routes` - (List) List of virtual connection routes.
Nested scheme for `routes`:
- `active` - (Bool) Indicates whether the route is the preferred path of the prefix.
- `local_preference` - (String) The local preference of the route. This attribute can manipulate the chosen path on routes.
- `prefix` - (String) The prefix used in the route.
- `virtual_connection_id` - (String) Virtual Connection ID
- `virtual_connection_name` - (String) Virtual Connection name
Expand Down
Loading