Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtual Chassis Mastership addition automatically changes device vc_position, breaking backup/restore of DB #2087

Closed
alejandrosalinas opened this issue May 10, 2018 · 0 comments
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@alejandrosalinas
Copy link

alejandrosalinas commented May 10, 2018

Issue type

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

Environment

  • Python version: 3.6
  • NetBox version: 2.3.3

Description

Upon creating a Virtual Chassis the position of the master gets updated to 1, causing a conflict whenever this was not the device 1 of the chassis (Example: Juniper fpc0 device being the master). This auto-update breaks backup and restore of the database.

Steps to replicate (using pynetbox for simplicity). First I create two devices and the virtual chassis

In [126]: deviceA_dict = nb.dcim.devices.create(**deviceA_data)
In [127]: deviceA_dict['vc_position']
Out[127]: 0

In [128]: deviceB_dict = nb.dcim.devices.create(**deviceB_data)
In [129]: deviceB_dict['vc_position']
Out[129]: 1

In [131]: vc_dict = nb.dcim.virtual_chassis.create({'domain': 'someVCname', 'master': deviceA_dict['id']})

In [132]: deviceA_obj = nb.dcim.devices.get(name='deviceA')
In [133]: deviceA_obj.vc_position
Out[133]: 1   <=== device position got changed

After this, using the GUI I manually moved deviceA to have position 0 and added deviceB to the cluster as I intended originally

In [161]: deviceA_obj = nb.dcim.devices.get(name='deviceA')
In [162]: deviceA_obj.vc_position
Out[162]: 0
In [163]: deviceA_obj.virtual_chassis.id
Out[163]: 1

In [164]: deviceB_obj = nb.dcim.devices.get(name='deviceB')
In [165]: deviceB_obj.vc_position
Out[165]: 1
In [166]: deviceB_obj.virtual_chassis.id
Out[166]: 1

In [167]: vc_obj = nb.dcim.virtual_chassis.get(domain="someVCname")
In [168]: deviceB_obj.virtual_chassis.master
Out[168]: deviceA

And now backup and restore breaks because of the vc_id, position constraint

[user@netboxserver:netbox] python manage.py dumpdata >  ~/VCtest.json
[user@netboxserver:netbox] python manage.py flush --noinput
[user@netboxserver:netbox] python manage.py loaddata ~/VCtest.json
Traceback (most recent call last):
  File "/var/netbox_env/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
psycopg2.IntegrityError: duplicate key value violates unique constraint "dcim_device_virtual_chassis_id_vc_position_efea7133_uniq"
DETAIL:  Key (virtual_chassis_id, vc_position)=(1, 1) already exists.
@jeremystretch jeremystretch added type: bug A confirmed report of unexpected behavior in the application status: accepted This issue has been accepted for implementation labels Jun 7, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jan 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants