[Openstack-operators] set quota got authentication error

Lee Ho Yeung jobmattcon at gmail.com
Mon Aug 29 09:05:56 UTC 2016


i have already set insecure but still got error


>>> nc.quotas.update(my_tenant.id, floating_ips=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/novaclient/v1_1/quotas.py", line
61, in update
    return self._update(url, body, 'quota_set')
  File "/usr/lib/python2.7/dist-packages/novaclient/base.py", line 165, in
_update
    _resp, body = self.api.client.put(url, body=body)
  File "/usr/lib/python2.7/dist-packages/novaclient/client.py", line 289,
in put
    return self._cs_request(url, 'PUT', **kwargs)
  File "/usr/lib/python2.7/dist-packages/novaclient/client.py", line 249,
in _cs_request
    self.authenticate()
  File "/usr/lib/python2.7/dist-packages/novaclient/client.py", line 382,
in authenticate
    auth_url = self._v2_auth(auth_url)
  File "/usr/lib/python2.7/dist-packages/novaclient/client.py", line 469,
in _v2_auth
    return self._authenticate(url, body)
  File "/usr/lib/python2.7/dist-packages/novaclient/client.py", line 482,
in _authenticate
    **kwargs)
  File "/usr/lib/python2.7/dist-packages/novaclient/client.py", line 242,
in _time_request
    resp, body = self.request(url, method, **kwargs)
  File "/usr/lib/python2.7/dist-packages/novaclient/client.py", line 236,
in request
    raise exceptions.from_response(resp, body, url, method)
novaclient.exceptions.Unauthorized: The request you have made requires
authentication. (HTTP 401)


from keystoneclient.v2_0.client import Client
import os
import csv
import sys
import logging
import time
from nova import db
from nova import config
from nova import context
import argparse
import novaclient.v1_1.client as nvclient


def get_nova_credentials_v2():
    d = {}
    d['version'] = '2'
    d['username'] = os.environ['OS_USERNAME']
    d['password'] = os.environ['OS_PASSWORD']
    d['auth_url'] = os.environ['OS_AUTH_URL']
    d['tenant_name'] = os.environ['OS_TENANT_NAME']
    d['insecure'] = 'True'
    return d

credentials = get_nova_credentials_v2()
keystone_client = Client(**credentials)
tenants = keystone_client.tenants.list()
rolelist = keystone_client.roles.list()
userlist = keystone_client.users.list()
my_admin = [x for x in rolelist if x.name=="admin"][0]
my_member = [x for x in rolelist if x.name=="_member_"][0]
my_admin_user = [x for x in userlist if x.name=="admin"][0]

my_tenant = [x for x in tenants if x.name=="hello"][0]
nc = nvclient.Client(None, None, None, auth_url=os.environ['OS_AUTH_URL'],
tenant_id=my_tenant.id, auth_token=keystone_client.auth_token,
insecure='True')

nc.quotas.update(my_tenant.id, floating_ips=1)
nc.quotas.update(my_tenant.id, security_group_rules=20)
nc.quotas.update(my_tenant.id, network=3)
nc.quotas.update(my_tenant.id, routers=1)
nc.quotas.update(my_tenant.id, subnets=3)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-operators/attachments/20160829/ec7003f5/attachment.html>


More information about the OpenStack-operators mailing list