diff --git a/.github/workflows/ci-testing.yml b/.github/workflows/ci-testing.yml index c513ab5f..3021bbff 100644 --- a/.github/workflows/ci-testing.yml +++ b/.github/workflows/ci-testing.yml @@ -33,18 +33,10 @@ jobs: fail-fast: false matrix: netbox-version: - # - v4.0.0 has mandatory tenant group - - v4.0.1 - - v4.0.2 - - v4.0.3 - # - v4.0.4 does not exist for some reason - - v4.0.5 - - v4.0.6 - - v4.0.7 - - v4.0.8 - - v4.0.9 - - v4.0.10 - - v4.0.11 + - v4.1.0 + - v4.1.1 + - v4.1.2 + - v4.1.3 steps: - uses: actions/checkout@v4 - name: Set up Go diff --git a/GNUmakefile b/GNUmakefile index 90c26bf3..eba70cd0 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -3,7 +3,7 @@ TEST_FUNC?=TestAccNetboxEventRule_basic GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor) DOCKER_COMPOSE=docker compose -export NETBOX_VERSION=v4.0.11 +export NETBOX_VERSION=v4.1.3 export NETBOX_SERVER_URL=http://localhost:8001 export NETBOX_API_TOKEN=0123456789abcdef0123456789abcdef01234567 export NETBOX_TOKEN=$(NETBOX_API_TOKEN) diff --git a/README.md b/README.md index 3c15a466..5322b7d1 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,8 @@ Since version [1.6.6](https://github.com/e-breuninger/terraform-provider-netbox/ | Netbox version | Provider version | | --------------- | ---------------- | -| v4.0.0 - 4.0.11 | v3.9.0 and up | +| v4.1.0 - 4.1.3 | v3.10.0 and up | +| v4.0.0 - 4.0.11 | v3.9.0 - 3.9.2 | | v3.7.0 - 3.7.8 | v3.8.0 - 3.8.9 | | v3.6.0 - 3.6.9 | v3.7.0 - 3.7.7 | | v3.5.1 - 3.5.9 | v3.6.x | diff --git a/docs/data-sources/vlan_group.md b/docs/data-sources/vlan_group.md index c8687009..93292cb8 100644 --- a/docs/data-sources/vlan_group.md +++ b/docs/data-sources/vlan_group.md @@ -45,8 +45,6 @@ data "netbox_vlan_group" "example3" { - `description` (String) - `id` (String) The ID of this resource. -- `max_vid` (Number) -- `min_vid` (Number) - `vlan_count` (Number) diff --git a/docs/index.md b/docs/index.md index 4cfabccf..d6901979 100644 --- a/docs/index.md +++ b/docs/index.md @@ -16,7 +16,8 @@ Netbox often makes breaking API changes even in non-major releases. Check the ta | Netbox version | Provider version | | --------------- | ---------------- | -| v4.0.0 - 4.0.11 | v3.9.0 and up | +| v4.1.0 - 4.1.3 | v3.10.0 and up | +| v4.0.0 - 4.0.11 | v3.9.0 - 3.9.2 | | v3.7.0 - 3.7.8 | v3.8.0 - 3.8.9 | | v3.6.0 - 3.6.9 | v3.7.0 - 3.7.7 | | v3.5.1 - 3.5.9 | v3.6.x | diff --git a/docs/resources/rack.md b/docs/resources/rack.md index 0e993ecd..57ae9142 100644 --- a/docs/resources/rack.md +++ b/docs/resources/rack.md @@ -65,7 +65,6 @@ resource "netbox_rack" "test" { - `serial` (String) - `tags` (Set of String) - `tenant_id` (Number) -- `type` (String) Valid values are `2-post-frame`, `4-post-frame`, `4-post-cabinet`, `wall-frame`, `wall-frame-vertical`, `wall-cabinet` and `wall-cabinet-vertical`. - `weight` (Number) - `weight_unit` (String) Valid values are `kg`, `g`, `lb` and `oz`. Required when `weight` and `max_weight` is set. diff --git a/docs/resources/vlan_group.md b/docs/resources/vlan_group.md index 8789c7dc..2006abe9 100644 --- a/docs/resources/vlan_group.md +++ b/docs/resources/vlan_group.md @@ -17,16 +17,12 @@ description: |- resource "netbox_vlan_group" "example1" { name = "example1" slug = "example1" - min_vid = 1 - max_vid = 4094 } #Full VLAN Group example resource "netbox_vlan_group" "example2" { name = "Second Example" slug = "example2" - min_vid = 1 - max_vid = 4094 scope_type = "dcim.site" scope_id = netbox_site.example.id description = "Second Example VLAN Group" @@ -39,8 +35,6 @@ resource "netbox_vlan_group" "example2" { ### Required -- `max_vid` (Number) -- `min_vid` (Number) - `name` (String) - `slug` (String) diff --git a/examples/resources/netbox_vlan_group/resource.tf b/examples/resources/netbox_vlan_group/resource.tf index 48d4975c..61733c50 100644 --- a/examples/resources/netbox_vlan_group/resource.tf +++ b/examples/resources/netbox_vlan_group/resource.tf @@ -2,16 +2,12 @@ resource "netbox_vlan_group" "example1" { name = "example1" slug = "example1" - min_vid = 1 - max_vid = 4094 } #Full VLAN Group example resource "netbox_vlan_group" "example2" { name = "Second Example" slug = "example2" - min_vid = 1 - max_vid = 4094 scope_type = "dcim.site" scope_id = netbox_site.example.id description = "Second Example VLAN Group" diff --git a/netbox/data_source_netbox_virtual_machines.go b/netbox/data_source_netbox_virtual_machines.go index 7b84e84b..2180164d 100644 --- a/netbox/data_source_netbox_virtual_machines.go +++ b/netbox/data_source_netbox_virtual_machines.go @@ -244,7 +244,7 @@ func dataSourceNetboxVirtualMachineRead(d *schema.ResourceData, m interface{}) e mapping["custom_fields"] = v.CustomFields } if v.Disk != nil { - mapping["disk_size_gb"] = *v.Disk + mapping["disk_size_gb"] = *v.Disk / 1000 } if v.LocalContextData != nil { if localContextData, err := json.Marshal(v.LocalContextData); err == nil { diff --git a/netbox/data_source_netbox_vlan_group.go b/netbox/data_source_netbox_vlan_group.go index 2d63133b..56c0b1ad 100644 --- a/netbox/data_source_netbox_vlan_group.go +++ b/netbox/data_source_netbox_vlan_group.go @@ -38,14 +38,6 @@ func dataSourceNetboxVlanGroup() *schema.Resource { Optional: true, RequiredWith: []string{"scope_type"}, }, - "min_vid": { - Type: schema.TypeInt, - Computed: true, - }, - "max_vid": { - Type: schema.TypeInt, - Computed: true, - }, "vlan_count": { Type: schema.TypeInt, Computed: true, @@ -92,8 +84,6 @@ func dataSourceNetboxVlanGroupRead(d *schema.ResourceData, m interface{}) error d.SetId(strconv.FormatInt(result.ID, 10)) d.Set("name", result.Name) d.Set("slug", result.Slug) - d.Set("min_vid", result.MinVid) - d.Set("max_vid", result.MaxVid) d.Set("vlan_count", result.VlanCount) d.Set("description", result.Description) return nil diff --git a/netbox/data_source_netbox_vlan_group_test.go b/netbox/data_source_netbox_vlan_group_test.go index 3bb9917a..3b723276 100644 --- a/netbox/data_source_netbox_vlan_group_test.go +++ b/netbox/data_source_netbox_vlan_group_test.go @@ -43,8 +43,6 @@ func TestAccNetboxVlanGroupDataSource_basic(t *testing.T) { resource.TestCheckResourceAttr("data.netbox_vlan_group.test", "name", testName), resource.TestCheckResourceAttr("data.netbox_vlan_group.test", "slug", testSlug), resource.TestCheckResourceAttr("data.netbox_vlan_group.test", "description", "Test"), - resource.TestCheckResourceAttr("data.netbox_vlan_group.test", "min_vid", "20"), - resource.TestCheckResourceAttr("data.netbox_vlan_group.test", "max_vid", "200"), resource.TestCheckResourceAttr("data.netbox_vlan_group.test", "scope_type", "dcim.site"), resource.TestCheckResourceAttrPair("data.netbox_vlan_group.test", "scope_id", "netbox_site.test", "id"), ), @@ -56,8 +54,6 @@ func TestAccNetboxVlanGroupDataSource_basic(t *testing.T) { resource.TestCheckResourceAttr("data.netbox_vlan_group.test", "name", testName), resource.TestCheckResourceAttr("data.netbox_vlan_group.test", "slug", testSlug), resource.TestCheckResourceAttr("data.netbox_vlan_group.test", "description", "Test"), - resource.TestCheckResourceAttr("data.netbox_vlan_group.test", "min_vid", "20"), - resource.TestCheckResourceAttr("data.netbox_vlan_group.test", "max_vid", "200"), resource.TestCheckResourceAttr("data.netbox_vlan_group.test", "scope_type", "dcim.site"), resource.TestCheckResourceAttrPair("data.netbox_vlan_group.test", "scope_id", "netbox_site.test", "id"), ), @@ -84,8 +80,6 @@ resource "netbox_vlan_group" "test" { slug = "%[1]s" name = "%[2]s" description = "Test" - min_vid = 20 - max_vid = 200 scope_type = "dcim.site" scope_id = netbox_site.test.id tags = [] @@ -98,15 +92,11 @@ func testAccNetboxVlanGroupSetUpMore(testSlug, anotherSlug, testName string) str resource "netbox_vlan_group" "same_name" { slug = "%[1]s" name = "%[3]s" - min_vid = 20 - max_vid = 200 } resource "netbox_vlan_group" "not_same" { slug = "%[2]s" name = "%[3]s_unique" - min_vid = 20 - max_vid = 200 } `, testSlug, anotherSlug, testName) } diff --git a/netbox/provider.go b/netbox/provider.go index 13f14572..d6df6759 100644 --- a/netbox/provider.go +++ b/netbox/provider.go @@ -295,7 +295,7 @@ func providerConfigure(ctx context.Context, data *schema.ResourceData) (interfac netboxVersion := res.GetPayload().(map[string]interface{})["netbox-version"].(string) - supportedVersions := []string{"4.0.0", "4.0.1", "4.0.2", "4.0.3", "4.0.5", "4.0.6", "4.0.7", "4.0.8", "4.0.9", "4.0.10", "4.0.11"} + supportedVersions := []string{"4.1.0", "4.1.1", "4.1.2", "4.1.3"} if !slices.Contains(supportedVersions, netboxVersion) { // Currently, there is no way to test these warnings. There is an issue to track this: https://github.com/hashicorp/terraform-plugin-sdk/issues/864 diff --git a/netbox/resource_netbox_rack.go b/netbox/resource_netbox_rack.go index d41d0c52..9d6ac6e1 100644 --- a/netbox/resource_netbox_rack.go +++ b/netbox/resource_netbox_rack.go @@ -11,7 +11,6 @@ import ( ) var resourceNetboxRackStatusOptions = []string{"reserved", "available", "planned", "active", "deprecated"} -var resourceNetboxRackTypeOptions = []string{"2-post-frame", "4-post-frame", "4-post-cabinet", "wall-frame", "wall-frame-vertical", "wall-cabinet", "wall-cabinet-vertical"} var resourceNetboxRackWeightUnitOptions = []string{"kg", "g", "lb", "oz"} var resourceNetboxRackOuterUnitOptions = []string{"mm", "in"} var resourceNetboxRackWidthOptions = []int{10, 19, 21, 23} @@ -84,12 +83,6 @@ Each rack is assigned a name and (optionally) a separate facility ID. This is he Optional: true, ValidateFunc: validation.StringLenBetween(0, 50), }, - "type": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice(resourceNetboxRackTypeOptions, false), - Description: buildValidValueDescription(resourceNetboxRackTypeOptions), - }, "weight": { Type: schema.TypeFloat, Optional: true, @@ -178,7 +171,6 @@ func resourceNetboxRackCreate(d *schema.ResourceData, m interface{}) error { if assetTag := getOptionalStr(d, "asset_tag", false); assetTag != "" { data.AssetTag = &assetTag } - data.Type = getOptionalStr(d, "type", false) data.Weight = getOptionalFloat(d, "weight") data.MaxWeight = getOptionalInt(d, "max_weight") data.WeightUnit = getOptionalStr(d, "weight_unit", false) @@ -279,12 +271,6 @@ func resourceNetboxRackRead(d *schema.ResourceData, m interface{}) error { d.Set("serial", rack.Serial) d.Set("asset_tag", rack.AssetTag) - if rack.Type != nil { - d.Set("type", rack.Type.Value) - } else { - d.Set("type", nil) - } - d.Set("weight", rack.Weight) d.Set("max_weight", rack.MaxWeight) @@ -348,7 +334,6 @@ func resourceNetboxRackUpdate(d *schema.ResourceData, m interface{}) error { if assetTag := getOptionalStr(d, "asset_tag", false); assetTag != "" { data.AssetTag = &assetTag } - data.Type = getOptionalStr(d, "type", false) data.Weight = getOptionalFloat(d, "weight") data.MaxWeight = getOptionalInt(d, "max_weight") data.WeightUnit = getOptionalStr(d, "weight_unit", false) diff --git a/netbox/resource_netbox_rack_test.go b/netbox/resource_netbox_rack_test.go index 5577d405..017170f6 100644 --- a/netbox/resource_netbox_rack_test.go +++ b/netbox/resource_netbox_rack_test.go @@ -62,7 +62,6 @@ resource "netbox_rack" "test" { role_id = netbox_rack_role.test.id serial = "%[1]sserial" asset_tag = "%[1]sasset_tag" - type = "4-post-frame" desc_units = true outer_width = 10 outer_depth = 15 @@ -92,7 +91,6 @@ resource "netbox_rack" "test2" { resource.TestCheckResourceAttrPair("netbox_rack.test", "role_id", "netbox_rack_role.test", "id"), resource.TestCheckResourceAttr("netbox_rack.test", "serial", testName+"serial"), resource.TestCheckResourceAttr("netbox_rack.test", "asset_tag", testName+"asset_tag"), - resource.TestCheckResourceAttr("netbox_rack.test", "type", "4-post-frame"), resource.TestCheckResourceAttr("netbox_rack.test", "desc_units", "true"), resource.TestCheckResourceAttr("netbox_rack.test", "outer_width", "10"), resource.TestCheckResourceAttr("netbox_rack.test", "outer_depth", "15"), @@ -129,7 +127,6 @@ resource "netbox_rack" "test" { resource.TestCheckResourceAttr("netbox_rack.test", "role_id", "0"), resource.TestCheckResourceAttr("netbox_rack.test", "serial", ""), resource.TestCheckResourceAttr("netbox_rack.test", "asset_tag", ""), - resource.TestCheckResourceAttr("netbox_rack.test", "type", ""), resource.TestCheckResourceAttr("netbox_rack.test", "weight", "0"), resource.TestCheckResourceAttr("netbox_rack.test", "max_weight", "0"), resource.TestCheckResourceAttr("netbox_rack.test", "weight_unit", ""), diff --git a/netbox/resource_netbox_user_test.go b/netbox/resource_netbox_user_test.go index 34efe95a..5516c4d8 100644 --- a/netbox/resource_netbox_user_test.go +++ b/netbox/resource_netbox_user_test.go @@ -22,7 +22,7 @@ func TestAccNetboxUser_basic(t *testing.T) { Config: fmt.Sprintf(` resource "netbox_user" "test_basic" { username = "%s" - password = "abcdefghijkl" + password = "abcdefghijkl1" active = true staff = true }`, testName), @@ -56,7 +56,7 @@ resource "netbox_group" "test_group" { resource "netbox_user" "test_group" { username = "%[1]s" - password = "abcdefghijkl" + password = "abcdefghijkl1" active = true staff = true group_ids = [netbox_group.test_group.id] diff --git a/netbox/resource_netbox_virtual_machine.go b/netbox/resource_netbox_virtual_machine.go index 2d1ae4c7..9b65764c 100644 --- a/netbox/resource_netbox_virtual_machine.go +++ b/netbox/resource_netbox_virtual_machine.go @@ -153,8 +153,8 @@ func resourceNetboxVirtualMachineCreate(ctx context.Context, d *schema.ResourceD diskSizeValue, ok := d.GetOk("disk_size_gb") if ok { - diskSize := int64(diskSizeValue.(int)) - data.Disk = &diskSize + diskSizeMb := int64(diskSizeValue.(int)) * 1000 + data.Disk = &diskSizeMb } tenantIDValue, ok := d.GetOk("tenant_id") @@ -308,7 +308,10 @@ func resourceNetboxVirtualMachineRead(ctx context.Context, d *schema.ResourceDat d.Set("vcpus", nil) } d.Set("memory_mb", vm.Memory) - d.Set("disk_size_gb", vm.Disk) + if vm.Disk != nil { + diskSizeGb := *vm.Disk / 1000 + d.Set("disk_size_gb", diskSizeGb) + } if vm.Status != nil { d.Set("status", vm.Status.Value) } else { @@ -383,8 +386,8 @@ func resourceNetboxVirtualMachineUpdate(ctx context.Context, d *schema.ResourceD diskSizeValue, ok := d.GetOk("disk_size_gb") if ok { - diskSize := int64(diskSizeValue.(int)) - data.Disk = &diskSize + diskSizeMb := int64(diskSizeValue.(int)) * 1000 + data.Disk = &diskSizeMb } primaryIP4Value, ok := d.GetOk("primary_ipv4") diff --git a/netbox/resource_netbox_vlan_group.go b/netbox/resource_netbox_vlan_group.go index ddfa8488..1feef457 100644 --- a/netbox/resource_netbox_vlan_group.go +++ b/netbox/resource_netbox_vlan_group.go @@ -33,16 +33,6 @@ func resourceNetboxVlanGroup() *schema.Resource { Required: true, ValidateFunc: validation.StringLenBetween(1, 100), }, - "min_vid": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntBetween(1, 4093), - }, - "max_vid": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntBetween(2, 4094), - }, "scope_type": { Type: schema.TypeString, Optional: true, @@ -73,14 +63,10 @@ func resourceNetboxVlanGroupCreate(d *schema.ResourceData, m interface{}) error name := d.Get("name").(string) slug := d.Get("slug").(string) - minVid := int64(d.Get("min_vid").(int)) - maxVid := int64(d.Get("max_vid").(int)) description := d.Get("description").(string) data.Name = &name data.Slug = &slug - data.MinVid = minVid - data.MaxVid = maxVid data.Description = description if scopeType, ok := d.GetOk("scope_type"); ok { @@ -125,8 +111,6 @@ func resourceNetboxVlanGroupRead(d *schema.ResourceData, m interface{}) error { d.Set("name", vlanGroup.Name) d.Set("slug", vlanGroup.Slug) - d.Set("min_vid", vlanGroup.MinVid) - d.Set("max_vid", vlanGroup.MaxVid) d.Set("description", vlanGroup.Description) d.Set(tagsKey, getTagListFromNestedTagList(vlanGroup.Tags)) @@ -148,14 +132,10 @@ func resourceNetboxVlanGroupUpdate(d *schema.ResourceData, m interface{}) error name := d.Get("name").(string) slug := d.Get("slug").(string) - minVid := int64(d.Get("min_vid").(int)) - maxVid := int64(d.Get("max_vid").(int)) description := d.Get("description").(string) data.Name = &name data.Slug = &slug - data.MinVid = minVid - data.MaxVid = maxVid data.Description = description if scopeType, ok := d.GetOk("scope_type"); ok { diff --git a/netbox/resource_netbox_vlan_group_test.go b/netbox/resource_netbox_vlan_group_test.go index d9de516a..745cacb2 100644 --- a/netbox/resource_netbox_vlan_group_test.go +++ b/netbox/resource_netbox_vlan_group_test.go @@ -26,8 +26,6 @@ resource "netbox_site" "test" { func TestAccNetboxVlanGroup_basic(t *testing.T) { testSlug := "vlan_group_basic" testName := testAccGetTestName(testSlug) - testMinVid := "777" - testMaxVid := "1777" resource.ParallelTest(t, resource.TestCase{ Providers: testAccProviders, PreCheck: func() { testAccPreCheck(t) }, @@ -37,15 +35,11 @@ func TestAccNetboxVlanGroup_basic(t *testing.T) { resource "netbox_vlan_group" "test_basic" { name = "%s" slug = "%s" - min_vid = "%s" - max_vid = "%s" tags = [] -}`, testName, testSlug, testMinVid, testMaxVid), +}`, testName, testSlug), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("netbox_vlan_group.test_basic", "name", testName), resource.TestCheckResourceAttr("netbox_vlan_group.test_basic", "slug", testSlug), - resource.TestCheckResourceAttr("netbox_vlan_group.test_basic", "min_vid", testMinVid), - resource.TestCheckResourceAttr("netbox_vlan_group.test_basic", "max_vid", testMaxVid), resource.TestCheckResourceAttr("netbox_vlan_group.test_basic", "description", ""), resource.TestCheckResourceAttr("netbox_vlan_group.test_basic", "tags.#", "0"), ), @@ -62,8 +56,6 @@ resource "netbox_vlan_group" "test_basic" { func TestAccNetboxVlanGroup_with_dependencies(t *testing.T) { testSlug := "vlan_group_with_dependencies" testName := testAccGetTestName(testSlug) - testMinVid := "777" - testMaxVid := "1777" testDescription := "Test Description" resource.ParallelTest(t, resource.TestCase{ Providers: testAccProviders, @@ -75,17 +67,13 @@ resource "netbox_vlan_group" "test_with_dependencies" { name = "%s" slug = "%s" description = "%s" - min_vid = "%s" - max_vid = "%s" scope_type = "dcim.site" scope_id = netbox_site.test.id tags = [netbox_tag.test.name] -}`, testName, testSlug, testDescription, testMinVid, testMaxVid), +}`, testName, testSlug, testDescription), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("netbox_vlan_group.test_with_dependencies", "name", testName), resource.TestCheckResourceAttr("netbox_vlan_group.test_with_dependencies", "slug", testSlug), - resource.TestCheckResourceAttr("netbox_vlan_group.test_with_dependencies", "min_vid", testMinVid), - resource.TestCheckResourceAttr("netbox_vlan_group.test_with_dependencies", "max_vid", testMaxVid), resource.TestCheckResourceAttr("netbox_vlan_group.test_with_dependencies", "description", testDescription), resource.TestCheckResourceAttr("netbox_vlan_group.test_with_dependencies", "scope_type", "dcim.site"), resource.TestCheckResourceAttrPair("netbox_vlan_group.test_with_dependencies", "scope_id", "netbox_site.test", "id"), diff --git a/netbox/resource_netbox_vlan_test.go b/netbox/resource_netbox_vlan_test.go index 6f7fb326..dfc33f87 100644 --- a/netbox/resource_netbox_vlan_test.go +++ b/netbox/resource_netbox_vlan_test.go @@ -29,8 +29,6 @@ resource "netbox_site" "test" { resource "netbox_vlan_group" "test_group" { name = "%[1]s" slug = "%[1]s" - min_vid = 1 - max_vid = 4094 scope_type = "dcim.site" scope_id = netbox_site.test.id } diff --git a/templates/index.md.tmpl b/templates/index.md.tmpl index 10dcb143..e6a914a2 100644 --- a/templates/index.md.tmpl +++ b/templates/index.md.tmpl @@ -16,7 +16,8 @@ Netbox often makes breaking API changes even in non-major releases. Check the ta | Netbox version | Provider version | | --------------- | ---------------- | -| v4.0.0 - 4.0.11 | v3.9.0 and up | +| v4.1.0 - 4.1.3 | v3.10.0 and up | +| v4.0.0 - 4.0.11 | v3.9.0 - 3.9.2 | | v3.7.0 - 3.7.8 | v3.8.0 - 3.8.9 | | v3.6.0 - 3.6.9 | v3.7.0 - 3.7.7 | | v3.5.1 - 3.5.9 | v3.6.x |