Add property to get module number in vertices#86
Add property to get module number in vertices#86PaulWinterstein merged 3 commits intoSWR-MoIP:mainfrom
Conversation
|
Hi @groupmsl, The current implementation parses the vertex ID string, which does not hold up for all vertex ID structures. For example:
A more robust approach would be to use
So the property could look something like this: @property
def module_id(self) -> Optional[str]:
"""Module identifier this vertex belongs to, or None for common vertices (e.g. SwitchingCore)."""
pid = self.gpid.pointId
if len(pid) >= 4 and pid[1] in ("dev", "virt"):
return pid[2]
return NoneA few notes on this approach:
Feel free to push an updated version — either based on this approach or an alternative that covers the edge cases above. Happy to merge once it's in! Cheers |
|
Hi @PaulWinterstein, Thank you for your time and detailed reply! I think your example does exactly what I need, but without the issues my original commit had. I've pushed this now, so hopefully this can be merged. I've also tested against the script I've written that requires this functionality (I'm duplicating virtual devices, while programmatically changing things like multicast addresses and labels). Cheers, Andrew |
|
Released in 0.8.0 pip install --upgrade --force-reinstall videoipath-automation-tool==0.8.0 |
I've added a property to get the module number of a vertex, simply by splitting the id - a very simple addition.
I need to be able to get the module number of a vertex as I have a need to duplicate a virtual device. While I could have the required code at my end, I wonder if it would be useful to be part of the Vertex class.