Python code posted down-here utilizes NeutronClient V2 API. It creates router RouterDVS for particular tenant, interface to private sub-net "demo1_network" (18.104.22.168/24) and gateway to external flat network "public" (22.214.171.124/24). As usual posting was inspired by question been posted at ask.openstack.org. Actually, API calls core design I was able to find at openstack/python-neutronclient at github.com
Code is intentionally updated and simplified to become understandable by people without strong python development background.
Complete text may be found here