libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r817537 - in /websites/staging/libcloud/trunk/content: ./ docs/compute-examples.html
Date Mon, 14 May 2012 01:53:50 GMT
Author: buildbot
Date: Mon May 14 01:53:50 2012
New Revision: 817537

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 Mon May 14 01:53:50 2012
@@ -1 +1 @@
-1331869
+1338023

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 Mon May 14 01:53:50
2012
@@ -96,6 +96,7 @@
       <h2 id="examples">Examples</h2>
 <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-trystack">Create an OpenStack node using trystack.org
provider</h3>
 
@@ -133,6 +134,64 @@ OpenStack driver.</p>
 
 <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 trunk rev 1333307 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>
       
     </div>
 



Mime
View raw message