Skip to content

Commit 5b8a973

Browse files
committed
fix: handle netbox migration to disk set in MB
1 parent a4e9def commit 5b8a973

File tree

7 files changed

+15
-18
lines changed

7 files changed

+15
-18
lines changed

.github/workflows/ci-testing.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,9 @@ jobs:
3333
fail-fast: false
3434
matrix:
3535
netbox-version:
36-
# - v4.0.0 has mandatory tenant group
37-
- v4.0.1
38-
- v4.0.2
39-
- v4.0.3
40-
# - v4.0.4 does not exist for some reason
41-
- v4.0.5
42-
- v4.0.6
43-
- v4.0.7
44-
- v4.0.8
45-
- v4.0.9
46-
- v4.0.10
36+
- v4.1.0
37+
- v4.1.1
38+
- v4.1.2
4739
steps:
4840
- uses: actions/checkout@v4
4941
- name: Set up Go

GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ TEST_FUNC?=TestAccNetboxEventRule_basic
33
GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)
44
DOCKER_COMPOSE=docker compose
55

6-
export NETBOX_VERSION=v4.0.10
6+
export NETBOX_VERSION=v4.1.2
77
export NETBOX_SERVER_URL=http://localhost:8001
88
export NETBOX_API_TOKEN=0123456789abcdef0123456789abcdef01234567
99
export NETBOX_TOKEN=$(NETBOX_API_TOKEN)

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ Since version [1.6.6](https://github.com/e-breuninger/terraform-provider-netbox/
1818

1919
| Netbox version | Provider version |
2020
| --------------- | ---------------- |
21-
| v4.0.0 - 4.0.10 | v3.9.0 and up |
21+
| v4.1.0 - 4.1.2 | v3.10.0 and up |
22+
| v4.0.0 - 4.0.10 | v3.9.0 - 3.9.1 |
2223
| v3.7.0 - 3.7.8 | v3.8.0 - 3.8.9 |
2324
| v3.6.0 - 3.6.9 | v3.7.0 - 3.7.7 |
2425
| v3.5.1 - 3.5.9 | v3.6.x |

netbox/data_source_netbox_virtual_machines.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func dataSourceNetboxVirtualMachineRead(d *schema.ResourceData, m interface{}) e
244244
mapping["custom_fields"] = v.CustomFields
245245
}
246246
if v.Disk != nil {
247-
mapping["disk_size_gb"] = *v.Disk
247+
mapping["disk_size_gb"] = *v.Disk / 1000
248248
}
249249
if v.LocalContextData != nil {
250250
if localContextData, err := json.Marshal(v.LocalContextData); err == nil {

netbox/provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ func providerConfigure(ctx context.Context, data *schema.ResourceData) (interfac
295295

296296
netboxVersion := res.GetPayload().(map[string]interface{})["netbox-version"].(string)
297297

298-
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"}
298+
supportedVersions := []string{"4.1.0", "4.1.1", "4.1.2"}
299299

300300
if !slices.Contains(supportedVersions, netboxVersion) {
301301
// 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

netbox/resource_netbox_virtual_machine.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func resourceNetboxVirtualMachineCreate(ctx context.Context, d *schema.ResourceD
153153

154154
diskSizeValue, ok := d.GetOk("disk_size_gb")
155155
if ok {
156-
diskSize := int64(diskSizeValue.(int))
156+
diskSize := int64(diskSizeValue.(int)) * 1000
157157
data.Disk = &diskSize
158158
}
159159

@@ -308,7 +308,10 @@ func resourceNetboxVirtualMachineRead(ctx context.Context, d *schema.ResourceDat
308308
d.Set("vcpus", nil)
309309
}
310310
d.Set("memory_mb", vm.Memory)
311-
d.Set("disk_size_gb", vm.Disk)
311+
if vm.Disk != nil {
312+
diskSizeGb := *vm.Disk / 1000
313+
d.Set("disk_size_gb", diskSizeGb)
314+
}
312315
if vm.Status != nil {
313316
d.Set("status", vm.Status.Value)
314317
} else {

templates/index.md.tmpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ Netbox often makes breaking API changes even in non-major releases. Check the ta
1616

1717
| Netbox version | Provider version |
1818
| --------------- | ---------------- |
19-
| v4.0.0 - 4.0.10 | v3.9.0 and up |
19+
| v4.1.0 - 4.1.2 | v3.10.0 and up |
20+
| v4.0.0 - 4.0.10 | v3.9.0 - 3.9.1 |
2021
| v3.7.0 - 3.7.8 | v3.8.0 - 3.8.9 |
2122
| v3.6.0 - 3.6.9 | v3.7.0 - 3.7.7 |
2223
| v3.5.1 - 3.5.9 | v3.6.x |

0 commit comments

Comments
 (0)