Ask Your Question

OpenStack Python Programming - Network

asked 2018-11-18 00:28:32 -0500

JeffBannister gravatar image

I'm trying to build Python programs to connect to OpenStack. I've just created two interfaces on a router with the neutron.create_port command but I need one of them to point to my 'public' network and I can't see how to do this, i.e. set a gateway. I know how to do it from the CLI but not from neutronclient. I'm creating the port as follows (note this does work):

pub_port = {'admin_state_up':True, 'device_id':router_id, 'network_id':pubnet_id}

So my general question is also where do I find detailed documentation on all the neutronclient parameters and/or openstackclient parameters than can be used in Python programs - I can find it all for the CLI.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2018-11-18 23:58:46 -0500

updated 2018-11-18 23:59:36 -0500

network = {'name': 'mynetwork', 'admin_state_up': True} neutron.create_network({'network':network}) networks = neutron.list_networks(name='mynetwork') print networks network_id = networks['networks'][0]['id'] neutron.delete_network(network_id)


edit flag offensive delete link more


Thanks but this document gives very basic usage & doesn't do what I want, i.e. how to specify the gateway port for a router in Python

JeffBannister gravatar imageJeffBannister ( 2018-11-19 02:53:38 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2018-11-18 00:28:32 -0500

Seen: 43 times

Last updated: Nov 18 '18