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

feat: Misc fixes #198

Merged
merged 13 commits into from
Mar 14, 2023
Merged
2 changes: 0 additions & 2 deletions examples/exports/v3.2/netbox_virtualization_cluster types.csv

This file was deleted.

2 changes: 0 additions & 2 deletions examples/exports/v3.2/netbox_virtualization_clusters.csv

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name,content_types,label,type,required,description,weight,default,filter_logic,choices,object_type
cf_boolean,"virtualization.virtualmachine,tenancy.tenant,tenancy.contactrole,tenancy.contactgroup,ipam.aggregate,ipam.ipaddress,ipam.prefix,tenancy.contact,ipam.vlan,ipam.service,ipam.iprange","Boolean field",boolean,False,,100,,loose,,
cf_date,"tenancy.tenant,tenancy.contactrole,tenancy.contactgroup,ipam.aggregate,ipam.ipaddress,ipam.prefix,tenancy.contact,virtualization.virtualmachine,ipam.vlan,ipam.service,ipam.iprange",,date,False,,100,,loose,,
cf_integer,"tenancy.tenant,tenancy.contactrole,tenancy.contactgroup,ipam.aggregate,ipam.ipaddress,ipam.prefix,tenancy.contact,virtualization.virtualmachine,ipam.vlan,ipam.service,ipam.iprange",,integer,False,,100,,loose,,
cf_multi_selection,"tenancy.tenant,tenancy.contactrole,tenancy.contactgroup,ipam.aggregate,ipam.ipaddress,ipam.prefix,tenancy.contact,virtualization.virtualmachine,ipam.vlan,ipam.service,ipam.iprange",,multiselect,False,,100,,loose,"0,1",
cf_selection,"tenancy.tenant,tenancy.contactrole,tenancy.contactgroup,ipam.aggregate,ipam.ipaddress,ipam.prefix,tenancy.contact,virtualization.virtualmachine,ipam.vlan,ipam.service,ipam.iprange",,select,False,,100,,loose,"0,1",
cf_text,"tenancy.tenant,tenancy.contactrole,tenancy.contactgroup,ipam.aggregate,ipam.ipaddress,ipam.prefix,tenancy.contact,virtualization.virtualmachine,ipam.vlan,ipam.service,ipam.iprange",,text,False,,100,,loose,,
cf_url,"tenancy.tenant,tenancy.contactrole,tenancy.contactgroup,ipam.aggregate,ipam.ipaddress,ipam.prefix,tenancy.contact,virtualization.virtualmachine,ipam.vlan,ipam.service,ipam.iprange",,url,False,,100,,loose,,
cf_json,"tenancy.tenant,tenancy.contactrole,tenancy.contactgroup,ipam.aggregate,ipam.ipaddress,ipam.prefix,tenancy.contact,virtualization.virtualmachine,ipam.vlan,ipam.service,ipam.iprange",,json,False,,100,,loose,,
cf_multi_object,"tenancy.tenant,tenancy.contactrole,tenancy.contactgroup,ipam.aggregate,ipam.ipaddress,ipam.prefix,tenancy.contact,virtualization.virtualmachine,ipam.vlan,ipam.service,ipam.iprange",,multiobject,False,,100,,loose,,dcim.platform
cf_object,"tenancy.tenant,tenancy.contactrole,tenancy.contactgroup,ipam.aggregate,ipam.ipaddress,ipam.prefix,tenancy.contact,virtualization.virtualmachine,ipam.vlan,ipam.service,ipam.iprange",,multiobject,False,,100,,loose,,dcim.platform
name,content_types,label,type,required,description,weight,default,filter_logic,choices,object_type,ui_visibility
cf_boolean,"virtualization.virtualmachine,tenancy.tenant,tenancy.contactrole,tenancy.contactgroup,ipam.aggregate,ipam.ipaddress,ipam.prefix,tenancy.contact,ipam.vlan,ipam.service,ipam.iprange","Boolean field",boolean,False,,100,,loose,,,read-write
cf_date,"tenancy.tenant,tenancy.contactrole,tenancy.contactgroup,ipam.aggregate,ipam.ipaddress,ipam.prefix,tenancy.contact,virtualization.virtualmachine,ipam.vlan,ipam.service,ipam.iprange",,date,False,,100,,loose,,,read-write
cf_integer,"tenancy.tenant,tenancy.contactrole,tenancy.contactgroup,ipam.aggregate,ipam.ipaddress,ipam.prefix,tenancy.contact,virtualization.virtualmachine,ipam.vlan,ipam.service,ipam.iprange",,integer,False,,100,,loose,,,read-write
cf_multi_selection,"tenancy.tenant,tenancy.contactrole,tenancy.contactgroup,ipam.aggregate,ipam.ipaddress,ipam.prefix,tenancy.contact,virtualization.virtualmachine,ipam.vlan,ipam.service,ipam.iprange",,multiselect,False,,100,,loose,"0,1",,read-write
cf_selection,"tenancy.tenant,tenancy.contactrole,tenancy.contactgroup,ipam.aggregate,ipam.ipaddress,ipam.prefix,tenancy.contact,virtualization.virtualmachine,ipam.vlan,ipam.service,ipam.iprange",,select,False,,100,,loose,"0,1",,read-write
cf_text,"tenancy.tenant,tenancy.contactrole,tenancy.contactgroup,ipam.aggregate,ipam.ipaddress,ipam.prefix,tenancy.contact,virtualization.virtualmachine,ipam.vlan,ipam.service,ipam.iprange",,text,False,,100,,loose,,,read-write
cf_url,"tenancy.tenant,tenancy.contactrole,tenancy.contactgroup,ipam.aggregate,ipam.ipaddress,ipam.prefix,tenancy.contact,virtualization.virtualmachine,ipam.vlan,ipam.service,ipam.iprange",,url,False,,100,,loose,,,read-write
cf_json,"tenancy.tenant,tenancy.contactrole,tenancy.contactgroup,ipam.aggregate,ipam.ipaddress,ipam.prefix,tenancy.contact,virtualization.virtualmachine,ipam.vlan,ipam.service,ipam.iprange",,json,False,,100,,loose,,,read-write
cf_multi_object,"tenancy.tenant,tenancy.contactrole,tenancy.contactgroup,ipam.aggregate,ipam.ipaddress,ipam.prefix,tenancy.contact,virtualization.virtualmachine,ipam.vlan,ipam.service,ipam.iprange",,multiobject,False,,100,,loose,,dcim.platform,read-write
cf_object,"tenancy.tenant,tenancy.contactrole,tenancy.contactgroup,ipam.aggregate,ipam.ipaddress,ipam.prefix,tenancy.contact,virtualization.virtualmachine,ipam.vlan,ipam.service,ipam.iprange",,multiobject,False,,100,,loose,,dcim.platform,read-write
2 changes: 2 additions & 0 deletions examples/exports/v3.3/netbox_virtualization_cluster types.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name,description,slug
"Test Cluster Type","Test Cluster Type",test_cluster_type
2 changes: 2 additions & 0 deletions examples/exports/v3.3/netbox_virtualization_clusters.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name,type,status
"Test Cluster","Test Cluster Type",active
87 changes: 81 additions & 6 deletions examples/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,92 @@ data "netbox_dcim_site" "site_test" {
}

resource "netbox_ipam_vlan_group" "vlan_group_test" {
name = "Test_VlanGroup"
slug = "Test_VlanGroup"
name = "TestVlanGroup"
slug = "TestVlanGroup"

max_vid = 4094
min_vid = 1

scope {
id = 1
type = "dcim.site"
}

tag {
name = "tag1"
slug = "tag1"
}

tag {
name = "tag2"
slug = "tag2"
custom_field {
name = "cf_boolean"
type = "boolean"
value = "true"
}

custom_field {
name = "cf_date"
type = "date"
value = "2020-12-25"
}

custom_field {
name = "cf_text"
type = "text"
value = "some text"
}

custom_field {
name = "cf_integer"
type = "integer"
value = "10"
}

custom_field {
name = "cf_selection"
type = "select"
value = "1"
}

custom_field {
name = "cf_url"
type = "url"
value = "https://github.com"
}

custom_field {
name = "cf_multi_selection"
type = "multiselect"
value = jsonencode([
"0",
"1"
])
}

custom_field {
name = "cf_json"
type = "json"
value = jsonencode({
stringvalue = "string"
boolvalue = false
dictionary = {
numbervalue = 5
}
})
}

custom_field {
name = "cf_object"
type = "object"
value = 1
}

custom_field {
name = "cf_multi_object"
type = "multiobject"
value = jsonencode([
1,
2
])
}
}

Expand Down Expand Up @@ -525,7 +600,7 @@ resource "netbox_ipam_ip_addresses" "dynamic_ip_from_ip_range" {
}

data "netbox_virtualization_cluster" "cluster_test" {
name = "test"
name = "Test Cluster"
}

data "netbox_dcim_platform" "platform_test" {
Expand Down
2 changes: 2 additions & 0 deletions examples/resources/netbox_dcim_device_role/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Device roles can be imported by id
terraform import netbox_dcim_device_role.device_role_test 1
2 changes: 2 additions & 0 deletions examples/resources/netbox_dcim_manufacturer/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Manufacturers can be imported by id
terraform import netbox_dcim_manufacturer.manufacturer_test 1
2 changes: 2 additions & 0 deletions examples/resources/netbox_dcim_platform/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Platforms can be imported by id
terraform import netbox_dcim_platform.platform_test 1
2 changes: 2 additions & 0 deletions examples/resources/netbox_dcim_site/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Sites can be imported by id
terraform import netbox_dcim_site.site_test 1
2 changes: 2 additions & 0 deletions examples/resources/netbox_extras_custom_field/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Custom fields can be imported by id
terraform import netbox_extras_custom_field.cf_text 1
2 changes: 2 additions & 0 deletions examples/resources/netbox_extras_tag/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Tags can be imported by id
terraform import netbox_extras_tag.tag_test 1
2 changes: 2 additions & 0 deletions examples/resources/netbox_ipam_aggregate/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Aggregates can be imported by id
terraform import netbox_ipam_aggregate.aggregate_test 1
2 changes: 2 additions & 0 deletions examples/resources/netbox_ipam_asn/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# ASNs can be imported by id
terraform import netbox_ipam_asn.asn_test 1
2 changes: 1 addition & 1 deletion examples/resources/netbox_ipam_asn/resource.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resource "netbox_ipam_aggregate" "aggregate_test" {
resource "netbox_ipam_asn" "asn_test" {
asn = "65530"
rir_id = netbox_ipam_rir.rir_test.id

Expand Down
2 changes: 2 additions & 0 deletions examples/resources/netbox_ipam_ip_addresses/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# IP addresses can be imported by id
terraform import netbox_ipam_ip_addresses.ip_test 1
2 changes: 2 additions & 0 deletions examples/resources/netbox_ipam_ip_range/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# IP ranges can be imported by id
terraform import netbox_ipam_ip_range.range_test 1
2 changes: 2 additions & 0 deletions examples/resources/netbox_ipam_prefix/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Prefixes can be imported by id
terraform import netbox_ipam_prefix.prefix_test 1
2 changes: 2 additions & 0 deletions examples/resources/netbox_ipam_rir/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# RIRs can be imported by id
terraform import netbox_ipam_rir.rir_test 1
2 changes: 2 additions & 0 deletions examples/resources/netbox_ipam_service/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Services can be imported by id
terraform import netbox_ipam_service.service_test 1
2 changes: 2 additions & 0 deletions examples/resources/netbox_ipam_vlan/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# VLANs can be imported by id
terraform import netbox_ipam_vlan.vlan_test 1
2 changes: 2 additions & 0 deletions examples/resources/netbox_ipam_vlan_group/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# VLAN groups can be imported by id
terraform import netbox_ipam_vlan_group.vlan_group_test 1
80 changes: 80 additions & 0 deletions examples/resources/netbox_ipam_vlan_group/resource.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,89 @@
resource "netbox_ipam_vlan_group" "vlan_group_test" {
name = "TestVlanGroup"
slug = "TestVlanGroup"
description = "Vlan group created by terraform"
max_vid = 4094
min_vid = 1

scope {
id = 1
type = "dcim.site"
}

tag {
name = "tag1"
slug = "tag1"
}

custom_field {
name = "cf_boolean"
type = "boolean"
value = "true"
}

custom_field {
name = "cf_date"
type = "date"
value = "2020-12-25"
}

custom_field {
name = "cf_text"
type = "text"
value = "some text"
}

custom_field {
name = "cf_integer"
type = "integer"
value = "10"
}

custom_field {
name = "cf_selection"
type = "select"
value = "1"
}

custom_field {
name = "cf_url"
type = "url"
value = "https://github.com"
}

custom_field {
name = "cf_multi_selection"
type = "multiselect"
value = jsonencode([
"0",
"1"
])
}

custom_field {
name = "cf_json"
type = "json"
value = jsonencode({
stringvalue = "string"
boolvalue = false
dictionary = {
numbervalue = 5
}
})
}

custom_field {
name = "cf_object"
type = "object"
value = 1
}

custom_field {
name = "cf_multi_object"
type = "multiobject"
value = jsonencode([
1,
2
])
}
}
2 changes: 2 additions & 0 deletions examples/resources/netbox_tenancy_contact/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Contacts can be imported by id
terraform import netbox_tenancy_contact.contact_test 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Contact assignments can be imported by id
terraform import netbox_tenancy_contact_assignment.contact_assignment_01 1
2 changes: 2 additions & 0 deletions examples/resources/netbox_tenancy_contact_group/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Contact groups roles can be imported by id
terraform import netbox_tenancy_contact_group.contact_group_test 1
2 changes: 2 additions & 0 deletions examples/resources/netbox_tenancy_contact_role/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Contact roles can be imported by id
terraform import netbox_tenancy_contact_role.contact_role_test 1
2 changes: 2 additions & 0 deletions examples/resources/netbox_tenancy_tenant/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Tenants can be imported by id
terraform import netbox_tenancy_tenant.tenant_test 1
2 changes: 2 additions & 0 deletions examples/resources/netbox_tenancy_tenant_group/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Tenant groups can be imported by id
terraform import netbox_tenancy_tenant_group.tenant_group_test 1
2 changes: 2 additions & 0 deletions examples/resources/netbox_virtualization_cluster/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Clusters can be imported by id
terraform import netbox_virtualization_cluster.cluster_test 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Cluster groups can be imported by id
terraform import netbox_virtualization_cluster_group.test 1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
resource "netbox_virtualization_cluster_type" "test" {
resource "netbox_virtualization_cluster_group" "test" {
name = "test-{{ .namesuffix }}"
slug = "test-{{ .namesuffix }}"
description = "Test device role"
description = "Test cluster group"

tag {
name = "tag1"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Cluster types can be imported by id
terraform import netbox_virtualization_cluster_type.test 1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
resource "netbox_virtualization_cluster_group" "test" {
resource "netbox_virtualization_cluster_type" "test" {
name = "test-{{ .namesuffix }}"
slug = "test-{{ .namesuffix }}"
description = "Test device role"
description = "Test cluster type"

tag {
name = "tag1"
Expand Down
2 changes: 2 additions & 0 deletions examples/resources/netbox_virtualization_interface/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Virtualization interfaces can be imported by id
terraform import netbox_virtualization_interface.interface_test 1
2 changes: 2 additions & 0 deletions examples/resources/netbox_virtualization_vm/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Virtual machines can be imported by id
terraform import netbox_virtualization_vm.vm_test 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Virtual machine primary IP assignments can be imported by virtual machine id
terraform import netbox_virtualization_vm_primary_ip.name 1
6 changes: 5 additions & 1 deletion netbox/dcim/resource_netbox_dcim_site.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,11 @@ func resourceNetboxDcimSiteUpdate(ctx context.Context, d *schema.ResourceData,
if d.HasChange("time_zone") {
timeZone := d.Get("time_zone").(string)
params.TimeZone = &timeZone
modifiedFields["time_zone"] = timeZone
if timeZone != "" {
modifiedFields["time_zone"] = timeZone
} else {
modifiedFields["time_zone"] = nil
}
}

resource := dcim.NewDcimSitesPartialUpdateParams().WithData(params)
Expand Down
3 changes: 1 addition & 2 deletions netbox/dcim/resource_netbox_dcim_site_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ func testAccCheckNetboxDcimSiteConfig(nameSuffix string, resourceFull, extraReso
latitude = 12.54632
longitude = 41.21632
tenant_id = netbox_tenancy_tenant.test.id
# Broken in netbox < 3.3.7
# time_zone = "Europe/Berlin"
time_zone = "Europe/Berlin"

comments = <<-EOT
Comments for Test device role
Expand Down
Loading