- Neutron command line and Python APIs can be installed directly on RDO, openSUSE, SUSE Linux Enterprise, Debian, and Ubuntu via command line.
- On Red Hat, CentOS or Fedora, use yum to install:
yum install python-neutronclient
- On Ubuntu or Debian, use apt-get to install:
sudo apt-get install python-neutronclient
- On openSUSE, use zypper to install:
zypper install python-neutronclient
- On SUSE Linux:
zypper addrepo -f obs://Cloud:OpenStack:Kilo/SLE_12 Kilo zypper install python-neutronclient
- OR: If you prefer to install sources packages, follow the instructions to install python-pip relevant to your operating system, then enter the command:
sudo pip install python-neutronclient
pip install python-neutronclient
Before you can use the python Neutron client and command line API you need to be authenticated to the NeCTAR cloud. The below shows the instructions of how to get username/password and get authenticated.
- Login to NeCTAR Cloud Dashboard
- Click 'Access & Security'
- On the 'Access & Security' page, click tab 'API Access'
- Click button "Download OpenStack RC File"
- Save the file into a directory
- Click the drop down list with your email on the right top of page, then click 'Settings'
- Click 'Reset Password' and save the password appeared on the screen
API normally requires 4 environment variables to be set for authentication:
- auth URL
- project id or name (most clients can handle either)
When using the script file you downloaded from NeCTAR Dashboard, these varilabels are set by the script file and you can see these variables if you open the file. Example:
Authentication for Command Line API
The following instruction assume you use Linux operating system.
Once you have obtained the authentication script and password, you can execute the script suing
source file-name.sh. and type in the password you
obtained from Dashboard.
Authentication for python Neutron API
You can use the below sample code to get authenticated.
from neutronclient.v2_0 import client username='adminUser' password='secretword' tenant_name='openstackDemo' auth_url='http://192.168.206.130:5000/v2.0' neutron = client.Client(username=username, password=password, tenant_name=tenant_name, auth_url=auth_url)
You can get username, tenant_name and auth_url from the above .sh file obtained from the NeCTAR Dashboard and you can also get the password from above as copied from the NeCTAR Dashboard.
How to use
Once the client is authenticated, you can start to use them. See below for how to get started.
Command Line API
You can use Neutron command to manage your objects storage, you can type:
neutron --help to find out all the available options.
Python Neutron API
You can also use Python Neutron API in your python code to access object storage.
See below for a sample code:
from neutronclient.v2_0 import client username='adminUser' password='secretword' tenant_name='openstackDemo' auth_url='http://192.168.206.130:5000/v2.0' neutron = client.Client(username=username, password=password, tenant_name=tenant_name, auth_url=auth_url) networks = neutron.list_networks()
You can find more information in the Networking API section.