Let's say I have the dictionary my_dict
:
my_dict = {"vms": {"vm": {"name": "test-vm", "desc": "test"}}}
Obviously, in code I can grab the VM data with:
my_dict['vms']['vm']
More to the point, I can create an object of vms with that value and then reference the data:
vms = my_dict['vms']
vm = vms['vm']
My question is, if I were to save the value vms['vm']
as a string in a configuration file, how can I then use said string to grab the value from the dictionary? Something like:
my_dict.grab("vms['vm']") # To grab my_dict['vms']['vm']
I'm hoping a solution that I can further use with, say, vms['vm']['name']
regardless of how nested it gets, akin to Ansible Facts in a YAML playbook:
my_dict.grab("vms['vm']['name']")