<div dir="ltr">Hi James,<div><br></div><div>I might suggest the CLI is the reference implementation of the API. Let me point out a few things there, and then you can probably tinker with it from there.</div><div><br></div><div>Imports: </div><div><br></div><div><a href="https://github.com/CentOS-PaaS-SIG/linchpin/blob/develop/linchpin/__init__.py#L8">https://github.com/CentOS-PaaS-SIG/linchpin/blob/develop/linchpin/__init__.py#L8</a><br></div><div><br></div><div>LinchPinCli (and LinchpinAPI) need a LinchpinContext class:</div><div><br></div><div><a href="https://github.com/CentOS-PaaS-SIG/linchpin/blob/develop/linchpin/__init__.py#L8">https://github.com/CentOS-PaaS-SIG/linchpin/blob/develop/linchpin/__init__.py#L8</a><br></div><div><br></div><div>The LinchpinContext class needs a few functions run to get things ready. Loading the configurations, up runDB, logging, reading extra_vars, etc.</div><div><br></div><div>Instantiate the LinchpinCli class:</div><div><br></div><div><a href="https://github.com/CentOS-PaaS-SIG/linchpin/blob/develop/linchpin/__init__.py#L169">https://github.com/CentOS-PaaS-SIG/linchpin/blob/develop/linchpin/__init__.py#L169</a><br></div><div><br></div><div>From there, perform actions, up, destroy, fetch, journal. Each of these items calls into the LinchpinCli (which is subclassing the LinchpinAPI class), and is prefixed with lp. Each method is named as such:</div><div><br></div><div>lp_up, lp_destroy, lp_fetch, lp_journal, etc.</div><div><br></div><div>You can read up on those methods on the docs provided. The up/destroy methods call run_playbook, which calls the proper ansible playgook. The fetch and journal methods are more for prep or reporting and don't use ansible.</div><div><br></div><div>Hopefully this will get you started. </div><div><br></div><div>Cheers,</div><div><br></div><div>herlo</div><div><br></div><div>PS - The API is about to go through a bit of an overhaul in the next month or so to handle dynamic PinFiles and topologies. The likeliest change will be having the API take only dicts of data, and the CLI bits will parse the files and pass in the information properly.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 16, 2017 at 3:26 PM, James Pryor <span dir="ltr"><<a href="mailto:jpryor@redhat.com" target="_blank">jpryor@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Hello list,<br>How can I use linchpin in Python code? I see in the docs the python api reference, that at least hints to me that it can be done as python and not just sub-process shell-out to the CLI. <br></div><div><br></div><div>Assuming I have a python codebase, and assuming I have linchpin installed and working, I guess I would have done<br></div><div>$ pip install linchpin</div><div><br></div><div>maybe then in my code:<br></div><div><br></div><div>import linchpin</div><div><br></div><div>but after that, I just don't know.</div><div>I am looking for a "Usage" section for noobs like so: <a href="https://github.com/openpaperwork/pyocr#usage" target="_blank">https://github.com/<wbr>openpaperwork/pyocr#usage</a></div><div><br></div>Regards,<br></div>James<br></div>
<br>______________________________<wbr>_________________<br>
linchpin mailing list<br>
<a href="mailto:linchpin@redhat.com">linchpin@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/linchpin" rel="noreferrer" target="_blank">https://www.redhat.com/<wbr>mailman/listinfo/linchpin</a><br>
<br></blockquote></div><br></div>