blob: 98092addc7c65d0661d85190f4a54eaa4af7e110 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Get up and running with Libcloud in just a couple of minutes">
<meta name="author" content="The Apache Software Foundation">
<meta name="keywords" content="python,libcloud,cloud,cloud computing,rackspace,amazon ec2,cloudfiles,openstack,cloudstack" />
<title>Getting Started | Apache Libcloud</title>
<!-- fav icons -->
<link rel="shortcut icon" href="/images/favicon.png" />
<link rel="apple-touch-icon" href="/images/apple-touch-icon.png" />
<link rel="apple-touch-icon-precomposed" href="/images/apple-touch-icon.png" />
<link href="/blog/atom.xml" type="application/atom+xml" rel="alternate" title="Apache Libcloud Blog Feed" />
<!-- Facebook OpenGraph tags -->
<meta content="Apache Libcloud" property="og:site_name">
<meta content="Getting Started" property="og:title">
<meta content="Get up and running with Libcloud in just a couple of minutes" property="og:description">
<meta content="website" property="og:type">
<meta content="https://libcloud.apache.org/getting-started" property="og:url">
<link href='/assets/global-1768bfa479597eed443be67c5aec2edc.css' rel='stylesheet' type='text/css' />
</head>
<body data-spy="scroll" data-target=".sidebar-nav" data-offset="80">
<nav class="navbar navbar-fixed-top navbar-inverse" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/"><img src="/images/libcloud_logo.png" class="navbar-logo" /> Apache Libcloud</a>
</div>
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
<li ><a href="/" >Home</a></li>
<li ><a href="/about.html" >About</a></li>
<li class="active"><a href="/getting-started.html" >Quick Start</a></li>
<li ><a href="https://libcloud.readthedocs.org/en/stable/" target="_blank">Documentation</a></li>
<li ><a href="/downloads.html" >Downloads</a></li>
<li ><a href="/community.html" >Community</a></li>
<li ><a href="/blog/" >Blog</a></li>
</ul>
<div class="material-switch pull-right">
<input id="theme-switch" name="theme-switch" type="checkbox" onclick="modeSwitcher()"/>
<label for="theme-switch" class="label-default"></label>
<span id="theme-toggle" class="theme-switch">Dark mode</span>
</div>
</div><!-- /.navbar-collapse -->
</div><!-- /.container -->
</nav>
<div class="container main-container">
<div class="row section page-content">
<div class="col-lg-2 sidebar-nav visible-lg">
<ul class="list-unstyled nav">
<li><a href="#installation-stable-version">Installation (stable version)</a></li>
<li><a href="#installation-development-version">Installation (development version)</a></li>
<li><a href="#using-it">Using it</a></li>
<li><a href="#where-to-go-from-here">Where to go from here?</a></li>
</ul>
</div>
<div class="col-lg-8 col-lg-offset-3">
<h1 id="getting-started">Getting Started</h1>
<p>This page contains short instructions on how to get up and running with
Libcloud in just a couple of minutes.</p>
<p>For more in-depth instructions and examples, please refer to the
<a href="https://libcloud.readthedocs.org/en/stable/index.html">documentation</a>.</p>
<h2 id="installation-stable-version">Installation (stable version)</h2>
<p>Libcloud is available on <a href="http://pypi.python.org/pypi/apache-libcloud">PyPi</a>. You can install latest stable version using
pip:</p>
<figure class="highlight">
<pre><code class="language-bash" data-lang="bash">pip <span class="nb">install </span>apache-libcloud</code></pre>
</figure>
<h2 id="installation-development-version">Installation (development version)</h2>
<p>If you feel adventurous and want the latest and greatest, you can install latest
development version from our Git repository:</p>
<figure class="highlight">
<pre><code class="language-bash" data-lang="bash">pip <span class="nb">install </span>git+http://gitbox.apache.org/repos/asf/libcloud.git@trunk#egg<span class="o">=</span>apache-libcloud</code></pre>
</figure>
<p>Keep in mind that trunk is usually under heavy development and can contain
backward incompatible changes. You should only use it if you know what you are
doing.</p>
<h2 id="using-it">Using It</h2>
<p>This section describes a standard work-flow which you follow when working
with Libcloud drivers.</p>
<p>Code snippet bellow use compute API as an example, but exactly the same
work-flow is followed also when working with other APIs.</p>
<p>1.. Obtain reference to the provider driver</p>
<figure class="highlight">
<pre><code class="language-python" data-lang="python"><span class="kn">from</span> <span class="nn">pprint</span> <span class="kn">import</span> <span class="n">pprint</span>
<span class="kn">from</span> <span class="nn">libcloud.compute.types</span> <span class="kn">import</span> <span class="n">Provider</span>
<span class="kn">from</span> <span class="nn">libcloud.compute.providers</span> <span class="kn">import</span> <span class="n">get_driver</span>
<span class="n">cls</span> <span class="o">=</span> <span class="n">get_driver</span><span class="p">(</span><span class="n">Provider</span><span class="p">.</span><span class="n">RACKSPACE</span><span class="p">)</span></code></pre>
</figure>
<p>2.. Instantiate the driver with your provider credentials</p>
<figure class="highlight">
<pre><code class="language-python" data-lang="python"><span class="n">driver</span> <span class="o">=</span> <span class="n">cls</span><span class="p">(</span><span class="s">'my username'</span><span class="p">,</span> <span class="s">'my api key'</span><span class="p">)</span></code></pre>
</figure>
<p>Keep in mind that some drivers take additional arguments such as <code class="language-plaintext highlighter-rouge">region</code>
and <code class="language-plaintext highlighter-rouge">api_version</code>.</p>
<p>For more information on which arguments you can pass to your provider driver,
see provider-specific documentation and the driver docstrings.</p>
<p>3.. Start using the driver</p>
<figure class="highlight">
<pre><code class="language-python" data-lang="python"><span class="n">pprint</span><span class="p">(</span><span class="n">driver</span><span class="p">.</span><span class="n">list_sizes</span><span class="p">())</span>
<span class="n">pprint</span><span class="p">(</span><span class="n">driver</span><span class="p">.</span><span class="n">list_nodes</span><span class="p">())</span></code></pre>
</figure>
<p>4.. Putting it all together</p>
<figure class="highlight">
<pre><code class="language-python" data-lang="python"><span class="kn">from</span> <span class="nn">pprint</span> <span class="kn">import</span> <span class="n">pprint</span>
<span class="kn">from</span> <span class="nn">libcloud.compute.types</span> <span class="kn">import</span> <span class="n">Provider</span>
<span class="kn">from</span> <span class="nn">libcloud.compute.providers</span> <span class="kn">import</span> <span class="n">get_driver</span>
<span class="n">cls</span> <span class="o">=</span> <span class="n">get_driver</span><span class="p">(</span><span class="n">Provider</span><span class="p">.</span><span class="n">RACKSPACE</span><span class="p">)</span>
<span class="n">driver</span> <span class="o">=</span> <span class="n">cls</span><span class="p">(</span><span class="s">'my username'</span><span class="p">,</span> <span class="s">'my api key'</span><span class="p">)</span>
<span class="n">pprint</span><span class="p">(</span><span class="n">driver</span><span class="p">.</span><span class="n">list_sizes</span><span class="p">())</span>
<span class="n">pprint</span><span class="p">(</span><span class="n">driver</span><span class="p">.</span><span class="n">list_nodes</span><span class="p">())</span></code></pre>
</figure>
<h2 id="where-to-go-from-here">Where to go from here?</h2>
<p>The best thing to do after understanding the basic driver work-flow is to visit
the documentation chapter for the API you are interested in (<a href="https://libcloud.readthedocs.org/en/stable/compute/index.html">Compute</a>,
<a href="https://libcloud.readthedocs.org/en/stable/storage/index.html">Object Storage</a>, <a href="https://libcloud.readthedocs.org/en/stable/loadbalancer/index.html">Load Balance</a>, <a href="https://libcloud.readthedocs.org/en/stable/dns/index.html">DNS</a>). Chapter for each API
explains some basic terminology and things you need to know to make an
effective use of that API.</p>
<p>After you have a good grasp of those basic concepts, you are encouraged to
check the documentation for the provider you are interested in (if available)
and usage examples. If the driver specific documentation for the provider
you are interested in is not available yet, you are encouraged to check
docstrings for that driver.</p>
</div>
</div>
<hr />
<footer>
<div class="row">
<div class="col-lg-12 text-center">
<div class="footer-links">
<p><a href="http://www.apache.org/licenses/">License</a> | <a
href="/security.html">Security</a> | <a
href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a> |
<a href="http://www.apache.org/foundation/thanks.html">Thanks</a> |
<a href="https://www.apache.org/events/">Events</a> |
<a href="/credits.html">Credits</a> | <a href="/media.html">Media</a>
</div>
<div class="footer-text">
<p><a class="acevent" data-format="wide"></a></p>
<p class="">Copyright &copy; 2009-2023 <a href="https://www.apache.org/" target="_blank">The Apache Software Foundation</a></p>
<p class="">Apache Libcloud, Libcloud, Apache, the Apache feather, and the Apache Libcloud project logo are trademarks of the Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
<p class="">Site last updated on 2023-09-09 21:33:21 +0000</p>
</div>
</div>
</div>
</footer>
</div><!-- /.container -->
<!-- JavaScript -->
<script src='/assets/global-20157a00c0e17a775f45ed99ccdf79d7.js' type='text/javascript'></script>
<script type="text/javascript">
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before
"trackPageView" */
/* We explicitly disable cookie tracking to avoid privacy issues */
_paq.push(['disableCookies']);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://analytics.apache.org/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '7']);
var d=document, g=d.createElement('script'),
s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<script src="https://www.apachecon.com/event-images/snippet.js"></script>
</body>
</html>