Skip to content

Commit

Permalink
fix: Import does not work for virtualization_vm_primary_ip
Browse files Browse the repository at this point in the history
fixes: #188
  • Loading branch information
amhn authored and smutel committed Mar 14, 2023
1 parent 6cd4162 commit c17026d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
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
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ func resourceNetboxVirtualizationVMPrimaryIPExists(d *schema.ResourceData,

resourceID := int64(d.Get("virtualmachine_id").(int))
resourceIDString := strconv.FormatInt(resourceID, 10)
if resourceIDString == "0" {
resourceIDString = d.Id()
}
params := virtualization.NewVirtualizationVirtualMachinesListParams().WithID(
&resourceIDString)
resources, err := client.Virtualization.VirtualizationVirtualMachinesList(
Expand All @@ -258,7 +261,7 @@ func resourceNetboxVirtualizationVMPrimaryIPExists(d *schema.ResourceData,
}

for _, resource := range resources.Payload.Results {
if resource.ID == resourceID {
if strconv.FormatInt(resource.ID, 10) == resourceIDString {
resourceExist = true
}
}
Expand Down

0 comments on commit c17026d

Please sign in to comment.