Skip to content

Commit

Permalink
feat: Add optional attribute tier in Create Virtual Device request fo…
Browse files Browse the repository at this point in the history
…r C8000V and C8000V SDWAN
  • Loading branch information
kpdhulipala committed Sep 12, 2024
1 parent 692594c commit fc8577d
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 5 deletions.
33 changes: 32 additions & 1 deletion docs/resources/network_device.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,36 @@ resource "equinix_network_device" "panw-cluster" {
}
```

```terraform
# Create C8000V BYOL device with bandwidth tier information
data "equinix_network_account" "sv" {
metro_code = "SV"
}
resource "equinix_network_device" "panw-cluster" {
name = "tf-c8000v-byol"
metro_code = data.equinix_network_account.sv.metro_code
type_code = "C8000V"
self_managed = true
byol = true
package_code = "VM100"
notifications = ["[email protected]", "[email protected]", "[email protected]"]
term_length = 12
account_number = data.equinix_network_account.sv.number
version = "17.11.01a"
interface_count = 10
core_count = 2
tier = 1
ssh_key {
username = "test"
key_name = "test-key"
}
acl_template_id = "0bff6e05-f0e7-44cd-804a-25b92b835f8b"
}
```


## Argument Reference

The following arguments are supported:
Expand All @@ -406,8 +436,9 @@ The following arguments are supported:
* `metro_code` - (Required) Device location metro code.
* `hostname` - (Optional) Device hostname prefix.
* `package_code` - (Required) Device software package code.
* `version` - (Required) Device software software version.
* `version` - (Required) Device software version.
* `core_count` - (Required) Number of CPU cores used by device. (**NOTE: Use this field to resize your device. When resizing your HA devices, primary device will be upgraded first. If the upgrade failed, device will be automatically rolled back to the previous state with original core number.**)
* `tier` - (Optional) Select bandwidth tier for your own license, i.e., `0` or `1` or `2` or `3`. Tiers applicable only for C8000V Autonomous or C8000V SDWAN (controller) device types. If not provided, tier is defaulted to '2' for C8000V and C8000V-SDWAN device types.
* `term_length` - (Required) Device term length.
* `self_managed` - (Optional) Boolean value that determines device management mode, i.e., `self-managed` or `Equinix-managed` (default).
* `byol` - (Optional) Boolean value that determines device licensing mode, i.e., `bring your own license` or `subscription` (default).
Expand Down
8 changes: 8 additions & 0 deletions equinix/data_source_network_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ func createDataSourceNetworkDeviceSchema() map[string]*schema.Schema {
Computed: true,
Description: neDeviceDescriptions["DiverseFromDeviceUUID"],
},
neDeviceSchemaNames["Tier"]: {
Type: schema.TypeInt,
Computed: true,
Description: neDeviceDescriptions["Tier"],
},
neDeviceSchemaNames["DiverseFromDeviceName"]: {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -853,6 +858,9 @@ func updateDataSourceNetworkDeviceResource(primary *ne.Device, secondary *ne.Dev
if err := d.Set(neDeviceSchemaNames["DiverseFromDeviceUUID"], primary.DiverseFromDeviceUUID); err != nil {
return fmt.Errorf("error reading DiverseFromDeviceUUID: %s", err)
}
if err := d.Set(neDeviceSchemaNames["Tier"], primary.Tier); err != nil {
return fmt.Errorf("error reading Tier: %s", err)
}
if err := d.Set(neDeviceSchemaNames["DiverseFromDeviceName"], primary.DiverseFromDeviceName); err != nil {
return fmt.Errorf("error reading DiverseFromDeviceName: %s", err)
}
Expand Down
20 changes: 20 additions & 0 deletions equinix/resource_network_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ var neDeviceSchemaNames = map[string]string{
"Connectivity": "connectivity",
"DiverseFromDeviceUUID": "diverse_device_id",
"DiverseFromDeviceName": "diverse_device_name",
"Tier": "tier",
}

var neDeviceDescriptions = map[string]string{
Expand Down Expand Up @@ -119,6 +120,7 @@ var neDeviceDescriptions = map[string]string{
"ProjectID": "The unique identifier of Project Resource to which device is scoped to",
"DiverseFromDeviceUUID": "Unique ID of an existing device",
"DiverseFromDeviceName": "Diverse Device Name of an existing device",
"Tier": "Bandwidth Tiers",
}

var neDeviceInterfaceSchemaNames = map[string]string{
Expand Down Expand Up @@ -442,6 +444,14 @@ func createNetworkDeviceSchema() map[string]*schema.Schema {
ConflictsWith: []string{neDeviceSchemaNames["Secondary"]},
Description: neDeviceDescriptions["DiverseFromDeviceUUID"],
},
neDeviceSchemaNames["Tier"]: {
Type: schema.TypeInt,
ForceNew: true,
Computed: true,
Optional: true,
ValidateFunc: validation.IntInSlice([]int{0, 1, 2, 3}),
Description: neDeviceDescriptions["Tier"],
},
neDeviceSchemaNames["DiverseFromDeviceName"]: {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -1140,6 +1150,9 @@ func createNetworkDevices(d *schema.ResourceData) (*ne.Device, *ne.Device) {
if v, ok := d.GetOk(neDeviceSchemaNames["ProjectID"]); ok {
primary.ProjectID = ne.String(v.(string))
}
if v, ok := d.GetOk(neDeviceSchemaNames["Tier"]); ok {
primary.Tier = ne.Int(v.(int))
}
if v, ok := d.GetOk(neDeviceSchemaNames["DiverseFromDeviceUUID"]); ok {
primary.DiverseFromDeviceUUID = ne.String(v.(string))
}
Expand Down Expand Up @@ -1234,6 +1247,9 @@ func updateNetworkDeviceResource(primary *ne.Device, secondary *ne.Device, d *sc
if err := d.Set(neDeviceSchemaNames["Name"], primary.Name); err != nil {
return fmt.Errorf("error reading Name: %s", err)
}
if err := d.Set(neDeviceSchemaNames["Tier"], primary.Tier); err != nil {
return fmt.Errorf("error reading Tier: %s", err)
}
if err := d.Set(neDeviceSchemaNames["ProjectID"], primary.ProjectID); err != nil {
return fmt.Errorf("error reading ProjectID: %s", err)
}
Expand Down Expand Up @@ -1368,6 +1384,7 @@ func updateNetworkDeviceResource(primary *ne.Device, secondary *ne.Device, d *sc
func flattenNetworkDeviceSecondary(device *ne.Device) interface{} {
transformed := make(map[string]interface{})
transformed[neDeviceSchemaNames["UUID"]] = device.UUID
transformed[neDeviceSchemaNames["Tier"]] = device.Tier
transformed[neDeviceSchemaNames["Name"]] = device.Name
transformed[neDeviceSchemaNames["Status"]] = device.Status
transformed[neDeviceSchemaNames["LicenseStatus"]] = device.LicenseStatus
Expand Down Expand Up @@ -1409,6 +1426,9 @@ func expandNetworkDeviceSecondary(devices []interface{}) *ne.Device {
if v, ok := device[neDeviceSchemaNames["Name"]]; ok && !isEmpty(v) {
transformed.Name = ne.String(v.(string))
}
if v, ok := device[neDeviceSchemaNames["Tier"]]; ok && !isEmpty(v) {
transformed.Tier = ne.Int(v.(int))
}
if v, ok := device[neDeviceSchemaNames["ProjectID"]]; ok && !isEmpty(v) {
transformed.ProjectID = ne.String(v.(string))
}
Expand Down
26 changes: 26 additions & 0 deletions examples/resources/equinix_network_device/example_10.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Create C8000V BYOL device with bandwidth tier information

data "equinix_network_account" "sv" {
metro_code = "SV"
}

resource "equinix_network_device" "panw-cluster" {
name = "tf-c8000v-byol"
metro_code = data.equinix_network_account.sv.metro_code
type_code = "C8000V"
self_managed = true
byol = true
package_code = "VM100"
notifications = ["[email protected]", "[email protected]", "[email protected]"]
term_length = 12
account_number = data.equinix_network_account.sv.number
version = "17.11.01a"
interface_count = 10
core_count = 2
tier = 1
ssh_key {
username = "test"
key_name = "test-key"
}
acl_template_id = "0bff6e05-f0e7-44cd-804a-25b92b835f8b"
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.22

require (
github.com/equinix/equinix-sdk-go v0.44.0
github.com/equinix/ne-go v1.17.0
github.com/equinix/ne-go v1.18.0
github.com/equinix/oauth2-go v1.0.0
github.com/equinix/rest-go v1.3.0
github.com/google/uuid v1.6.0
Expand Down Expand Up @@ -97,4 +97,4 @@ require (
google.golang.org/protobuf v1.34.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/equinix/equinix-sdk-go v0.44.0 h1:v4ejvEGC6TYiwQ29NW4zaq7SlnqLe9SJmfLb4aanbkQ=
github.com/equinix/equinix-sdk-go v0.44.0/go.mod h1:hEb3XLaedz7xhl/dpPIS6eOIiXNPeqNiVoyDrT6paIg=
github.com/equinix/ne-go v1.17.0 h1:+wZq0GNognpiTHTsBXtATOCphTFvnowF046NzQXj0n0=
github.com/equinix/ne-go v1.17.0/go.mod h1:eHkkxM4nbTB7DZ9X9zGnwfYnxIJWIsU3aHA+FAoZ1EI=
github.com/equinix/ne-go v1.18.0 h1:5az4ai39y1XLNOq3+qQVT9wFG7BmaQfj941MNqqouhk=
github.com/equinix/ne-go v1.18.0/go.mod h1:eHkkxM4nbTB7DZ9X9zGnwfYnxIJWIsU3aHA+FAoZ1EI=
github.com/equinix/oauth2-go v1.0.0 h1:fHtAPGq82PdgtK5vEThs8Vwz6f7D/8SX4tE3NJu+KcU=
github.com/equinix/oauth2-go v1.0.0/go.mod h1:4pulXvUNMktJlewLPnUeJyMW52iCoF1aM+A/Z5xY1ws=
github.com/equinix/rest-go v1.3.0 h1:m38scYTOfV6N+gcrwchgVDutDffYd+QoYCMm9Jn6jyk=
Expand Down
4 changes: 4 additions & 0 deletions templates/resources/network_device.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ In addition to management modes, there are two software license modes available:

{{tffile "examples/resources/equinix_network_device/example_9.tf"}}

{{tffile "examples/resources/network_device/example_10.tf"}}


## Argument Reference

The following arguments are supported:
Expand All @@ -51,6 +54,7 @@ The following arguments are supported:
* `package_code` - (Required) Device software package code.
* `version` - (Required) Device software software version.
* `core_count` - (Required) Number of CPU cores used by device. (**NOTE: Use this field to resize your device. When resizing your HA devices, primary device will be upgraded first. If the upgrade failed, device will be automatically rolled back to the previous state with original core number.**)
* `tier` - (Optional) Select bandwidth tier for your own license, i.e., `0` or `1` or `2` or `3`. Tiers applicable only for C8000V Autonomous or C8000V SDWAN (controller) device types. If not provided, tier is defaulted to '2'.
* `term_length` - (Required) Device term length.
* `self_managed` - (Optional) Boolean value that determines device management mode, i.e., `self-managed` or `Equinix-managed` (default).
* `byol` - (Optional) Boolean value that determines device licensing mode, i.e., `bring your own license` or `subscription` (default).
Expand Down

0 comments on commit fc8577d

Please sign in to comment.