The request you have made requires authentication. (HTTP 401)

Bug #1640708 reported by xuchao
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
vmtp
Invalid
Undecided
Unassigned

Bug Description

Run VMTP:

# docker run --rm -it -v $PWD:/tmp/vmtp -v $HOME/.ssh:/tmp/ssh berrypatch/vmtp vmtp -d -c /tmp/vmtp/vmtp.cfg -r /tmp/vmtp/admin-openrc.sh -p secret --protocol T --json /tmp/vmtp/test.json

Output:

2016-11-10 08:16:29,294 INFO Using http://172.16.xx.xx:5000/v2.0
2016-11-10 08:16:29,294 INFO VM public key: /tmp/ssh/id_rsa.pub
2016-11-10 08:16:29,294 INFO VM private key: /tmp/ssh/id_rsa
2016-11-10 08:16:29,738 ERROR Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/vmtp/vmtp.py", line 426, in run
    self.setup()
  File "/usr/local/lib/python2.7/dist-packages/vmtp/vmtp.py", line 206, in setup
    self.comp.init_key_pair(self.config.public_key_name, self.instance_access)
  File "/usr/local/lib/python2.7/dist-packages/vmtp/compute.py", line 136, in init_key_pair
    return self.add_public_key(kp_name, ssh_access.public_key_file)
  File "/usr/local/lib/python2.7/dist-packages/vmtp/compute.py", line 118, in add_public_key
    self.remove_public_key(name)
  File "/usr/local/lib/python2.7/dist-packages/vmtp/compute.py", line 97, in remove_public_key
    keypair_list = self.novaclient.keypairs.list()
  File "/usr/local/lib/python2.7/dist-packages/novaclient/api_versions.py", line 378, in substitution
    return methods[-1].func(obj, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/novaclient/v2/keypairs.py", line 163, in list
    return self._list('/%s' % self.keypair_prefix, 'keypairs')
  File "/usr/local/lib/python2.7/dist-packages/novaclient/base.py", line 242, in _list
    resp, body = self.api.client.get(url)
  File "/usr/local/lib/python2.7/dist-packages/novaclient/client.py", line 481, in get
    return self._cs_request(url, 'GET', **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/novaclient/client.py", line 437, in _cs_request
    self.authenticate()
  File "/usr/local/lib/python2.7/dist-packages/novaclient/client.py", line 594, in authenticate
    auth_url = self._v2_auth(auth_url)
  File "/usr/local/lib/python2.7/dist-packages/novaclient/client.py", line 685, in _v2_auth
    return self._authenticate(url, body)
  File "/usr/local/lib/python2.7/dist-packages/novaclient/client.py", line 698, in _authenticate
    **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/novaclient/client.py", line 432, in _time_request
    resp, body = self.request(url, method, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/novaclient/client.py", line 426, in request
    raise exceptions.from_response(resp, body, url, method)
Unauthorized: The request you have made requires authentication. (HTTP 401)

Other info
OpenStack Version:Mitaka

admin-openrc.sh file
# cat admin-openrc.sh
unset OS_SERVICE_TOKEN
export OS_USERNAME=admin
export OS_PASSWORD=admin
export OS_AUTH_URL=http://172.16.xx.xx:5000/v2.0
export PS1='[\u@\h \W(keystone_admin)]\$ '
export OS_TENANT_NAME=admin
export OS_REGION_NAME=RegionOne

xuchao (xuchao)
description: updated
Revision history for this message
Yichen Wang (yicwang) wrote :

This looks to me is wrong username/password... Can you double check the credentials you have in openrc.sh is correct? Or you can actually do a "nova list" after sourcing this admin-openrc.sh file, and most likely you will get the same traceback.

Revision history for this message
xuchao (xuchao) wrote :

Thank you for your reply

I can determine my username and password is correct, such as execute commands
[root@22 ~(keystone_admin)]# openstack user list
+----------------------------------+----------------+
| ID | Name |
+----------------------------------+----------------+
| 0d060255f3c441ed9b1131a6feb32510 | heat-cfn |
| 3fbd6204bca54ba4981438f5b2423ac7 | glance |
| 4bc66ec20c75444a99241cd293c3e317 | nova |
| 557cdb5126434e9fb457383a8abe1231 | admin |
| 76e956f3e18a468b8524f47e1b5859ef | heat |
| 803e5716abf24172b9c827bf27af27f5 | cinder |
| 81f00dd0ef58453989eb3b1f7e64d653 | ceilometer |
| ad9e01944be94fb59959a32111af06b5 | pulsar@126.com |
| ccd9fd1700364bfa852c985add3856d3 | neutron |
+----------------------------------+----------------+

Revision history for this message
xuchao (xuchao) wrote :

According to different versions of OpenStack environment test, is also the same error

Such as:Mitaka、Juno、Liberty etc

Revision history for this message
Yichen Wang (yicwang) wrote :

I am not sure whether you intended to mask it. In your CLI, you have "-p secret" which should be "-p admin" per the output of your "admin-openrc.sh".

Revision history for this message
xuchao (xuchao) wrote :

Use Pypi to install and run VMTP

# vmtp -d -c vmtp.cfg -r admin-openrc.sh -p secret --protocol T --json test33.json
2016-11-11 10:35:59,790 WARNING Invalid public_key_file:/tmp/ssh/id_rsa.pub
2016-11-11 10:35:59,790 WARNING Invalid private_key_file:/tmp/ssh/id_rsa
2016-11-11 10:35:59,791 INFO Using http://172.16.xx.xx:5000/v2.0/
2016-11-11 10:35:59,791 INFO VM public key: /root/.ssh/id_rsa.pub
2016-11-11 10:35:59,791 INFO VM private key: /root/.ssh/id_rsa
2016-11-11 10:36:00,229 ERROR Traceback (most recent call last):
  File "/root/vmtpenv/lib/python2.7/site-packages/vmtp/vmtp.py", line 426, in run
    self.setup()
  File "/root/vmtpenv/lib/python2.7/site-packages/vmtp/vmtp.py", line 206, in setup
    self.comp.init_key_pair(self.config.public_key_name, self.instance_access)
  File "/root/vmtpenv/lib/python2.7/site-packages/vmtp/compute.py", line 136, in init_key_pair
    return self.add_public_key(kp_name, ssh_access.public_key_file)
  File "/root/vmtpenv/lib/python2.7/site-packages/vmtp/compute.py", line 118, in add_public_key
    self.remove_public_key(name)
  File "/root/vmtpenv/lib/python2.7/site-packages/vmtp/compute.py", line 97, in remove_public_key
    keypair_list = self.novaclient.keypairs.list()
  File "/root/vmtpenv/lib/python2.7/site-packages/novaclient/api_versions.py", line 402, in substitution
    return methods[-1].func(obj, *args, **kwargs)
  File "/root/vmtpenv/lib/python2.7/site-packages/novaclient/v2/keypairs.py", line 164, in list
    return self._list('/%s' % self.keypair_prefix, 'keypairs')
  File "/root/vmtpenv/lib/python2.7/site-packages/novaclient/base.py", line 249, in _list
    resp, body = self.api.client.get(url)
  File "/root/vmtpenv/lib/python2.7/site-packages/novaclient/client.py", line 480, in get
    return self._cs_request(url, 'GET', **kwargs)
  File "/root/vmtpenv/lib/python2.7/site-packages/novaclient/client.py", line 436, in _cs_request
    self.authenticate()
  File "/root/vmtpenv/lib/python2.7/site-packages/novaclient/client.py", line 593, in authenticate
    auth_url = self._v2_auth(auth_url)
  File "/root/vmtpenv/lib/python2.7/site-packages/novaclient/client.py", line 684, in _v2_auth
    return self._authenticate(url, body)
  File "/root/vmtpenv/lib/python2.7/site-packages/novaclient/client.py", line 697, in _authenticate
    **kwargs)
  File "/root/vmtpenv/lib/python2.7/site-packages/novaclient/client.py", line 431, in _time_request
    resp, body = self.request(url, method, **kwargs)
  File "/root/vmtpenv/lib/python2.7/site-packages/novaclient/client.py", line 425, in request
    raise exceptions.from_response(resp, body, url, method)
Unauthorized: The request you have made requires authentication. (HTTP 401)

Revision history for this message
Yichen Wang (yicwang) wrote :

Xuchao, not sure if you get my point of the reply. I am not saying the way you installed VMTP is wrong, I was saying the parameter passed to VMTP may be wrong.

According to the usage of VMTP, you should use "-p" to specify the password for your stack. From the log you pasted, you are using "-p secret", which means the password is "secret". From the contents of your admin-openrc.sh file, appreently it should be "admin"(export OS_PASSWORD=admin). So can you pass the right password to "-p" of the CLI, and let me know if it works?

Revision history for this message
xuchao (xuchao) wrote :

thanks

Changed in vmtp:
status: New → Invalid
Revision history for this message
xuchao (xuchao) wrote :

In vmtp.cfg file, we need to specify the relevant network resources ?

Revision history for this message
xuchao (xuchao) wrote :

# vmtp -d -c vmtp.cfg -r admin-openrc.sh -p admin --protocol T --json test44.json

2016-11-11 14:39:37,751 WARNING Invalid public_key_file:/tmp/ssh/id_rsa.pub
2016-11-11 14:39:37,751 WARNING Invalid private_key_file:/tmp/ssh/id_rsa
2016-11-11 14:39:37,752 INFO Using http://172.16.70.188:5000/v2.0
2016-11-11 14:39:37,752 INFO VM public key: /root/.ssh/id_rsa.pub
2016-11-11 14:39:37,752 INFO VM private key: /root/.ssh/id_rsa
2016-11-11 14:39:40,105 INFO Found image ubuntu14.04 to launch VM, will continue
/root/vmtpenv/lib/python2.7/site-packages/keystoneclient/service_catalog.py:200: UserWarning: Providing attr without filter_value to get_urls() is deprecated as of the 1.7.0 release and may be removed in the 2.0.0 release. Either both should be provided or neither should be provided.
  'Providing attr without filter_value to get_urls() is '
2016-11-11 14:39:40,581 WARNING No external network found.
2016-11-11 14:39:41,304 INFO Created internal network: pns-internal-net.
2016-11-11 14:39:42,571 INFO Created internal network: pns-internal-net2.
2016-11-11 14:39:42,616 INFO OpenStack agent: Open vSwitch agent
2016-11-11 14:39:42,616 INFO OpenStack network type: vxlan
2016-11-11 14:39:44,897 INFO [TestServer1] Creating server VM...
2016-11-11 14:39:44,897 DEBUG [TestServer1] Starting on zone nova:localhost.localdomain
2016-11-11 14:39:46,781 DEBUG [TestServer1] VM status=BUILD, retrying 1 of 50...
2016-11-11 14:39:49,057 DEBUG [TestServer1] VM status=BUILD, retrying 2 of 50...
2016-11-11 14:39:51,316 DEBUG [TestServer1] VM status=BUILD, retrying 3 of 50...
2016-11-11 14:39:53,810 DEBUG [TestServer1] VM status=BUILD, retrying 4 of 50...
2016-11-11 14:39:56,043 ERROR Traceback (most recent call last):
  File "/root/vmtpenv/lib/python2.7/site-packages/vmtp/vmtp.py", line 426, in run
    self.setup()
  File "/root/vmtpenv/lib/python2.7/site-packages/vmtp/vmtp.py", line 301, in setup
    self.net.vm_int_net[0])
  File "/root/vmtpenv/lib/python2.7/site-packages/vmtp/vmtp.py", line 161, in create_instance
    init_file_name=user_data_file))
  File "/root/vmtpenv/lib/python2.7/site-packages/vmtp/perf_instance.py", line 47, in create
    init_file_name)
  File "/root/vmtpenv/lib/python2.7/site-packages/vmtp/instance.py", line 189, in create
    fip = self.net.create_floating_ip()
  File "/root/vmtpenv/lib/python2.7/site-packages/vmtp/network.py", line 329, in create_floating_ip
    "floating_network_id": self.ext_net['id']
TypeError: 'NoneType' object has no attribute '__getitem__'

Changed in vmtp:
status: Invalid → Confirmed
status: Confirmed → Invalid
Revision history for this message
Yichen Wang (yicwang) wrote :

So VM has been spawned successfully, VMTP is trying to assign a floating IP to it, and it failed.

In order to run VMTP, one of the prerequisite will be having an external network. VMTP will connect to the VM via the floating IP to setup/orchestrate the VM, and get the results from it. From the log above, most likely you don't have an external network configured, therefore no floating IP can be allocated. The solution to this is to set up a routable external network in Neutron, and try again. :)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.