Skip to content

Commit

Permalink
Merge pull request #361 from schadalawada/master
Browse files Browse the repository at this point in the history
NFV-25337: Added attribute Connectivity to support device creation with no internet access
  • Loading branch information
ctreatma authored Aug 23, 2023
2 parents 24cb78c + 1d8f678 commit 5f69208
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/data-sources/equinix_network_device.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ NOTE: Exactly one of either `uuid` or `name` must be specified.
* APPLIED
* WAITING_FOR_CLUSTER_SETUP
* REGISTRATION_FAILED
* NA
* `license_file_id` - Unique identifier of applied license file
* `ibx` - Device location Equinix Business Exchange name
* `region` - Device location region
Expand All @@ -71,3 +72,4 @@ primary or secondary
* `zone_code` - Device location zone code
* `cluster_id` - The id of the cluster
* `num_of_nodes` - The number of nodes in the cluster
* `connectivity` - Device accessibility (INTERNET-ACCESS or PRIVATE or INTERNET-ACCESS-WITH-PRVT-MGMT)
4 changes: 4 additions & 0 deletions docs/resources/equinix_network_device.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ resource "equinix_network_device" "csr1000v-ha" {
metro_code = data.equinix_network_account.dc.metro_code
type_code = "CSR1000V"
self_managed = false
connectivity = "INTERNET-ACCESS"
byol = false
package_code = "SEC"
notifications = ["[email protected]", "[email protected]", "[email protected]"]
Expand Down Expand Up @@ -190,6 +191,7 @@ resource "equinix_network_device" "arista-ha" {
metro_code = data.equinix_network_account.sv.metro_code
type_code = "ARISTA-ROUTER"
self_managed = true
connectivity = "PRIVATE"
byol = true
package_code = "CloudEOS"
notifications = ["[email protected]"]
Expand Down Expand Up @@ -261,6 +263,8 @@ on a device (max one key). See [SSH Key](#ssh-key) below for more details.
device configurations. See [Secondary Device](#secondary-device) below for more details.
* `cluster_details` - (Optional) An object that has the cluster details. See
[Cluster Details](#cluster-details) below for more details.
* `connectivity` - (Optional) Device accessibility (INTERNET-ACCESS or PRIVATE or INTERNET-ACCESS-WITH-PRVT-MGMT).
If not specified, default will be INTERNET-ACCESS

### Secondary Device

Expand Down
5 changes: 5 additions & 0 deletions equinix/data_source_network_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ func createDataSourceNetworkDeviceSchema() map[string]*schema.Schema {
Computed: true,
Description: neDeviceDescriptions["ZoneCode"],
},
neDeviceSchemaNames["Connectivity"]: {
Type: schema.TypeString,
Computed: true,
Description: neDeviceDescriptions["Connectivity"],
},
neDeviceSchemaNames["Secondary"]: {
Type: schema.TypeList,
Computed: true,
Expand Down
14 changes: 14 additions & 0 deletions equinix/resource_network_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ var neDeviceSchemaNames = map[string]string{
"Secondary": "secondary_device",
"ClusterDetails": "cluster_details",
"ValidStatusList": "valid_status_list",
"Connectivity": "connectivity",
}

var neDeviceDescriptions = map[string]string{
Expand Down Expand Up @@ -105,6 +106,7 @@ var neDeviceDescriptions = map[string]string{
"Secondary": "Definition of secondary device applicable for HA setup",
"ClusterDetails": "An object that has the cluster details",
"ValidStatusList": "Comma Separated List of states to be considered valid when searching by name",
"Connectivity": "Parameter to identify internet access for device. Supported Values: INTERNET-ACCESS(default) or PRIVATE or INTERNET-ACCESS-WITH-PRVT-MGMT",
}

var neDeviceInterfaceSchemaNames = map[string]string{
Expand Down Expand Up @@ -479,6 +481,14 @@ func createNetworkDeviceSchema() map[string]*schema.Schema {
Computed: true,
Description: neDeviceDescriptions["ZoneCode"],
},
neDeviceSchemaNames["Connectivity"]: {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Default: "INTERNET-ACCESS",
ValidateFunc: validation.StringInSlice([]string{"INTERNET-ACCESS", "PRIVATE", "INTERNET-ACCESS-WITH-PRVT-MGMT"}, false),
Description: neDeviceDescriptions["Connectivity"],
},
neDeviceSchemaNames["Secondary"]: {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -1100,6 +1110,9 @@ func createNetworkDevices(d *schema.ResourceData) (*ne.Device, *ne.Device) {
if v, ok := d.GetOk(neDeviceSchemaNames["ClusterDetails"]); ok {
primary.ClusterDetails = expandNetworkDeviceClusterDetails(v.([]interface{}))
}
if v, ok := d.GetOk(neDeviceSchemaNames["Connectivity"]); ok {
primary.Connectivity = ne.String(v.(string))
}
return primary, secondary
}

Expand Down Expand Up @@ -1603,6 +1616,7 @@ func createNetworkDeviceLicenseStatusWaitConfiguration(fetchFunc getDevice, id s
target := []string{
ne.DeviceLicenseStateRegistered,
ne.DeviceLicenseStateApplied,
ne.DeviceLicenseStateNA,
}
return &retry.StateChangeConf{
Pending: pending,
Expand Down
4 changes: 4 additions & 0 deletions equinix/resource_network_device_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ func TestAccNetworkDevice_PaloAlto_HA_Self_BYOL(t *testing.T) {
"device-resourceName": "test",
"device-account_name": accountName.(string),
"device-self_managed": true,
"connectivity": "PRIVATE",
"device-byol": true,
"device-name": fmt.Sprintf("%s-%s", tstResourcePrefix, randString(6)),
"device-metro_code": metro.(string),
Expand Down Expand Up @@ -1034,6 +1035,9 @@ func testAccNeDeviceAttributes(device *ne.Device, ctx map[string]interface{}) re
if v, ok := ctx["device-vendorConfig_serialNumber"]; ok && device.VendorConfiguration["serialNumber"] != v.(string) {
return fmt.Errorf("device-vendorConfig_serialNumber does not match %v - %v", device.VendorConfiguration["serialNumber"], v)
}
if v, ok := ctx["connectivity"]; ok && ne.StringValue(device.Connectivity) != v.(string) {
return fmt.Errorf("connectivity does not match %v - %v", ne.StringValue(device.Connectivity), v)
}
return nil
}
}
Expand Down
1 change: 1 addition & 0 deletions equinix/resource_network_device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func TestNetworkDevice_createFromResourceData(t *testing.T) {
IsSelfManaged: ne.Bool(false),
VendorConfiguration: expectedPrimaryVendorConfig,
UserPublicKey: &expectedPrimaryUserKey,
Connectivity: ne.String("INTERNET-ACCESS"),
}
rawData := map[string]interface{}{
neDeviceSchemaNames["Name"]: ne.StringValue(expectedPrimary.Name),
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/equinix-labs/fabric-go v0.4.0
github.com/equinix-labs/metal-go v0.16.0
github.com/equinix/ecx-go/v2 v2.3.1
github.com/equinix/ne-go v1.10.0
github.com/equinix/ne-go v1.11.0
github.com/equinix/oauth2-go v1.0.0
github.com/equinix/rest-go v1.3.0
github.com/gruntwork-io/terratest v0.43.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ github.com/equinix-labs/metal-go v0.16.0 h1:4YmGx9SRFkDtHiEqRsSjlgJDztV6NHqH1eea
github.com/equinix-labs/metal-go v0.16.0/go.mod h1:SmxCklxW+KjmBLVMdEXgtFO5gD5/b4N0VxcNgUYbOH4=
github.com/equinix/ecx-go/v2 v2.3.1 h1:gFcAIeyaEUw7S8ebqApmT7E/S7pC7Ac3wgScp89fkPU=
github.com/equinix/ecx-go/v2 v2.3.1/go.mod h1:FvCdZ3jXU8Z4CPKig2DT+4J2HdwgRK17pIcznM7RXyk=
github.com/equinix/ne-go v1.10.0 h1:hy1umXQFPi1b3z/maZ8kqLRFlD1PXD4qp0cV8rnyL8k=
github.com/equinix/ne-go v1.10.0/go.mod h1:eHkkxM4nbTB7DZ9X9zGnwfYnxIJWIsU3aHA+FAoZ1EI=
github.com/equinix/ne-go v1.11.0 h1:ja6G2fmcGrLsOeV25Mq6pDfH+/cUlvxJbnE8uRXTGGk=
github.com/equinix/ne-go v1.11.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

0 comments on commit 5f69208

Please sign in to comment.