libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r861201 - in /websites/staging/libcloud/trunk/content: ./ docs/compute-examples.html
Date Tue, 07 May 2013 17:53:43 GMT
Author: buildbot
Date: Tue May  7 17:53:43 2013
New Revision: 861201

Log:
Staging update by buildbot for libcloud

Modified:
    websites/staging/libcloud/trunk/content/   (props changed)
    websites/staging/libcloud/trunk/content/docs/compute-examples.html

Propchange: websites/staging/libcloud/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Tue May  7 17:53:43 2013
@@ -1 +1 @@
-1470265
+1479992

Modified: websites/staging/libcloud/trunk/content/docs/compute-examples.html
==============================================================================
--- websites/staging/libcloud/trunk/content/docs/compute-examples.html (original)
+++ websites/staging/libcloud/trunk/content/docs/compute-examples.html Tue May  7 17:53:43
2013
@@ -96,9 +96,140 @@
       
       <h2 id="examples">Examples</h2>
 <ul>
+<li><a href="#example-3-openstack-node-using-local-openstack">Create an OpenStack
node using a local OpenStack provider</a></li>
 <li><a href="#example-1-openstack-node-using-trystack">Create an OpenStack node
using trystack.org provider</a></li>
 <li><a href="#example-2-vcloud-generic-provider">Create a VMware vCloud v1.5
node using generic provider</a></li>
 </ul>
+<h3 id="example-3-openstack-node-using-local-openstack">Create an OpenStack node using
a local OpenStack provider</h3>
+
+<p>This example shows how to create a node using a local OpenStack installation.
+To make it work with your installation make sure to replace
+`your_auth_username`, `your_auth_password` and `ex_force_auth_url` with a
+correct value.</p>
+
+<p>Note: This example works with Libcloud 0.9.0 and above.</p>
+
+<div class="codehilite"><pre><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="kn">import</span> <span class="nn">libcloud.security</span>
+
+<span class="c"># This assumes you don&#39;t have SSL set up.</span>
+<span class="c"># Note: Code like this poses a security risk (MITM attack) and</span>
+<span class="c"># that&#39;s the reason why you should never use it for anything
else</span>
+<span class="c"># besides testing. You have been warned.</span>
+<span class="n">libcloud</span><span class="o">.</span><span class="n">security</span><span
class="o">.</span><span class="n">VERIFY_SSL_CERT</span> <span class="o">=</span>
<span class="bp">False</span>
+
+<span class="n">OpenStack</span> <span class="o">=</span> <span
class="n">get_driver</span><span class="p">(</span><span class="n">Provider</span><span
class="o">.</span><span class="n">OPENSTACK</span><span class="p">)</span>
+<span class="n">driver</span> <span class="o">=</span> <span class="n">OpenStack</span><span
class="p">(</span><span class="s">&#39;your_auth_username&#39;</span><span
class="p">,</span> <span class="s">&#39;your_auth_password&#39;</span><span
class="p">,</span>
+                   <span class="n">ex_force_auth_url</span><span class="o">=</span><span
class="s">&#39;http://192.168.1.101:5000/v2.0&#39;</span><span class="p">,</span>
+                   <span class="n">ex_force_auth_version</span><span class="o">=</span><span
class="s">&#39;2.0_password&#39;</span><span class="p">,</span>
+                   <span class="n">ex_tenant_name</span><span class="o">=</span><span
class="s">&#39;your_tenant_name&#39;</span><span class="p">)</span>
+</pre></div>
+
+
+<h3 id="example-1-openstack-node-using-trystack">Create an OpenStack node using trystack.org
provider</h3>
+
+<p><a href="https://trystack.org/">trystack.org</a> allows users to try
out OpenStack for free.
+This example demonstrates how to launch an OpenStack node on the trystack.org provider using
a generic
+OpenStack driver.</p>
+
+<p>Note: This example works with Libcloud 0.9.0 and above.</p>
+
+<div class="codehilite"><pre><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="kn">import</span> <span class="nn">libcloud.security</span>
+
+<span class="c"># At the time this example was written, https://nova-api.trystack.org:5443</span>
+<span class="c"># was using a certificate issued by a Certificate Authority (CA)</span>
+<span class="c"># which is not included in the default Ubuntu certificates bundle (ca-certificates).</span>
+<span class="c"># Note: Code like this poses a security risk (MITM attack) and</span>
+<span class="c"># that&#39;s the reason why you should never use it for anything
else</span>
+<span class="c"># besides testing. You have been warned.</span>
+<span class="n">libcloud</span><span class="o">.</span><span class="n">security</span><span
class="o">.</span><span class="n">VERIFY_SSL_CERT</span> <span class="o">=</span>
<span class="bp">False</span>
+
+<span class="n">OpenStack</span> <span class="o">=</span> <span
class="n">get_driver</span><span class="p">(</span><span class="n">Provider</span><span
class="o">.</span><span class="n">OPENSTACK</span><span class="p">)</span>
+
+<span class="n">driver</span> <span class="o">=</span> <span class="n">OpenStack</span><span
class="p">(</span><span class="s">&#39;your username&#39;</span><span
class="p">,</span> <span class="s">&#39;your password&#39;</span><span
class="p">,</span>
+                   <span class="n">ex_force_auth_url</span><span class="o">=</span><span
class="s">&#39;https://nova-api.trystack.org:5443/v2.0&#39;</span><span
class="p">,</span>
+                   <span class="n">ex_force_auth_version</span><span class="o">=</span><span
class="s">&#39;2.0_password&#39;</span><span class="p">)</span>
+
+<span class="n">nodes</span> <span class="o">=</span> <span class="n">driver</span><span
class="o">.</span><span class="n">list_nodes</span><span class="p">()</span>
+
+<span class="n">images</span> <span class="o">=</span> <span class="n">driver</span><span
class="o">.</span><span class="n">list_images</span><span class="p">()</span>
+<span class="n">sizes</span> <span class="o">=</span> <span class="n">driver</span><span
class="o">.</span><span class="n">list_sizes</span><span class="p">()</span>
+<span class="n">size</span> <span class="o">=</span> <span class="p">[</span><span
class="n">s</span> <span class="k">for</span> <span class="n">s</span>
<span class="ow">in</span> <span class="n">sizes</span> <span class="k">if</span>
<span class="n">s</span><span class="o">.</span><span class="n">ram</span>
<span class="o">==</span> <span class="mi">512</span><span class="p">][</span><span
class="mi">0</span><span class="p">]</span>
+<span class="n">image</span> <span class="o">=</span> <span class="p">[</span><span
class="n">i</span> <span class="k">for</span> <span class="n">i</span>
<span class="ow">in</span> <span class="n">images</span> <span
class="k">if</span> <span class="n">i</span><span class="o">.</span><span
class="n">name</span> <span class="o">==</span> <span class="s">&#39;natty-server-cloudimg-amd64&#39;</span><span
class="p">][</span><span class="mi">0</span><span class="p">]</span>
+
+<span class="n">node</span> <span class="o">=</span> <span class="n">driver</span><span
class="o">.</span><span class="n">create_node</span><span class="p">(</span><span
class="n">name</span><span class="o">=</span><span class="s">&#39;test
node&#39;</span><span class="p">,</span> <span class="n">image</span><span
class="o">=</span><span class="n">image</span><span class="p">,</span>
<span class="n">size</span><span class="o">=</span><span class="n">size</span><span
class="p">)</span>
+</pre></div>
+
+
+<h3 id="example-2-vcloud-generic-provider">Create a VMware vCloud v1.5 node using generic
provider</h3>
+
+<p>This example demonstrates how to launch a VMware vCloud v1.5 node on a generic provider
such as a test lab.</p>
+
+<p>Note: This example works with Libcloud version 0.10.1 and above.</p>
+
+<div class="codehilite"><pre><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="kn">import</span> <span class="nn">libcloud.security</span>
+
+<span class="c"># Skip this step if you are launching nodes on an official vCloud</span>
+<span class="c"># provider. It is intended only for self signed SSL certs in </span>
+<span class="c"># vanilla vCloud Director v1.5 test deployments.</span>
+<span class="c"># Note: Code like this poses a security risk (MITM attack) and</span>
+<span class="c"># that&#39;s the reason why you should never use it for anything
else</span>
+<span class="c"># besides testing. You have been warned.</span>
+<span class="n">libcloud</span><span class="o">.</span><span class="n">security</span><span
class="o">.</span><span class="n">VERIFY_SSL_CERT</span> <span class="o">=</span>
<span class="bp">False</span>
+
+<span class="n">vcloud</span> <span class="o">=</span> <span class="n">get_driver</span><span
class="p">(</span><span class="n">Provider</span><span class="o">.</span><span
class="n">VCLOUD</span><span class="p">)</span>
+
+<span class="n">driver</span> <span class="o">=</span> <span class="n">vcloud</span><span
class="p">(</span><span class="s">&#39;you username@organisation&#39;</span><span
class="p">,</span> <span class="s">&#39;your password&#39;</span><span
class="p">,</span>
+                <span class="n">host</span><span class="o">=</span><span
class="s">&#39;vcloud.local&#39;</span><span class="p">,</span>
<span class="n">api_version</span><span class="o">=</span><span
class="s">&#39;1.5&#39;</span><span class="p">)</span>
+
+<span class="c"># List all instantiated vApps</span>
+<span class="n">nodes</span> <span class="o">=</span> <span class="n">driver</span><span
class="o">.</span><span class="n">list_nodes</span><span class="p">()</span>
+<span class="c"># List all VMs within the first vApp instance</span>
+<span class="k">print</span> <span class="n">nodes</span><span
class="p">[</span><span class="mi">0</span><span class="p">]</span><span
class="o">.</span><span class="n">extra</span><span class="p">[</span><span
class="s">&#39;vms&#39;</span><span class="p">]</span>
+
+<span class="c"># List all available vApp Templates</span>
+<span class="n">images</span> <span class="o">=</span> <span class="n">driver</span><span
class="o">.</span><span class="n">list_images</span><span class="p">()</span>
+<span class="n">image</span> <span class="o">=</span> <span class="p">[</span><span
class="n">i</span> <span class="k">for</span> <span class="n">i</span>
<span class="ow">in</span> <span class="n">images</span> <span
class="k">if</span> <span class="n">i</span><span class="o">.</span><span
class="n">name</span> <span class="o">==</span> <span class="s">&#39;natty-server-cloudimg-amd64&#39;</span><span
class="p">][</span><span class="mi">0</span><span class="p">]</span>
+
+<span class="c"># Create node with minimum set of parameters</span>
+<span class="n">node</span> <span class="o">=</span> <span class="n">driver</span><span
class="o">.</span><span class="n">create_node</span><span class="p">(</span><span
class="n">name</span><span class="o">=</span><span class="s">&#39;test
node 1&#39;</span><span class="p">,</span> <span class="n">image</span><span
class="o">=</span><span class="n">image</span><span class="p">)</span>
+<span class="c"># Destroy the node</span>
+<span class="n">driver</span><span class="o">.</span><span class="n">destroy_node</span><span
class="p">(</span><span class="n">node</span><span class="p">)</span>
+
+<span class="c"># Create node without deploying and powering it on</span>
+<span class="n">node</span> <span class="o">=</span> <span class="n">driver</span><span
class="o">.</span><span class="n">create_node</span><span class="p">(</span><span
class="n">name</span><span class="o">=</span><span class="s">&#39;test
node 2&#39;</span><span class="p">,</span> <span class="n">image</span><span
class="o">=</span><span class="n">image</span><span class="p">,</span>
<span class="n">ex_deploy</span><span class="o">=</span><span class="bp">False</span><span
class="p">)</span>
+
+<span class="c"># Create node with custom CPU &amp; Memory values</span>
+<span class="n">node</span> <span class="o">=</span> <span class="n">driver</span><span
class="o">.</span><span class="n">create_node</span><span class="p">(</span><span
class="n">name</span><span class="o">=</span><span class="s">&#39;test
node 3&#39;</span><span class="p">,</span> <span class="n">image</span><span
class="o">=</span><span class="n">image</span><span class="p">,</span>
<span class="n">ex_vm_cpu</span><span class="o">=</span><span class="mi">3</span><span
class="p">,</span> <span class="n">ex_vm_memory</span><span class="o">=</span><span
class="mi">1024</span><span class="p">)</span>
+
+<span class="c"># Create node with customised networking parameters (eg. for OVF imported
images)</span>
+<span class="n">node</span> <span class="o">=</span> <span class="n">driver</span><span
class="o">.</span><span class="n">create_node</span><span class="p">(</span><span
class="n">name</span><span class="o">=</span><span class="s">&#39;test
node 4&#39;</span><span class="p">,</span> <span class="n">image</span><span
class="o">=</span><span class="n">image</span><span class="p">,</span>
+                          <span class="n">ex_vm_network</span><span class="o">=</span><span
class="s">&#39;your vm net name&#39;</span><span class="p">,</span>
<span class="n">ex_network</span><span class="o">=</span><span
class="s">&#39;your org net name&#39;</span><span class="p">,</span>
+                          <span class="n">ex_vm_fence</span><span class="o">=</span><span
class="s">&#39;bridged&#39;</span><span class="p">,</span> <span
class="n">ex_vm_ipmode</span><span class="o">=</span><span class="s">&#39;DHCP&#39;</span><span
class="p">)</span>
+
+<span class="c"># Create node in a custom virtual data center</span>
+<span class="n">node</span> <span class="o">=</span> <span class="n">driver</span><span
class="o">.</span><span class="n">create_node</span><span class="p">(</span><span
class="n">name</span><span class="o">=</span><span class="s">&#39;test
node 4&#39;</span><span class="p">,</span> <span class="n">image</span><span
class="o">=</span><span class="n">image</span><span class="p">,</span>
<span class="n">ex_vdc</span><span class="o">=</span><span class="s">&#39;your
vdc name&#39;</span><span class="p">)</span>
+
+<span class="c"># Create node with guest OS customisation script to be run at first
boot</span>
+<span class="n">node</span> <span class="o">=</span> <span class="n">driver</span><span
class="o">.</span><span class="n">create_node</span><span class="p">(</span><span
class="n">name</span><span class="o">=</span><span class="s">&#39;test
node 5&#39;</span><span class="p">,</span> <span class="n">image</span><span
class="o">=</span><span class="n">image</span><span class="p">,</span>
+                          <span class="n">ex_vm_script</span><span class="o">=</span><span
class="s">&#39;filesystem path to your script&#39;</span><span class="p">)</span>
+</pre></div>
+
+
+<ul>
+<li><a href="#example-1-openstack-node-using-trystack">Create an OpenStack node
using trystack.org provider</a></li>
+<li><a href="#example-2-vcloud-generic-provider">Create a VMware vCloud v1.5
node using generic provider</a></li>
+</ul>
+<h3 id="example-1-openstack-node-using-local-openstack">Create an OpenStack node using
a local OpenStack provider</h3>
+
 <h3 id="example-1-openstack-node-using-trystack">Create an OpenStack node using trystack.org
provider</h3>
 
 <p><a href="https://trystack.org/">trystack.org</a> allows users to try
out OpenStack for free.



Mime
View raw message