6475c37330
Change-Id: If421d82e4c3522a008054c31a2003e81d591bbd3
1.4 KiB
1.4 KiB
Authenticate against a Networking endpoint
To authenticate against a Networking endpoint, instantiate a
neutronclient.v_2_0.client.Client
object:
from os import environ as env
from neutronclient.v2_0 import client as neutronclient
= neutronclient.Client(auth_url=env['OS_AUTH_URL'],
neutron =env['OS_USERNAME'],
username=env['OS_PASSWORD'],
password=env['OS_TENANT_NAME'],
tenant_name=env['OS_REGION_NAME']) region_name
You can also authenticate by explicitly specifying the endpoint and token:
from os import environ as env
import keystoneclient.v2_0.client as ksclient
from neutronclient.v2_0 import client as neutronclient
= ksclient.Client(auth_url=env['OS_AUTH_URL'],
keystone =env['OS_USERNAME'],
username=env['OS_PASSWORD'],
password=env['OS_TENANT_NAME'],
tenant_name=env['OS_REGION_NAME'])
region_name= keystone.service_catalog.url_for(service_type='network')
endpoint_url = keystone.auth_token
token = neutronclient.Client(endpoint_url=endpoint_url, token=token) neutron