Skip to content

Commit

Permalink
feat: Add netbox_virtualization_cluster resource
Browse files Browse the repository at this point in the history
  • Loading branch information
amhn committed Nov 18, 2022
1 parent 6ac1a1e commit a292478
Show file tree
Hide file tree
Showing 6 changed files with 588 additions and 14 deletions.
89 changes: 89 additions & 0 deletions examples/resources/netbox_virtualization_cluster/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
resource "netbox_virtualization_cluster" "cluster_test" {
name = "Test cluster"
type_id = netbox_virtualization_cluster_type.test.id

comments = <<-EOT
Test cluster
EOT

group_id = netbox_virtualization_cluster_group.test.id
site_id = netbox_dcim_site.site_test.id
tenant_id = netbox_tenancy_tenant.tenant_test.id

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
])
}
}
16 changes: 16 additions & 0 deletions netbox/internal/util/nested.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ func GetNestedIPAddressAddress(nested *models.NestedIPAddress) *string {
return nested.Address
}

func GetNestedClusterGroupID(nested *models.NestedClusterGroup) *int64 {
if nested == nil {
return nil
}

return &nested.ID
}

func GetNestedManufacturerID(nested *models.NestedManufacturer) *int64 {
if nested == nil {
return nil
Expand All @@ -36,6 +44,14 @@ func GetNestedRegionID(nested *models.NestedRegion) *int64 {
return &nested.ID
}

func GetNestedSiteID(nested *models.NestedSite) *int64 {
if nested == nil {
return nil
}

return &nested.ID
}

func GetNestedSiteGroupID(nested *models.NestedSiteGroup) *int64 {
if nested == nil {
return nil
Expand Down
1 change: 1 addition & 0 deletions netbox/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ func Provider() *schema.Provider {
"netbox_tenancy_contact_role": tenancy.ResourceNetboxTenancyContactRole(),
"netbox_tenancy_tenant": tenancy.ResourceNetboxTenancyTenant(),
"netbox_tenancy_tenant_group": tenancy.ResourceNetboxTenancyTenantGroup(),
"netbox_virtualization_cluster": virtualization.ResourceNetboxVirtualizationCluster(),
"netbox_virtualization_cluster_group": virtualization.ResourceNetboxVirtualizationClusterGroup(),
"netbox_virtualization_cluster_type": virtualization.ResourceNetboxVirtualizationClusterType(),
"netbox_virtualization_interface": virtualization.ResourceNetboxVirtualizationInterface(),
Expand Down
Loading

0 comments on commit a292478

Please sign in to comment.