Comments (3)
Can you please post an example of a yaml that triggers this behavior?
from netbox-docker.
Sure, here it is:
https://gist.github.com/bdlamprecht/04ba20b53edc192fdccbbe09550609c7
Although, I've noticed that potentially this only happens when a device_type
that I've manually created (through the WebUI or through the API) is then added to the device_types.yml
and then the container is brought up again.
This may be an unsupported workflow (manually adding a type then recreating a container), but in reality, should it be?
from netbox-docker.
I was able to load your device_types.yml
two times with no problems.
If you already have data in Netbox that matches one of the initializers, that's a complex problem. Because there are no primary keys (i.e. ids) in the initializers, it's not possible to distinguish the entries precisely. That's why all given attributes must match exactly for an object not to be created again.
If there is just a very tiny difference, then Django will try to create a new object. But in your case there is already an object, that is similar, yet not identical, and therefore Django will try to create a new object. But it fails to do so, as some unique constraint is violated, i.e. because the value for 'model' in combination with the given manufacturer already exists.
I've tried to come up with a solution that circumvents this problem. But there is not one-size-fits-all solution and that solution is therefore bound to fail for other use-cases. That's why I will leave the scripts as they are.
If you want to create an initializer that supports your case, you may want to adjust (clones of) the existing initializers.
The Django method, that you need to handle for your case, is objects.create_or_update()
. The solution would be to pass just the parameters, that you want to use for identification, as the main arguments, and all the other parameters as default=
:
device_type, created = DeviceType.objects.get_or_create(params.pop('model'), params.pop('slug'), default=params)
from netbox-docker.
Related Issues (20)
- root password of docker container
- Cannot delete a user account with Bookmarks HOT 2
- Add SSO variables to configuration file, so they can be added to the environment files
- Crash with SOCIAL_AUTH_SAML - signal 11 HOT 3
- using environment block in example file fails HOT 2
- Postgres-Error on first boot HOT 1
- superuser_password secret fails with permission denied
- dependency failed to start: container netbox-docker-netbox-1 exited (127) HOT 1
- Server Error 'NoneType' object has no attribute 'get_absolute_url'
- Social Auth not following proxy settings in config file
- docker compose up fails on "unexpected EOF on client connection" during "./manage.py migrate --no-input"
- Restart Policy in the YAML? HOT 1
- Copying of Admin->Authentication->Permissions HOT 1
- Support for JSON and YAML configuration files HOT 5
- psycopg connection issue HOT 2
- Netbox Restarts in Nomad
- docker compose up fails on "unexpected EOF on client connection" during "./manage.py migrate --no-input" HOT 1
- Upgrading from Release to Release Via Docker
- Add Environment Variable to Mange ALLOW_TOKEN_RETRIEVAL HOT 1
- Nginx Unit user UID has changed to 999, breaks git data source sync HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from netbox-docker.