Operate neutron from Python!

Premise

It is assumed that OpenStack is already installed. CentOS7 + RDO(All-in-one)

Preparation

python-install neutron client #pip install python-neutronclient

Set of environment variables

Since it is necessary to tell the program the IP or eye path of the neutron server, set it in the environment variable. Same as "keystonerc_XX" created during installation.

export OS_USERNAME=XXXX
export OS_TENANT_NAME=XXXXX
export OS_PASSWORD=XXXXX
export OS_AUTH_URL=http://172.19.60.93:5000/v2.0/
export OS_REGION_NAME=RegionOne

connect

As documented.

from os import environ
from neutronclient.v2_0 import client

neutron = client.Client(
auth_url=environ['OS_AUTH_URL'],
username=environ['OS_USERNAME'],
password=environ['OS_PASSWORD'],
tenant_name=environ['OS_TENANT_NAME'],
region_name=environ['OS_REGION_NAME'])

Run

list is a display system

#Display Version
print neutron.version

#View security group
print neutron.list_security_groups()

#Display security group (display only specific group)
print neutron.show_security_group("XXXXXX")

#There are many
print dir(neutron)

References

http://docs.openstack.org/user-guide/enduser/sdk.html

Recommended Posts

Operate neutron from Python!
Operate Filemaker from Python
Operate LXC from Python
Operate an I2C-connected display from Python
Operate DynamoDB from Python like SQL.
sql from python
MeCab from Python
Operate Sakura's cloud object storage from Python
Touch MySQL from Python 3
Operate Redmine using Python Redmine
Access bitcoind from python
Changes from Python 3.0 to Python 3.5
Changes from Python 2 to Python 3.0
Python from or import
Use MySQL from Python
Run python from excel
Execute command from Python
Use MySQL from Python
Operate Blender with Python
Operate the schedule app using python from iphone
Manipulate riak from python
Force Python from Fortran
Use BigQuery from python.
Execute command from python
Operate Excel with Python (1)
[Python] Read From Stdin
Use mecab-ipadic-neologd from python
Operate Excel with Python (2)
Operate mongoDB from python in ubuntu environment ① Introduction of mongoDB
[AWS] Operate SQS from SDK (send / receive) [Python] [Node.js]
Flatten using Python yield from
Call CPLEX from Python (DO cplex)
Operate Excel with Python openpyxl
Post from Python to Slack
Operate TwitterBot with Lambda, Python
Cheating from PHP to Python
Make MeCab available from Python3
Information obtained from tweet_id (Python)
Run illustrator script from python
Use MySQL from Anaconda (python)
Anaconda updated from 4.2.0 to 4.3.0 (python3.5 updated to python3.6)
Study from Python Hour4: Object-oriented ②
Query Athena from Lambda Python
[Note] Operate MongoDB with Python
Study from Python Hour3: Functions
Start / stop GCE from python
Stop Omxplayer from Python code
Switch from python2.7 to python3.6 (centos7)
Connect to sqlite from python
Install pyenv from Homebrew, install Python from pyenv
Study from Python Hour4: Object-oriented ①
Python naming convention (from PEP8)
[Python] [SQLite3] Operate SQLite with Python (Basic)
With skype, notify with skype from python!
Use e-Stat API from Python
Register redmine issue from Python
Call Matlab from Python to optimize
Execute Python script from batch file
Call a Python function from p5.js.
Python: Exclude tags from html data
Operate a receipt printer with python