Skip to content

Commit

Permalink
eat: create device without default password(supported for only C8000V…
Browse files Browse the repository at this point in the history
… Autonomous and Fortinet firewall devices)
  • Loading branch information
kpdhulipala committed Dec 5, 2024
1 parent f59e5d5 commit 47f51fc
Show file tree
Hide file tree
Showing 7 changed files with 258 additions and 176 deletions.
33 changes: 33 additions & 0 deletions docs/resources/network_device.md
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,36 @@ resource "equinix_network_device" "zscaler-pse-single" {
}
```

```terraform
# Create C8000V BYOL device with bandwidth tier information
data "equinix_network_account" "sv" {
metro_code = "SV"
}
resource "equinix_network_device" "c8000v-byol-withtout-default-password" {
name = "tf-c8000v-byol"
metro_code = data.equinix_network_account.sv.metro_code
type_code = "C8000V"
self_managed = true
byol = true
generate_default_password = false
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 Down Expand Up @@ -589,6 +619,9 @@ The following arguments are supported:
* `connectivity` - (Optional) Device accessibility (INTERNET-ACCESS or PRIVATE or INTERNET-ACCESS-WITH-PRVT-MGMT). If not specified, default will be INTERNET-ACCESS
* `project_id` - (Optional) Unique Identifier for the project resource where the device is scoped to.If you leave it out, the device will be created under the default project id of your organization.
* `diverse_device_id` - (Optional) Unique ID of an existing device. Use this field to let Equinix know if you want your new device to be in a different location from any existing virtual device. This field is only meaningful for single devices.
* `generate_default_password` - (Optional) Boolean value that determines to create device with or without default password. Use this field to let Equinix know if you want your new device to be create with default admin password.
This field is only meaningful for C8000V Autonomous(single/ha) and Fortinet Firewall devices(single/ha/cluster). If not specified, by default device is created with admin password.


### Secondary Device

Expand Down
201 changes: 107 additions & 94 deletions equinix/resource_network_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,103 +24,105 @@ import (
)

var neDeviceSchemaNames = map[string]string{
"UUID": "uuid",
"Name": "name",
"TypeCode": "type_code",
"Status": "status",
"MetroCode": "metro_code",
"IBX": "ibx",
"Region": "region",
"Throughput": "throughput",
"ThroughputUnit": "throughput_unit",
"HostName": "hostname",
"PackageCode": "package_code",
"Version": "version",
"IsBYOL": "byol",
"LicenseToken": "license_token",
"LicenseFile": "license_file",
"LicenseFileID": "license_file_id",
"CloudInitFileID": "cloud_init_file_id",
"LicenseStatus": "license_status",
"ACLTemplateUUID": "acl_template_id",
"MgmtAclTemplateUuid": "mgmt_acl_template_uuid",
"SSHIPAddress": "ssh_ip_address",
"SSHIPFqdn": "ssh_ip_fqdn",
"AccountNumber": "account_number",
"Notifications": "notifications",
"PurchaseOrderNumber": "purchase_order_number",
"RedundancyType": "redundancy_type",
"RedundantUUID": "redundant_id",
"ProjectID": "project_id",
"TermLength": "term_length",
"AdditionalBandwidth": "additional_bandwidth",
"OrderReference": "order_reference",
"InterfaceCount": "interface_count",
"CoreCount": "core_count",
"IsSelfManaged": "self_managed",
"WanInterfaceId": "wan_interface_id",
"Interfaces": "interface",
"VendorConfiguration": "vendor_configuration",
"UserPublicKey": "ssh_key",
"ASN": "asn",
"ZoneCode": "zone_code",
"Secondary": "secondary_device",
"ClusterDetails": "cluster_details",
"ValidStatusList": "valid_status_list",
"Connectivity": "connectivity",
"DiverseFromDeviceUUID": "diverse_device_id",
"DiverseFromDeviceName": "diverse_device_name",
"Tier": "tier",
"UUID": "uuid",
"Name": "name",
"TypeCode": "type_code",
"Status": "status",
"MetroCode": "metro_code",
"IBX": "ibx",
"Region": "region",
"Throughput": "throughput",
"ThroughputUnit": "throughput_unit",
"HostName": "hostname",
"PackageCode": "package_code",
"Version": "version",
"IsBYOL": "byol",
"LicenseToken": "license_token",
"LicenseFile": "license_file",
"LicenseFileID": "license_file_id",
"CloudInitFileID": "cloud_init_file_id",
"LicenseStatus": "license_status",
"ACLTemplateUUID": "acl_template_id",
"MgmtAclTemplateUuid": "mgmt_acl_template_uuid",
"SSHIPAddress": "ssh_ip_address",
"SSHIPFqdn": "ssh_ip_fqdn",
"AccountNumber": "account_number",
"Notifications": "notifications",
"PurchaseOrderNumber": "purchase_order_number",
"RedundancyType": "redundancy_type",
"RedundantUUID": "redundant_id",
"ProjectID": "project_id",
"TermLength": "term_length",
"AdditionalBandwidth": "additional_bandwidth",
"OrderReference": "order_reference",
"InterfaceCount": "interface_count",
"CoreCount": "core_count",
"IsSelfManaged": "self_managed",
"WanInterfaceId": "wan_interface_id",
"Interfaces": "interface",
"VendorConfiguration": "vendor_configuration",
"UserPublicKey": "ssh_key",
"ASN": "asn",
"ZoneCode": "zone_code",
"Secondary": "secondary_device",
"ClusterDetails": "cluster_details",
"ValidStatusList": "valid_status_list",
"Connectivity": "connectivity",
"DiverseFromDeviceUUID": "diverse_device_id",
"DiverseFromDeviceName": "diverse_device_name",
"IsGenerateDefaultPassword": "generate_default_password",
"Tier": "tier",
}

var neDeviceDescriptions = map[string]string{
"UUID": "Device unique identifier",
"Name": "Device name",
"TypeCode": "Device type code",
"Status": "Device provisioning status",
"MetroCode": "Device location metro code",
"IBX": "Device location Equinix Business Exchange name",
"Region": "Device location region",
"Throughput": "Device license throughput",
"ThroughputUnit": "Device license throughput unit (Mbps or Gbps)",
"HostName": "Device hostname prefix",
"PackageCode": "Device software package code",
"Version": "Device software software version",
"IsBYOL": "Boolean value that determines device licensing mode: bring your own license or subscription (default)",
"LicenseToken": "License Token applicable for some device types in BYOL licensing mode",
"LicenseFile": "Path to the license file that will be uploaded and applied on a device, applicable for some device types in BYOL licensing mode",
"LicenseFileID": "Unique identifier of applied license file",
"CloudInitFileID": "Unique identifier of applied cloud init file",
"LicenseStatus": "Device license registration status",
"ACLTemplateUUID": "Unique identifier of applied ACL template",
"MgmtAclTemplateUuid": "Unique identifier of applied MGMT ACL template",
"SSHIPAddress": "IP address of SSH enabled interface on the device",
"SSHIPFqdn": "FQDN of SSH enabled interface on the device",
"AccountNumber": "Device billing account number",
"Notifications": "List of email addresses that will receive device status notifications",
"PurchaseOrderNumber": "Purchase order number associated with a device order",
"RedundancyType": "Device redundancy type applicable for HA devices, either primary or secondary",
"RedundantUUID": "Unique identifier for a redundant device, applicable for HA device",
"TermLength": "Device term length",
"AdditionalBandwidth": "Additional Internet bandwidth, in Mbps, that will be allocated to the device",
"OrderReference": "Name/number used to identify device order on the invoice",
"InterfaceCount": "Number of network interfaces on a device. If not specified, default number for a given device type will be used",
"CoreCount": "Number of CPU cores used by device",
"IsSelfManaged": "Boolean value that determines device management mode: self-managed or subscription (default)",
"WanInterfaceId": "device interface id picked for WAN",
"Interfaces": "List of device interfaces",
"VendorConfiguration": "Map of vendor specific configuration parameters for a device (controller1, activationKey, managementType, siteId, systemIpAddress)",
"UserPublicKey": "Definition of SSH key that will be provisioned on a device",
"ASN": "Autonomous system number",
"ZoneCode": "Device location zone code",
"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",
"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",
"UUID": "Device unique identifier",
"Name": "Device name",
"TypeCode": "Device type code",
"Status": "Device provisioning status",
"MetroCode": "Device location metro code",
"IBX": "Device location Equinix Business Exchange name",
"Region": "Device location region",
"Throughput": "Device license throughput",
"ThroughputUnit": "Device license throughput unit (Mbps or Gbps)",
"HostName": "Device hostname prefix",
"PackageCode": "Device software package code",
"Version": "Device software software version",
"IsBYOL": "Boolean value that determines device licensing mode: bring your own license or subscription (default)",
"LicenseToken": "License Token applicable for some device types in BYOL licensing mode",
"LicenseFile": "Path to the license file that will be uploaded and applied on a device, applicable for some device types in BYOL licensing mode",
"LicenseFileID": "Unique identifier of applied license file",
"CloudInitFileID": "Unique identifier of applied cloud init file",
"LicenseStatus": "Device license registration status",
"ACLTemplateUUID": "Unique identifier of applied ACL template",
"MgmtAclTemplateUuid": "Unique identifier of applied MGMT ACL template",
"SSHIPAddress": "IP address of SSH enabled interface on the device",
"SSHIPFqdn": "FQDN of SSH enabled interface on the device",
"AccountNumber": "Device billing account number",
"Notifications": "List of email addresses that will receive device status notifications",
"PurchaseOrderNumber": "Purchase order number associated with a device order",
"RedundancyType": "Device redundancy type applicable for HA devices, either primary or secondary",
"RedundantUUID": "Unique identifier for a redundant device, applicable for HA device",
"TermLength": "Device term length",
"AdditionalBandwidth": "Additional Internet bandwidth, in Mbps, that will be allocated to the device",
"OrderReference": "Name/number used to identify device order on the invoice",
"InterfaceCount": "Number of network interfaces on a device. If not specified, default number for a given device type will be used",
"CoreCount": "Number of CPU cores used by device",
"IsSelfManaged": "Boolean value that determines device management mode: self-managed or subscription (default)",
"WanInterfaceId": "device interface id picked for WAN",
"Interfaces": "List of device interfaces",
"VendorConfiguration": "Map of vendor specific configuration parameters for a device (controller1, activationKey, managementType, siteId, systemIpAddress)",
"UserPublicKey": "Definition of SSH key that will be provisioned on a device",
"ASN": "Autonomous system number",
"ZoneCode": "Device location zone code",
"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",
"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",
"IsGenerateDefaultPassword": "Boolean value that decides to generate default admin password for devices. Default value is true if not provided.",
}

var neDeviceInterfaceSchemaNames = map[string]string{
Expand Down Expand Up @@ -332,6 +334,13 @@ func createNetworkDeviceSchema() map[string]*schema.Schema {
ForceNew: true,
Description: neDeviceDescriptions["IsBYOL"],
},
neDeviceSchemaNames["IsGenerateDefaultPassword"]: {
Type: schema.TypeBool,
Optional: true,
Default: true,
ForceNew: true,
Description: neDeviceDescriptions["IsGenerateDefaultPassword"],
},
neDeviceSchemaNames["LicenseToken"]: {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -1170,6 +1179,7 @@ func createNetworkDevices(d *schema.ResourceData) (*ne.Device, *ne.Device) {
primary.Version = ne.String(v.(string))
}
primary.IsBYOL = ne.Bool(d.Get(neDeviceSchemaNames["IsBYOL"]).(bool))
primary.IsGenerateDefaultPassword = ne.Bool(d.Get(neDeviceSchemaNames["IsGenerateDefaultPassword"]).(bool))
if v, ok := d.GetOk(neDeviceSchemaNames["LicenseToken"]); ok {
primary.LicenseToken = ne.String(v.(string))
}
Expand Down Expand Up @@ -1293,6 +1303,9 @@ func updateNetworkDeviceResource(primary *ne.Device, secondary *ne.Device, d *sc
if err := d.Set(neDeviceSchemaNames["IsBYOL"], primary.IsBYOL); err != nil {
return fmt.Errorf("error reading IsBYOL: %s", err)
}
if err := d.Set(neDeviceSchemaNames["IsGenerateDefaultPassword"], primary.IsGenerateDefaultPassword); err != nil {
return fmt.Errorf("error reading GenerateDefaultPassword: %s", err)
}
if err := d.Set(neDeviceSchemaNames["LicenseFileID"], primary.LicenseFileID); err != nil {
return fmt.Errorf("error reading LicenseFileID: %s", err)
}
Expand Down
Loading

0 comments on commit 47f51fc

Please sign in to comment.