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

Add ND version and site resources (DCNE-179) #6

Merged
merged 13 commits into from
Nov 20, 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
2 changes: 2 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ jobs:
nd_host:
- name: v3.1
url: "https://173.36.219.35/"
insecure: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
Expand All @@ -78,6 +79,7 @@ jobs:
TF_ACC_STATE_LINEAGE: "1"
ND_VAL_REL_DN: false
ND_URL: ${{ matrix.nd_host.url }}
ND_INSECURE: ${{ matrix.nd_host.insecure }}
- name: Upload coverage to Codecov
# Upload Coverage on latest only
if: ${{ matrix.nd_host.name == 'v3.1'}}
Expand Down
47 changes: 47 additions & 0 deletions docs/data-sources/site.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
subcategory: "Sites"
layout: "nd"
page_title: "ND: nd_site"
sidebar_current: "docs-nd-data-source-nd_site"
description: |-
Data source for Nexus Dashboard Sites
---

# nd_site #

Data source for Nexus Dashboard Sites

## API Information ##

* Site Management [API Information](https://developer.cisco.com/docs/nexus-dashboard/3-1-1/api-reference/)
* API Endpoint: `nexus/api/sitemanagement/v4/sites`

## GUI Information ##

* Location: `Admin Console -> Manage -> Sites`

## Example Usage ##

```hcl
data "nd_site" "example" {
name = "example"
}
```

## Schema ##

### Required ###

* `name` (name) - (String) The name of the site.

### Read-Only ###
* `id` (id) - (String) The ID of the site.
* `url` (host) - (String) The URL of the site.
* `username` (userName) - (String) The username of the site.
* `password` (password) - (String) The password of the site.
* `type` (siteType) - (String) The type of the site.
* `login_domain` (loginDomain) - (String) The login domain of the site.
* `inband_epg` (inband_epg) - (String) The In-Band Endpoint Group (EPG) used to connect ND to the site.
* `latitude` (latitude) - (String) The latitude location of the site.
* `longitude` (longitude) - (String) The longitude location of the site.
* `use_proxy` (useProxy) - (Bool) The use proxy of the site, used to route network traffic through a proxy server.
44 changes: 44 additions & 0 deletions docs/data-sources/version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
subcategory: "Version"
layout: "nd"
page_title: "ND: nd_version"
sidebar_current: "docs-nd-data-source-nd_version"
description: |-
Data source for Nexus Dashboard Version
---

# nd_site #

Data source for Nexus Dashboard Version

## API Information ##

* Site Management [API Information](https://developer.cisco.com/docs/nexus-dashboard/3-1-1/api-reference/)
* API Endpoint: `version.json`

## GUI Information ##

* Location: `Help -> Welcome Screen`

## Example Usage ##

```hcl
data "nd_version" "example" {
}
```

## Schema ##

### Read-Only ###

* `build_host` (build_host) - (String) The build host of the ND Platform Version.
* `build_time` (build_time) - (String) The build time of the ND Platform Version.
* `commit_id` (commit_id) - (String) The commit id of the ND Platform Version.
* `maintenance` (maintenance) - (Number) The maintenance version number of the ND Platform Version.
* `major` (major) - (Number) The major version number of the ND Platform Version.
* `minor` (minor) - (Number) The minor version number of the ND Platform Version.
* `patch` (patch) - (String) The patch version letter of the ND Platform Version.
* `product_id` (product_id) - (String) The product id of the ND Platform Version.
* `product_name` (product_name) - (String) The product name of the ND Platform Version.
* `release` (release) - (Boolean) The release status of the ND Platform Version.
* `user` (user) - (String) The build user name of the ND Platform Version.
89 changes: 89 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
layout: "nd"
page_title: "Provider: ND"
sidebar_current: "docs-nd-index"
description: |-
The Cisco ND provider is used to interact with the resources provided by Cisco Nexus Dashboard.
The provider needs to be configured with the proper credentials before it can be used.
---

# Nexus Dashboard (ND)

Cisco Nexus Dashboard is a central management console for multiple data center sites and a common analytics solution for Cisco data center operations. Nexus Dashboard allows users to manage multiple data center sites and provide real time analytics, visibility, assurance for network policies and operations, as well as policy orchestration for the data center fabrics, such as Cisco ACI or Cisco NDFC or standalone Nexus 9000 switches.

# Cisco ND Provider

The Cisco ND terraform provider is used to interact with resources provided by Cisco Nexus Dashboard. The provider needs to be configured with proper credentials to authenticate with Cisco Nexus Dashboard.

## Authentication

Authentication with username and password.

Example:

```hcl
provider "nd" {
username = "admin"
password = "password"
url = "https://my-cisco-nd.com"
login_domain = "DefaultAuth"
}
```

## Example Usage

```hcl
terraform {
required_providers {
nd = {
source = "ciscodevnet/nd"
}
}
}

provider "nd" {
username = "admin"
password = "password"
url = "https://my-cisco-nd.com"
insecure = false
}

resource "nd_site" "example" {
name = "example"
username = "admin"
password = "password"
url = "10.195.219.154"
type = "aci"
inband_epg = "test_epg"
latitude = "19.36475238603211"
longitude = "-155.28865502961474"
login_domain = "local"
}
```

## Schema

## Required

- `username` (String) Username for the Nexus Dashboard Account.
- Environment variable: `ND_USERNAME`
- `password` (String) Password for the Nexus Dashboard Account.
- Environment variable: `ND_PASSWORD`
- `url` (String) URL of the Cisco Nexus Dashboard web interface.
- Environment variable: `ND_URL`

## Optional

- `login_domain` (String) Login domain for the Nexus Dashboard Account.
- Default: `DefaultAuth`
- Environment variable: `ND_LOGIN_DOMAIN`
- `insecure` (Boolean) Allow insecure HTTPS client.
- Default: `false`
- Environment variable: `ND_INSECURE`
- `proxy_creds` (String) Proxy server credentials in the form of `username:password`.
- Environment variable: `ND_PROXY_CREDS`
- `proxy_url` (String) Proxy Server URL with port number.
- Environment variable: `ND_PROXY_URL`
- `retries` (Number) Number of retries for REST API calls.
- Default: `2`
- Environment variable: `ND_RETRIES`
92 changes: 92 additions & 0 deletions docs/resources/site.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
subcategory: "Sites"
layout: "nd"
page_title: "ND: nd_site"
sidebar_current: "docs-nd-resource-nd_site"
description: |-
Manages Sites for Nexus Dashboard
---

# nd_site #

Manages Sites for Nexus Dashboard

## API Information ##

* Site Management [API Information](https://developer.cisco.com/docs/nexus-dashboard/3-1-1/api-reference/)
* API Endpoint: `nexus/api/sitemanagement/v4/sites`

## GUI Information ##

* Location: `Admin Console -> Manage -> Sites`
* [Guide](https://www.cisco.com/c/en/us/td/docs/dcn/nd/3x/articles-311/nexus-dashboard-sites-311.html#_adding_aci_sites)

## Example Usage ##

The configuration snippet below shows all possible attributes of the ND Site.

!> This example might not be valid configuration and is only used to show all possible attributes.

```hcl
resource "nd_site" "example" {
name = "example"
url = "10.195.219.154"
username = "admin"
password = "password"
type = "aci"
inband_epg = "epg"
login_domain = "local"
latitude = "19.36475238603211"
longitude = "-155.28865502961474"
use_proxy = false
}
```

All examples for the Site resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-nd/tree/master/examples/resources/nd_site) folder.

## Schema ##

### Required ###

* `name` (name) - (String) The name of the site.
* `url` (host) - (String) The URL of the site.
* `username` (userName) - (String) The username of the site.
* `password` (password) - (String) The password of the site.
* `type` (siteType) - (String) The type of the site.
* Valid Values: `aci`, `dcnm`, `third_party`, `cloud_aci`, `dcnm_ng`, `ndfc`.

### Optional ###

* `login_domain` (loginDomain) - (String) The login domain of the site.
* `inband_epg` (inband_epg) - (String) The In-Band Endpoint Group (EPG) used to connect ND to the site.
* `latitude` (latitude) - (String) The latitude location of the site.
* `longitude` (longitude) - (String) The longitude location of the site.
* `use_proxy` (useProxy) - (Bool) The use proxy of the site, used to route network traffic through a proxy server.
* Default: false

sajagana marked this conversation as resolved.
Show resolved Hide resolved
### Read-Only ###

* `id` (id) - (String) The ID of the site.

## Importing

An existing Site can be [imported](https://www.terraform.io/docs/import/index.html) into this resource with its name (name), via the following command:

```
terraform import nd_site.example {name}
```

Starting in Terraform version 1.5, an existing Site can be imported using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration:

```
import {
name = "{name}"
to = nd_site.example
}
```

~> The values for `username`, `password`, and `login_domain` attributes will not be imported when the `nd_site` resource imports an already registered site from Nexus Dashboard. Modifying the `username`, `password`, and `login_domain` will not update the imported site configuration on Nexus Dashboard. Use the `-replace` option to force the site recreation and use the new provided `username`, `password`, and `login_domain` attributes for the imported site.

```
terraform apply -replace="nd_site.example"
```
3 changes: 3 additions & 0 deletions examples/data-sources/nd_site/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "nd_site" "example" {
name = "example"
}
14 changes: 14 additions & 0 deletions examples/data-sources/nd_site/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
terraform {
required_providers {
nd = {
source = "ciscodevnet/nd"
}
}
}

provider "nd" {
username = ""
password = ""
url = ""
insecure = true
}
2 changes: 2 additions & 0 deletions examples/data-sources/nd_version/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
data "nd_version" "example" {
}
14 changes: 14 additions & 0 deletions examples/data-sources/nd_version/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
terraform {
required_providers {
nd = {
source = "ciscodevnet/nd"
}
}
}

provider "nd" {
username = ""
password = ""
url = ""
insecure = true
}
14 changes: 14 additions & 0 deletions examples/provider/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
terraform {
required_providers {
nd = {
source = "ciscodevnet/nd"
}
}
}

provider "nd" {
username = ""
password = ""
url = ""
insecure = true
}
12 changes: 12 additions & 0 deletions examples/resources/nd_site/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
resource "nd_site" "example" {
name = "example"
username = "admin"
password = "password"
url = "10.195.219.154"
type = "aci"
inband_epg = "test_epg"
latitude = "19.36475238603211"
longitude = "-155.28865502961474"
login_domain = "local"
use_proxy = true
}
14 changes: 14 additions & 0 deletions examples/resources/nd_site/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
terraform {
required_providers {
nd = {
source = "ciscodevnet/nd"
}
}
}

provider "nd" {
username = ""
password = ""
url = ""
insecure = true
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module terraform-provider-nd
module github.com/CiscoDevNet/terraform-provider-nd

go 1.21

Expand All @@ -10,6 +10,7 @@ require (
github.com/hashicorp/terraform-plugin-go v0.23.0
github.com/hashicorp/terraform-plugin-log v0.9.0
lhercot marked this conversation as resolved.
Show resolved Hide resolved
github.com/hashicorp/terraform-plugin-testing v1.8.0
golang.org/x/net v0.23.0
)

require (
Expand Down Expand Up @@ -74,7 +75,6 @@ require (
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/tools v0.19.0 // indirect
Expand Down
Loading
Loading