Debugging the Command Line Client
This article assumes you have installed the OpenStack command line client in a Linux environment. If you have another operating system, the debugging process might be slightly different, however the general rules should still apply.
The OpenStack command line client is very much like other Linux command line tools; error messages are displayed if there is a problem.
These error messages should provide a good indication about what might be wrong. For example, if you execute an OpenStack Swift command without authentication, the error message will look like this:
$ openstack container list Missing value auth-url required for auth plugin password
This message indicates that there are some required command parameters (or environment variables) that are missing. To set the required environment variables you can either source the OpenStack RC script file downloaded from NeCTAR Dashboard, or you can using the equivalent command parameters.
You can always execute openstack help container
or openstack help object
to get help information on the Swift container and object supported options. If you find a useful command, you can also use the --help
option for more specific help, for example:
$ openstack container list --help
Debugging the Python API Client
Debugging your code using the client Python API takes more effort and depends on your familiarity with Python programming and the development environment you use.
You can use the pdb
tool to debug your Python code. You can find more information on pdb
here. The pdb
debugger can be started as follows.
pdb file_name.py
When you start the debugger, program execution pauses at the first line of code. Some useful commands to control the execution flow include:
Command | Action |
---|---|
b | set a breakpoint |
c | continue debugging until you hit a breakpoint |
s | step through the code |
n | to go to next line of code |
l | list source code for the current file |
u | navigate up a stack frame |
d | navigate down a stack frame |
p | to print the value of an expression in the current context |
Debugging the HTTP Client
The OpenStack command line API and Python API are both REST-ful web service clients. All requests are made using HTTP and you can find information on Swift request/response contents at OpenStack Object Storage API. The OpenStack client API uses the Python requests library to send and receive HTTP requests/responses.
For the command line client, you can add the --debug
option to print out the HTTP request/response headers and data, which can provide useful insight. You can compare the debug information to the Object Storage API definitions to see what is expected.
To enable debugging information for the Python API, you can add the following code:
import logging logger = logging.getLogger("swiftclient") logging.basicConfig(level=logging.DEBUG)
This provides the same output as the --debug
option for the command line API.
Debugging via Source Code
If the above techniques are still not helpful, you can always look at the source code to help understand why a problem is occurring. The following source file structure is based on an Ubuntu installation.
The openstack
command executable is located in '/usr/bin/openstack'. This file shows the entry point to the Python API is openstackclient.shell
.
The Python API files are located under '/usr/lib/python2.7/dist-packages/openstackclient' where the most important Swift client file to look at is 'api/object_store_v1.py'. This file prepares and sends Swift requests, and receives the responses.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article