-
Notifications
You must be signed in to change notification settings - Fork 81
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
feat: Add a way to assign a device to a position in a rack #375
base: master
Are you sure you want to change the base?
Conversation
Before it was only possible to assign a device to a data center and a location within that data center. Now it is also possible to assign it to a position within a location in a data center. There's no error handling, Lets assume that rack exists and the position is free.
Hello @kuchosauronad0 and thank you for you contribution ❤️ I saw a couple of undefined vars and missing bits so I assume you're still working on this. I didn't want to annoy you with comments if it's still WIP, so I only made comments about style and structure for now 😁 Feel free to mark your PR as draft until you're finished. And don't hesitate to ask anything you might need to know ! |
driver_value = ( | ||
":".join(config.position_location.driver.split(":")[1:]) | ||
if config.position_location.driver | ||
else None | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just nitpicking on style but you could use maxsplit
driver_value = ( | |
":".join(config.position_location.driver.split(":")[1:]) | |
if config.position_location.driver | |
else None | |
) | |
driver_value = ( | |
config.position_location.driver.split(":", maxsplit=1)[1] | |
if config.position_location.driver | |
else None | |
) |
logging.error("Can't get position if no datacenter is configured or found") | ||
sys.exit(1) | ||
|
||
return position |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is supposed to return the position currently set in Netbox, rather than the actual, expected one, to be used in the diff checks around lines 480-530.
Before it was only possible to assign a device to a data center and a location within that data center. Now it is also possible to assign it
to a position within a location in a data center. There's no error handling,
Lets assume that rack exists and the position is free.