def get_inventory(self, keys=None):
inventory = defaultdict(list)<EOL>keys = keys or ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>vms = self.prefix.get_vms().values()<EOL>for vm in vms:<EOL><INDENT>entry = self._generate_entry(vm)<EOL>vm_spec = vm.spec<EOL>for key in keys:<EOL><INDENT>value = self.get_key(key, vm_spec)<EOL>if value is None:<EOL><INDENT>continue<EOL><DEDENT>if isinstance(value, list):<EOL><INDENT>for sub_value in value:<EOL><INDENT>inventory['<STR_LIT>'.format(key, sub_value)].append(entry)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>inventory['<STR_LIT>'.format(key, value)].append(entry)<EOL><DEDENT><DEDENT>for group in vm_spec.get('<STR_LIT>', []):<EOL><INDENT>inventory[group].append(entry)<EOL><DEDENT><DEDENT>return inventory<EOL>
Create an Ansible inventory based on python dicts and lists.
The returned value is a dict in which every key represents a group
and every value is a list of entries for that group.

Args:
    keys (list of str): Path to the keys that will be used to
        create groups.

Returns:
    dict: dict based Ansible inventory