Skip to content

Commit 4875ce9

Browse files
committed
Changes to AT environment
1 parent ff585ad commit 4875ce9

File tree

8 files changed

+274
-88
lines changed

8 files changed

+274
-88
lines changed

README.md

Lines changed: 83 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
- [Go](https://golang.org/doc/install) >= 1.19
77

88

9-
## Building The Provider
9+
## Installing The Provider
1010

1111
1. Clone the repository
1212
2. Enter the repository directory
@@ -19,44 +19,102 @@ The provider should be available in `$GOPATH/bin`
1919

2020
## Using the provider
2121

22-
The provider is not yet available in hashicorp terraform registry. So `terrform init` will not work
23-
22+
For using the locally compiled provider:
2423
Refer https://developer.hashicorp.com/terraform/cli/config/config-file
2524
Section: Development Overrides for Provider Developers
2625
To add dev overrides to use a the plugin under development
2726

2827

29-
## Developing the Provider
30-
31-
See generator/generate.md
32-
33-
3428
## Acceptance Tests
3529

3630
```shell
3731
./run_accept_tests.sh // Run everything
3832
./run_accept_tests.sh TestAcc<Pattern of tests> // Run Specific tests
33+
or
34+
make testacc // Run everything
3935
```
4036
* AT runs on actual NDFC environment
41-
* The testbed settings are stored in `testing/at_testbeds/`
42-
* By default it uses ndfc-175
43-
* Use `TESTBED` environment variable to change the testbed
44-
* A file `testing/at_testbeds/ndfc_$(TESTBED).yaml must be present
45-
** Remember to set fabric names, switch serials etc to match the NDFC in use
46-
47-
AT run result mandatory for PR approval
48-
49-
## Steps to run unit test with mockoon server
50-
51-
1. Install mockoon-cli server
52-
```
53-
npm install -g @mockoon/cli
54-
```
55-
2. Copy your mockoon environment data json file to `/terraform-provide-ndfc/mockoon_data.json`
56-
3. Create unit test functions with prefix `TestUT_` and use `ut_client` as NDFC client variable.
57-
4. Run `./run_unit_test.sh` to run the unit test cases.
37+
* The testbed settings are expected in a yaml file as seen in [`testing/testbed.yaml`](testing/testbed.yaml)
38+
* export `TESTBED_FILE` environment variable to indicate the testbed config to be used for AT
39+
* The provider settings can be overrided by following environment variables
40+
`NDFC_HOST`, `NDFC_USER`, `NDFC_PASSWORD`, `NDFC_DOMAIN`
41+
** The fabric names, switch serials etc in the config must match the NDFC being used
5842

5943
## Provider plugin Documentation
6044
[Provider](docs/index.md)
6145
[Resources](docs/resources)
6246
[Datasources](docs/data-sources)
47+
48+
## Sample Workflow
49+
50+
Following is a sample integrated config that creates a new fabric and adds a switch into it.
51+
Save this to a `config.tf` file, modify the paramters according to the NDFC in use
52+
53+
```
54+
terraform {
55+
required_providers {
56+
ndfc = {
57+
source = "registry.terraform.io/cisco/ndfc"
58+
}
59+
}
60+
}
61+
62+
provider "ndfc" {
63+
username = "admin"
64+
password = "test"
65+
host = "https://my-ndfc"
66+
insecure = true
67+
}
68+
69+
resource "ndfc_fabric_vxlan_evpn" "my_fabric_1" {
70+
fabric_name = "my_fabric_name"
71+
bgp_as = "65000"
72+
deploy = false
73+
}
74+
resource "ndfc_inventory_devices" "test_resource_inventory_devices_1" {
75+
fabric_name = "my_fabric_name"
76+
auth_protocol = "md5"
77+
username = "admin"
78+
password = "admin_password"
79+
max_hops = 0
80+
set_as_individual_device_write_credential = false
81+
preserve_config = false
82+
save = true
83+
deploy = false
84+
retries = 300
85+
retry_wait_timeout = 20
86+
devices = {
87+
"10.1.1.1" = {
88+
role = "spine"
89+
discovery_type = "discover"
90+
discovery_auth_protocol = "md5"
91+
}
92+
}
93+
}
94+
95+
# resource to do a final recalculate and deploy
96+
resource "ndfc_configuration_deploy" "test_resource_configuration_deploy_1" {
97+
fabric_name = "my_fabric_name"
98+
serial_numbers = ["ALL"]
99+
config_save = true
100+
trigger_deploy_on_update = false
101+
# Adding depends on ensures that features are configured in the right order in NDFC
102+
depends_on = [
103+
ndfc_inventory_devices.test_resource_inventory_devices_1,
104+
ndfc_fabric_vxlan_evpn.my_fabric_1
105+
]
106+
}
107+
```
108+
109+
### Execute following to configure NDFC
110+
111+
```shell
112+
terraform plan
113+
terraform apply
114+
```
115+
116+
### Execute following to cleanup
117+
118+
```shell
119+
terraform destroy
120+
```

go.mod

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go 1.22.7
55
toolchain go1.23.2
66

77
require (
8+
github.com/hashicorp/hcl/v2 v2.19.1
89
github.com/hashicorp/terraform-plugin-framework v1.4.2
910
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0
1011
github.com/hashicorp/terraform-plugin-go v0.22.0
@@ -14,6 +15,7 @@ require (
1415
github.com/stretchr/testify v1.8.4
1516
github.com/tidwall/gjson v1.17.0
1617
github.com/tidwall/sjson v1.2.5
18+
github.com/zclconf/go-cty v1.15.0
1719
gopkg.in/h2non/gock.v1 v1.1.2
1820
gopkg.in/yaml.v2 v2.4.0
1921
)
@@ -22,11 +24,15 @@ require (
2224
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect
2325
github.com/agext/levenshtein v1.2.2 // indirect
2426
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
27+
github.com/bitfield/gotestdox v0.2.2 // indirect
2528
github.com/cloudflare/circl v1.3.7 // indirect
2629
github.com/davecgh/go-spew v1.1.1 // indirect
30+
github.com/dnephin/pflag v1.0.7 // indirect
2731
github.com/fatih/color v1.16.0 // indirect
32+
github.com/fsnotify/fsnotify v1.7.0 // indirect
2833
github.com/golang/protobuf v1.5.3 // indirect
2934
github.com/google/go-cmp v0.6.0 // indirect
35+
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
3036
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect
3137
github.com/hashicorp/errwrap v1.1.0 // indirect
3238
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
@@ -39,7 +45,6 @@ require (
3945
github.com/hashicorp/go-uuid v1.0.3 // indirect
4046
github.com/hashicorp/go-version v1.7.0 // indirect
4147
github.com/hashicorp/hc-install v0.9.0 // indirect
42-
github.com/hashicorp/hcl/v2 v2.19.1 // indirect
4348
github.com/hashicorp/logutils v1.0.0 // indirect
4449
github.com/hashicorp/terraform-exec v0.21.0 // indirect
4550
github.com/hashicorp/terraform-json v0.23.0 // indirect
@@ -63,17 +68,20 @@ require (
6368
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
6469
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
6570
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
66-
github.com/zclconf/go-cty v1.15.0 // indirect
67-
golang.org/x/crypto v0.21.0 // indirect
71+
golang.org/x/crypto v0.24.0 // indirect
6872
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 // indirect
6973
golang.org/x/mod v0.21.0 // indirect
70-
golang.org/x/net v0.23.0 // indirect
74+
golang.org/x/net v0.26.0 // indirect
75+
golang.org/x/sync v0.9.0 // indirect
7176
golang.org/x/sys v0.21.0 // indirect
77+
golang.org/x/term v0.21.0 // indirect
7278
golang.org/x/text v0.20.0 // indirect
79+
golang.org/x/tools v0.22.0 // indirect
7380
google.golang.org/appengine v1.6.8 // indirect
7481
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect
7582
google.golang.org/grpc v1.61.1 // indirect
7683
google.golang.org/protobuf v1.32.0 // indirect
7784
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
7885
gopkg.in/yaml.v3 v3.0.1 // indirect
86+
gotest.tools/gotestsum v1.12.0 // indirect
7987
)

0 commit comments

Comments
 (0)