Structured import of VMs/Devices e.g. with JSON #1235

Closed
opened 2025-12-29 16:30:27 +01:00 by adam · 1 comment
Owner

Originally created by @candlerb on GitHub (Sep 16, 2017).

Issue type

[X] Feature request
[ ] Bug report
[ ] Documentation

Environment

  • Python version: 3.5.2
  • NetBox version: v2.2-beta1

Description

Use case: I want to import VMs. I have an existing table of VMs with their IPv4 and IPv6 addresses.

Using CSV import, this would be a three-step affair:

  1. Import VMs with just their names + cluster
  2. Import interfaces (not yet supported, see #1492 and #822)
  3. Import IP addresses (not yet supported for VMs, see #1500)

Importing Devices requires steps 1 and 3, if the Device Type has been properly configured to create the interfaces.

So I am suggesting some sort of structured import which can create the related items at once, e.g.

{"name":"unifi","platform":"Ubuntu 16.04","interfaces":[
  {"name":"eth0","mac":"54:00:00:28:56:1c","addresses":[
    {"address":"192.0.2.30/24","primary":True},
    {"address":"2001:db8::30/64","primary":True}
  ]}
]}

(If this were done for Device, then any interfaces which had been pre-created from the Device Type would be updated rather than created)

This sort of import could be done via the API. However as far as I can tell, the API doesn't support transactions, so the importer application would have to explicitly track changes and roll them back on error.

Originally created by @candlerb on GitHub (Sep 16, 2017). ### Issue type [X] Feature request <!-- Requesting the implementation of a new feature --> [ ] Bug report <!-- Reporting unexpected or erroneous behavior --> [ ] Documentation <!-- Proposing a modification to the documentation --> ### Environment * Python version: 3.5.2 * NetBox version: v2.2-beta1 ### Description Use case: I want to import VMs. I have an existing table of VMs with their IPv4 and IPv6 addresses. Using CSV import, this would be a three-step affair: 1. Import VMs with just their names + cluster 2. Import interfaces (not yet supported, see #1492 and #822) 3. Import IP addresses (not yet supported for VMs, see #1500) Importing Devices requires steps 1 and 3, if the Device Type has been properly configured to create the interfaces. So I am suggesting some sort of structured import which can create the related items at once, e.g. ~~~ {"name":"unifi","platform":"Ubuntu 16.04","interfaces":[ {"name":"eth0","mac":"54:00:00:28:56:1c","addresses":[ {"address":"192.0.2.30/24","primary":True}, {"address":"2001:db8::30/64","primary":True} ]} ]} ~~~ (If this were done for Device, then any interfaces which had been pre-created from the Device Type would be updated rather than created) This sort of import could be done via the API. However as far as I can tell, the API doesn't support transactions, so the importer application would have to explicitly track changes and roll them back on error.
adam closed this issue 2025-12-29 16:30:27 +01:00
Author
Owner

@jeremystretch commented on GitHub (Sep 18, 2017):

The CSV-formatted bulk import functions work with only one type of object at a time and are provided for convenience. Any bulk operations requiring more complex logic will need to be performed via the REST API (or directly via the CLI shell). As with most APIs, you'll need to handle errors on the client side accordingly.

@jeremystretch commented on GitHub (Sep 18, 2017): The CSV-formatted bulk import functions work with only one type of object at a time and are provided for convenience. Any bulk operations requiring more complex logic will need to be performed via the REST API (or directly via the CLI shell). As with most APIs, you'll need to handle errors on the client side accordingly.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1235