Search This Blog

Tuesday, July 24, 2012

Rackspace python-cloudservers debugging

For the first generation of Rackspace cloud there is a cli tool and a python library [1].
The source code can the tool can be found on github [2].

Problem description

After successful installation of this tool I run into the follow error below.
# cat /etc/issue
Ubuntu 11.04 \n \l
# aptitude install python-rackspace-cloudservers

$ cloudservers --username user --apikey 391c7...be1  show 10197279
Traceback (most recent call last):
  File "/usr/bin/cloudservers", line 9, in 
    load_entry_point('python-cloudservers==1.0a5', 'console_scripts', 'cloudservers')()
  File "/usr/lib/pymodules/python2.7/cloudservers/", line 409, in main
  File "/usr/lib/pymodules/python2.7/cloudservers/", line 123, in main
  File "/usr/lib/pymodules/python2.7/cloudservers/", line 60, in authenticate
  File "/usr/lib/pymodules/python2.7/cloudservers/", line 79, in authenticate
    resp, body = self.request(self.AUTH_URL, 'GET', headers=headers)
  File "/usr/lib/pymodules/python2.7/cloudservers/", line 34, in request
    body = json.loads(body) if body else None
  File "/usr/lib/python2.7/json/", line 326, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/", line 360, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/", line 378, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded


Investigating the stacktrace we see that there are various method called before the error was reported. Looking at the stack from bottom up we see that the the code gets interested around lines 12 and 13.

$ sed -n 79p  /usr/lib/pymodules/python2.7/cloudservers/
        resp, body = self.request(self.AUTH_URL, 'GET', headers=headers)

$ grep AUTH_URL /usr/lib/pymodules/python2.7/cloudservers/ 
    AUTH_URL = ''
        resp, body = self.request(self.AUTH_URL, 'GET', headers=headers)

We see that the URL is hard coded in python code. Because my cloud account is base in London (my cloud files and cloud server provisioning regions are in London ) this URL is wrong. More info about the authentication point can be found in the official doc [3].

An easy fix for this requires to change the URL to a new one:




No comments:

Post a Comment