A really basic python-ironicclient usage example

Because this is one of those things that took me longer than it should have taken to figure out, here’s an ultra-basic look at how to get python-ironicclient working, if you want to poke at the Ironic API. Note that I make no claim that this is even the right way, but it ought to get you going:

# the ...as something is because 'client' is way too generic
import keystoneclient.v2_0.client as ksclient
import ironicclient.client as iclient


ks = ksclient.Client(auth_url='http://localhost:35357/v2.0',
    username='admin', password='password', tenant_name='admin')
# Check out ks.auth_token which should have a long value if it worked

ic = iclient.Client('1', 'http://localhost:6385')
ic.auth_token = ks.auth_token

ic.node.list() # etc.

I started that inside of ipython, which gives me tab-autocomplete. That’s very handy for figuring out what options are available.

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>