In my last post I scripted automating a standup of a KVM lab w/ vJUNOS, vEOS and some ubuntu containers.
I don’t quite like the code and it’s difficult to maintain so many ‘if’ and ‘for’ statements to reparse an inventory files key/values. There is an easy solution to this and that is using an object.
Using objects shortcuts a lot of the re-parsing of the inventory file and just parses the file once to create an object for a given KVM or container type. The drawbacks of using objects in python is that I must use Pydantic which seems to add a few more seconds of delay and Object Oriented Programming (OOP) in Python may not be beginner friendly. From my viewpoint it’s best to write code based on who is going to maintain it. Such that I wouldn’t write Object-Oriented Python and hand it off to a beginner in Python and expect them to maintain it.
Continue reading “Automating vJunOS and vEOS using OOP in Python (Pydantic)”