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

adding devel changes #27

Merged
merged 1 commit into from
Oct 12, 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
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ provider "f5os" {
- `host` (String) URI/Host details for F5os Device,can be provided via `F5OS_HOST` environment variable.
- `password` (String, Sensitive) Password for F5os Device,can be provided via `F5OS_PASSWORD` environment variable.
- `port` (Number) Port Number to be used to make API calls to HOST
- `teem_disable` (Boolean) If this flag set to true,sending telemetry data to TEEM will be disabled,can be provided via `TEEM_DISABLE` environment variable.
- `username` (String) Username for F5os Device,can be provided via `F5OS_USERNAME` environment variable.User provided here need to have required permission as per [UserManagement](https://techdocs.f5.com/en-us/f5os-a-1-4-0/f5-rseries-systems-administration-configuration/title-user-mgmt.html)
55 changes: 55 additions & 0 deletions docs/resources/lag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "f5os_lag Resource - terraform-provider-f5os"
subcategory: ""
description: |-
Resource to Manage network Link Aggregation Group (LAG) interfaces on F5OS systems like VELOS chassis partitions or rSeries platforms
---

# f5os_lag (Resource)

Resource to Manage network Link Aggregation Group (LAG) interfaces on F5OS systems like VELOS chassis partitions or rSeries platforms

## Example Usage

```terraform
resource "f5os_lag" "test_lag" {
name = "test_lag"
members = ["1.0"]
native_vlan = 5
trunk_vlans = [
1,
2,
3
]
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) Name of the Link Aggregation Group interface (LAG) interface to configure

### Optional

- `members` (List of String) List of physical interfaces that are members of the LAG.
- `native_vlan` (Number) Configures the VLAN ID to associate with LAG interface.
The `native_vlan` parameter is used for untagged traffic.
- `trunk_vlans` (List of Number) Configures multiple VLAN IDs to associate with the LAG interface.
The `trunk_vlans` parameter is used for tagged traffic

### Read-Only

- `id` (String) Unique identifier for LAG Interface resource.
- `status` (String) Operational state of the LAG interface.

## Import

Import is supported using the following syntax:

```shell
# LAG Interface can be imported by specifying the LAG Interface name
terraform import f5os_lag.test-import test-lag
```
2 changes: 2 additions & 0 deletions examples/resources/f5os_lag/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# LAG Interface can be imported by specifying the LAG Interface name
terraform import f5os_lag.test-import test-lag
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/hashicorp/terraform-plugin-log v0.8.0
github.com/hashicorp/terraform-plugin-testing v1.2.0
github.com/stretchr/testify v1.8.4
gitswarm.f5net.com/terraform-providers/f5osclient v1.0.2-0.20230817082623-065c38e0fe3e
gitswarm.f5net.com/terraform-providers/f5osclient v1.0.2
)

require (
Expand All @@ -25,7 +25,7 @@ require (
github.com/fatih/color v1.15.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
Expand Down Expand Up @@ -211,8 +211,8 @@ github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6e
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zclconf/go-cty v1.13.1 h1:0a6bRwuiSHtAmqCqNOE+c2oHgepv0ctoxU4FUe43kwc=
github.com/zclconf/go-cty v1.13.1/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0=
gitswarm.f5net.com/terraform-providers/f5osclient v1.0.2-0.20230817082623-065c38e0fe3e h1:csKWYvSpNYrGa2drcwr6zvtqcuJ9zuH8HNfvGrPkg3o=
gitswarm.f5net.com/terraform-providers/f5osclient v1.0.2-0.20230817082623-065c38e0fe3e/go.mod h1:KN91vHAGPLQq+i+05CQXVcyqwjOpoJdq8ksPB7hR9MA=
gitswarm.f5net.com/terraform-providers/f5osclient v1.0.2 h1:RXDYEeXCYymbdPnbOt2XVQLVK2tYXWpfrQMZ607jDSQ=
gitswarm.f5net.com/terraform-providers/f5osclient v1.0.2/go.mod h1:XmqFs5vsbNni7scPBmJ0pWDIFa8i1NOnHoLnQPU/c98=
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func extractSubnet(cidr string) (int, string, error) {
return ones, ip.String(), nil
}

func getSliceDifference(slice1, slice2 []int64) []int64 {
func getIntSliceDifference(slice1, slice2 []int64) []int64 {
var diff []int64
for _, num1 := range slice1 {
found := false
Expand Down
18 changes: 15 additions & 3 deletions internal/provider/interface_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ func NewInterfaceResource() resource.Resource {

// InterfaceResource defines the resource implementation.
type InterfaceResource struct {
client *f5ossdk.F5os
client *f5ossdk.F5os
teemData *TeemData
}

type InterfaceResourceModel struct {
Expand Down Expand Up @@ -82,6 +83,9 @@ func (r *InterfaceResource) Schema(ctx context.Context, req resource.SchemaReque

func (r *InterfaceResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
r.client, resp.Diagnostics = toF5osProvider(req.ProviderData)
teemData.ProviderName = "f5os"
teemData.ResourceName = "f5os_interface"
r.teemData = teemData
}

func (r *InterfaceResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
Expand Down Expand Up @@ -110,7 +114,13 @@ func (r *InterfaceResource) Create(ctx context.Context, req resource.CreateReque

tflog.Debug(ctx, fmt.Sprintf("interfaceReqConfig Response:%+v", string(respByte)))
data.Id = types.StringValue(data.Name.ValueString())

teemInfo := make(map[string]interface{})
teemInfo["teemData"] = r.teemData
r.client.Metadata = teemInfo
err = r.client.SendTeem(teemInfo)
if err != nil {
resp.Diagnostics.AddError("Teem Error", fmt.Sprintf("Sending Teem Data failed: %s", err))
}
intfData, err := r.client.GetInterface(data.Name.ValueString())
if err != nil {
resp.Diagnostics.AddError("F5OS Client Error", fmt.Sprintf("Unable to Read/Get Interface, got error: %s", err))
Expand Down Expand Up @@ -217,7 +227,9 @@ func (r *InterfaceResource) interfaceResourceModelToState(ctx context.Context, r
data.Name = types.StringValue(respData.OpenconfigInterfacesInterface[0].Name)
data.Enabled = types.BoolValue(respData.OpenconfigInterfacesInterface[0].State.Enabled)
data.Status = types.StringValue(respData.OpenconfigInterfacesInterface[0].State.OperStatus)
data.NativeVlan = types.Int64Value(int64(respData.OpenconfigInterfacesInterface[0].OpenconfigIfEthernetEthernet.OpenconfigVlanSwitchedVlan.Config.NativeVlan))
if int64(respData.OpenconfigInterfacesInterface[0].OpenconfigIfEthernetEthernet.OpenconfigVlanSwitchedVlan.Config.NativeVlan) != 0 {
data.NativeVlan = types.Int64Value(int64(respData.OpenconfigInterfacesInterface[0].OpenconfigIfEthernetEthernet.OpenconfigVlanSwitchedVlan.Config.NativeVlan))
}
data.TrunkVlans, _ = types.ListValueFrom(ctx, types.Int64Type, respData.OpenconfigInterfacesInterface[0].OpenconfigIfEthernetEthernet.OpenconfigVlanSwitchedVlan.Config.TrunkVlans)
}

Expand Down
Loading
Loading