Some problem when using Dynamic Inventory Sources and python API

Hi,
I’m developing a script using ansible python API (http://docs.ansible.com/ansible/developing_api.html)
Here is my ansible version


ansible 2.2.0 (devel af150ea43a) last updated 2016/06/18 02:00:10 (GMT +800)
lib/ansible/modules/core: (detached HEAD f0f5272f90) last updated 2016/06/19 09:59:32 (GMT +800)
lib/ansible/modules/extras: (detached HEAD 6cb6829384) last updated 2016/06/19 09:59:53 (GMT +800)
config file =
configured module search path = Default w/o overrides

My inventory is dynamic, so I follow the guide here : http://docs.ansible.com/ansible/developing_inventory.html

I found my script must support the --list option and --host <hostname> option.
What stumbles me is that when I use --host <hostname>, the <hostname> must appear in the output of the --list option.
But I can’t get all the hosts that I have access in advance. I just render my options with <hostname> when I call the --host <hostname> option.

Actually, all I need is to render my connection options based on the <hostname> option and I can’t know the list of in advance.
How can I achieve this goal?

Thanks in advance :slight_smile: