Browse Source

Zend_Cloud documentation + unit test fix

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24699 44c647ce-9c0f-0410-b52a-842ac1e357ba
ezimuel 14 years ago
parent
commit
b7040b20e0

+ 26 - 0
documentation/manual/en/manual.xml.in

@@ -493,6 +493,17 @@
                     <xi:include href="../en/module_specs/Zend_Cloud_StorageService.xml" />
                 </xi:fallback>
             </xi:include>
+            <xi:include href="module_specs/Zend_Cloud_Infrastructure.xml">
+                <xi:fallback>
+                    <xi:include href="../en/module_specs/Zend_Cloud_Infrastructure.xml" />
+                </xi:fallback>
+            </xi:include>
+            <xi:include href="module_specs/Zend_Cloud_Infrastructure_Adapter.xml">
+                <xi:fallback>
+                    <xi:include href="../en/module_specs/Zend_Cloud_Infrastructure_Adapter.xml" />
+                </xi:fallback>
+            </xi:include>
+
         </chapter>
 
         <chapter id="zend.codegenerator">
@@ -1980,6 +1991,21 @@
                     <xi:include href="../en/module_specs/Zend_Service_Nirvanix.xml" />
                 </xi:fallback>
             </xi:include>
+            <xi:include href="module_specs/Zend_Service_Rackspace.xml">
+                <xi:fallback>
+                    <xi:include href="../en/module_specs/Zend_Service_Rackspace.xml" />
+                </xi:fallback>
+            </xi:include>
+            <xi:include href="module_specs/Zend_Service_Rackspace_Files.xml">
+                <xi:fallback>
+                    <xi:include href="../en/module_specs/Zend_Service_Rackspace_Files.xml" />
+                </xi:fallback>
+            </xi:include>
+            <xi:include href="module_specs/Zend_Service_Rackspace_Servers.xml">
+                <xi:fallback>
+                    <xi:include href="../en/module_specs/Zend_Service_Rackspace_Servers.xml" />
+                </xi:fallback>
+            </xi:include>
             <xi:include href="module_specs/Zend_Service-ReCaptcha.xml">
                 <xi:fallback>
                     <xi:include href="../en/module_specs/Zend_Service-ReCaptcha.xml" />

+ 592 - 0
documentation/manual/en/module_specs/Zend_Cloud_Infrastructure.xml

@@ -0,0 +1,592 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Reviewed: no -->
+<sect1 id="zend.cloud.infrastructure">
+    <title>Zend_Cloud_Infrastructure</title>
+
+    <sect2 id="zend.cloud.infrastructure.intro">
+        <title>Overview</title>
+
+        <para>
+            The <classname>Zend_Cloud_Infrastructure</classname> is a class to manage different
+            cloud computing infrastructures using a common <acronym>API</acronym>.
+        </para>
+        
+        <para>
+            In order to provide a common class API for different cloud vendors we implemented 
+            a small set of basic operations for the management of instances (servers) in a cloud infrastructure.
+            These basic operations are:
+        </para>
+
+        <itemizedlist>
+            <listitem>
+                <para>
+                    <emphasis>create a new instance</emphasis>;
+                </para>
+            </listitem>               
+            <listitem>
+                <para>
+                    <emphasis>delete a new instance</emphasis>;
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis>start/stop an instance</emphasis>;
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis>reboot an instance</emphasis>;
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis>list of the available instances</emphasis>;
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis>get the status of an instance</emphasis>;
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis>wait for a status change of an instance</emphasis>;
+                </para>
+            </listitem>  
+            <listitem>
+                <para>
+                    <emphasis>get the public IP or DNS name of the instance</emphasis>;
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis>list all the available images for new instances</emphasis>;
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis>list all the available geographical zones for new instances</emphasis>;
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis>monitor an instance getting the systems information (CPU%, RAM%, DISK%, NETWORK% usage)</emphasis>;
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis>deploy of an instance (run arbitrary shell script on an instance)</emphasis>;
+                </para>
+            </listitem>
+        </itemizedlist> 
+        
+        <note>
+            <title>Deployment of an instance</title>
+
+            <para>
+                For the deploy operations we used the <ulink url="http://www.php.net/manual/en/book.ssh2.php">
+                SSH2 PHP extension (ext/ssh2)</ulink> to connect on an instance and execute shell script.  The SSH2
+                extensions can be used to connect only to Gnu/Linux instances (servers).
+            </para>
+        </note>
+    
+        <para>
+            This class is managed by a factory to initialize specific cloud computing adapters.
+        </para>
+    </sect2>
+
+    <sect2 id="zend.cloud.infrastructure.quick-start">
+        <title>Quick Start</title>
+        
+        <para>
+            To use this class you have to initialize the factory with a specific adapters.  You can
+            check the supported apadters in the specific Chapter <link linkend="zend.cloud.infrastructure.adapter">Zend_Cloud_Infrastructure_Adapter</link>.
+            We are planning to support other cloud computing vendors very soon.
+        </para>
+        
+        <para>
+            For instance, to work with the AMAZON EC2 adapter you have to initialize the class with
+            following parameters:
+        </para>
+        
+         <programlisting language="php"><![CDATA[
+$key    = 'key';
+$secret = 'secret';
+$region = 'region';
+
+$infrastructure = Zend_Cloud_Infrastructure_Factory::getAdapter(array( 
+    Zend_Cloud_Infrastructure_Factory::INFRASTRUCTURE_ADAPTER_KEY => 'Zend_Cloud_Infrastructure_Adapter_Ec2', 
+    Zend_Cloud_Infrastructure_Adapter_Ec2::AWS_ACCESS_KEY => $key, 
+    Zend_Cloud_Infrastructure_Adapter_Ec2::AWS_SECRET_KEY => $secret,
+    Zend_Cloud_Infrastructure_Adapter_Ec2::AWS_REGION     => $region,
+)); 
+]]></programlisting>
+        
+        <para>
+            <classname>Zend_Cloud_Infrastructure</classname> has only a couple of methods that are vendor specific.
+            These methods are the creation of a new instance and the monitoring of an instance.
+            For instance, below is reported an example that shows how to create a new instance using the Amazon EC2 adapter:
+        </para>
+
+        <programlisting language="php"><![CDATA[
+$param= array (
+    'imageId'      => 'your-image-id',
+    'instanceType' => 'your-instance-type',
+);
+
+$instance= $infrastructure->createInstance('name of the instance', $param);
+
+printf ("Name of the instance: %s\n", $instance->getName());
+printf ("ID of the instance  : %s\n", $instance->getId());
+]]></programlisting>
+            
+        <para>
+            The interface of the <methodname>createInstance</methodname> is always the same, only
+            the content of <emphasis>$param</emphasis> is specific to the adapter.  for more
+            information about the adapter supported by Zend_Cloud_Infrastructure go to the specific
+            <link linkend="zend.cloud.infrastructure.adapter">page of the manual</link>.
+        </para>
+        
+        <para>
+            The <classname>Zend_Cloud_Infrastructure</classname> uses the classes
+            <classname>Zend_Cloud_Infrastructure_Instance</classname> and
+            <classname>Zend_Cloud_Infrastructure_Image</classname> to manage the instances (servers)
+            and the images of an instance. 
+        </para>
+    </sect2>
+ 
+    <sect2 id="zend.cloud.infrastructure.methods">
+        <title>Available Methods</title>
+ 
+        <variablelist>
+            <varlistentry id="zend.cloud.infrastructure.methods.create-instance">
+                <term>
+                    <methodsynopsis>
+                        <methodname>createInstance</methodname>
+                        <methodparam>
+                            <funcparams>string $name, array $options</funcparams>
+                        </methodparam>
+                    </methodsynopsis>
+                </term>
+                
+                <listitem>
+                    <para>
+                        Create an instance.
+                        The return value is an instance of <classname>Zend_Cloud_Infrastructure_Instance</classname>.
+                        In case of error the return is <emphasis>false</emphasis>.
+                    </para>
+                    <para>
+                        <emphasis>$name</emphasis> is the name of the instance to create
+                    </para>
+                    <para>
+                        <emphasis>$options</emphasis> is the array contains the specific parameter for the cloud adapter.
+                        For more info read the Chapter of <link linkend="zend.cloud.infrastructure.adapter">Zend_Cloud_Infrastructure_Adapter</link>.
+                    </para>
+                </listitem>
+            </varlistentry>
+            
+            <varlistentry id="zend.cloud.infrastructure.methods.deploy-instance">
+                <term>
+                    <methodsynopsis>
+                        <methodname>deployInstance</methodname>
+                        <methodparam>
+                            <funcparams>string $id, array $param, string|array $cmd</funcparams>
+                        </methodparam>
+                    </methodsynopsis>
+                </term>
+                
+                <listitem>
+                    <para>
+                        Run arbitrary shell scripts on an instance.
+                        Return a string or an array contains all the standard output (errors included) of the scripts executed in the instance.
+                        <note><title>Requirement</title>
+                            
+                            <para>
+                                In order to use the deployInstance method you have to install the SSH2 extension (ext/ssh2) of PHP.
+                                The SSH2 extensions can be used to connect only to Gnu/Linux instances (servers).
+                                For more info about the SSH2 extension, <ulink url="http://www.php.net/manual/en/book.ssh2.php">click here</ulink>.
+                            </para>
+                        </note>
+                    </para>
+                    <para>
+                        <emphasis>$id</emphasis> is the ID of the instance
+                    </para>    
+                    <para>
+                        <emphasis>$param</emphasis> is an array contains the username and the password to be used for the SSH connection.
+                        The username and the password must be specified using the following constants key of the <classname>Zend_Cloud_Infrastructure_Instance</classname>: 
+                        SSH_USERNAME, SSH_PASSWORD.
+                    </para> 
+                    <para>
+                        <emphasis>$cmd</emphasis> is a string (or an array) contains the commands line to be executed in the instance.
+                    </para> 
+                </listitem>
+            </varlistentry>
+            
+            <varlistentry id="zend.cloud.infrastructure.methods.destroy-instance">
+                <term>
+                    <methodsynopsis>
+                        <methodname>destroyInstance</methodname>
+                        <methodparam>
+                            <funcparams>string $id</funcparams>
+                        </methodparam>
+                    </methodsynopsis>
+                </term>
+                
+                <listitem>
+                    <para>
+                        Destroy an instance.
+                        Return <emphasis>true</emphasis> in case of success, <emphasis>false</emphasis> in case of error.
+                    </para>
+                    <para>
+                        <emphasis>$id</emphasis> is the ID of the instance
+                    </para>    
+                </listitem>
+            </varlistentry>
+            
+            <varlistentry id="zend.cloud.infrastructure.methods.get-adapter">
+                <term>
+                    <methodsynopsis>
+                        <methodname>getAdapter</methodname>
+                        <methodparam>
+                            <funcparams/>
+                        </methodparam>
+                    </methodsynopsis>
+                </term>
+                
+                <listitem>
+                    <para>
+                        Return the adapter object.
+                    </para>    
+                </listitem>
+            </varlistentry>
+            
+            <varlistentry id="zend.cloud.infrastructure.methods.get-adapter-result">
+                <term>
+                    <methodsynopsis>
+                        <methodname>getAdapterResult</methodname>
+                        <methodparam>
+                            <funcparams/>
+                        </methodparam>
+                    </methodsynopsis>
+                </term>
+                
+                <listitem>
+                    <para>
+                        Return the original adapter result.
+                    </para>    
+                </listitem>
+            </varlistentry>
+            
+            <varlistentry id="zend.cloud.infrastructure.methods.get-last-http-request">
+                <term>
+                    <methodsynopsis>
+                        <methodname>getLastHttpRequest</methodname>
+                        <methodparam>
+                            <funcparams/>
+                        </methodparam>
+                    </methodsynopsis>
+                </term>
+                
+                <listitem>
+                    <para>
+                        Return the last HTTP Request of the adapter.
+                    </para>    
+                </listitem>
+            </varlistentry>
+            
+             <varlistentry id="zend.cloud.infrastructure.methods.get-last-http-response">
+                <term>
+                    <methodsynopsis>
+                        <methodname>getLastHttpResponse</methodname>
+                        <methodparam>
+                            <funcparams/>
+                        </methodparam>
+                    </methodsynopsis>
+                </term>
+                
+                <listitem>
+                    <para>
+                        Return the last HTTP Response of the adapter.
+                    </para>    
+                </listitem>
+            </varlistentry>
+            
+            <varlistentry id="zend.cloud.infrastructure.methods.images-instance">
+                <term>
+                    <methodsynopsis>
+                        <methodname>imagesInstance</methodname>
+                        <methodparam>
+                            <funcparams/>
+                        </methodparam>
+                    </methodsynopsis>
+                </term>
+                
+                <listitem>
+                    <para>
+                        Return all the available images to use for an instance.
+                        The return value is an instance of <classname>Zend_Cloud_Infrastructure_ImageList</classname>
+                    </para>
+                </listitem>
+            </varlistentry>
+            
+            <varlistentry id="zend.cloud.infrastructure.methods.list-instances">
+                <term>
+                    <methodsynopsis>
+                        <methodname>listInstances</methodname>
+                        <methodparam>
+                            <funcparams/>
+                        </methodparam>
+                    </methodsynopsis>
+                </term>
+                
+                <listitem>
+                    <para>
+                        Return the list of of the available instances. 
+                        The return is an instance of <classname>Zend_Cloud_Infrastructure_InstanceList</classname>.
+                    </para>
+                </listitem>
+            </varlistentry>
+            
+            <varlistentry id="zend.cloud.infrastructure.methods.monitor-instance">
+                <term>
+                    <methodsynopsis>
+                        <methodname>monitorInstance</methodname>
+                        <methodparam>
+                            <funcparams>string $id,string $metric,array $options=null</funcparams>
+                        </methodparam>
+                    </methodsynopsis>
+                </term>
+                
+                <listitem>
+                    <para>
+                        Monitor an instance. Return the system information about the metric of an instance.
+                        The return value is an array that contains samples of values, timestamp and the elaboration of the average value.
+                    </para>
+                    <para>
+                        <emphasis>$id</emphasis> is the ID of the instance;
+                    </para>
+                    <para>
+                        <emphasis>$metric</emphasis> is the metric to be monitored. The allowed metrics are reported as contants of the
+                        <classname>Zend_Cloud_Infrastructure_Instance</classname> class: MONITOR_CPU, MONITOR_RAM,
+                        MONITOR_NETWORK_IN, MONITOR_NETWORK_OUT, MONITOR_DISK, MONITOR_DISK_WRITE, MONITOR_DISK_READ.                       
+                    </para>
+                    <para>
+                        <emphasis>$options</emphasis> is the optional array contains the adapter specific options.
+                    </para>
+                </listitem>
+            </varlistentry>
+            
+             <varlistentry id="zend.cloud.infrastructure.methods.public-dns-instance">
+                <term>
+                    <methodsynopsis>
+                        <methodname>publicDnsInstance</methodname>
+                        <methodparam>
+                            <funcparams>string $id</funcparams>
+                        </methodparam>
+                    </methodsynopsis>
+                </term>
+                
+                <listitem>
+                    <para>
+                        Return the public DNS name or the IP address of the instance. The return value is a string.
+                        In case of error the return is <emphasis>false</emphasis>.
+                    </para>
+                    <para>
+                        <emphasis>$id</emphasis> is the ID of the instance
+                    </para>    
+                </listitem>
+            </varlistentry>
+            
+            <varlistentry id="zend.cloud.infrastructure.methods.reboot-instance">
+                <term>
+                    <methodsynopsis>
+                        <methodname>rebootInstance</methodname>
+                        <methodparam>
+                            <funcparams>string $id</funcparams>
+                        </methodparam>
+                    </methodsynopsis>
+                </term>
+                
+                <listitem>
+                    <para>
+                        Reboot an instance. 
+                        Return <emphasis>true</emphasis> in case of success, <emphasis>false</emphasis> in case of error.
+                    </para>
+                    <para>
+                        <emphasis>$id</emphasis> is the ID of the instance
+                    </para>    
+                </listitem>
+            </varlistentry>
+            
+            <varlistentry id="zend.cloud.infrastructure.methods.start-instance">
+                <term>
+                    <methodsynopsis>
+                        <methodname>startInstance</methodname>
+                        <methodparam>
+                            <funcparams>string $id</funcparams>
+                        </methodparam>
+                    </methodsynopsis>
+                </term>
+                
+                <listitem>
+                    <para>
+                        Start an instance.
+                        Return <emphasis>true</emphasis> in case of success, <emphasis>false</emphasis> in case of error.
+                    </para>
+                    <para>
+                        <emphasis>$id</emphasis> is the ID of the instance
+                    </para>    
+                </listitem>
+            </varlistentry>
+            
+            <varlistentry id="zend.cloud.infrastructure.methods.status-instance">
+                <term>
+                    <methodsynopsis>
+                        <methodname>statusInstance</methodname>
+                        <methodparam>
+                            <funcparams>string $id</funcparams>
+                        </methodparam>
+                    </methodsynopsis>
+                </term>
+                
+                <listitem>
+                    <para>
+                        Get the status of an instance. The return value is a string. 
+                        The available status are reported in the following constants of the class <classname>Zend_Cloud_Infrastructure_Instance</classname>:
+                        STATUS_STOPPED, STATUS_RUNNING, STATUS_SHUTTING_DOWN, STATUS_REBOOTING,
+                        STATUS_TERMINATED, STATUS_PENDING, STATUS_REBUILD.
+                        In case of error the return is <emphasis>false</emphasis>.
+                    </para>
+                    <para>
+                        <emphasis>$id</emphasis> is the ID of the instance
+                    </para>    
+                </listitem>
+            </varlistentry>
+            
+            <varlistentry id="zend.cloud.infrastructure.methods.stop-instance">
+                <term>
+                    <methodsynopsis>
+                        <methodname>stopInstance</methodname>
+                        <methodparam>
+                            <funcparams>string $id</funcparams>
+                        </methodparam>
+                    </methodsynopsis>
+                </term>
+                
+                <listitem>
+                    <para>
+                        Stop an instance.
+                        Return <emphasis>true</emphasis> in case of success, <emphasis>false</emphasis> in case of error.
+                    </para>
+                    <para>
+                        <emphasis>$id</emphasis> is the ID of the instance
+                    </para>    
+                </listitem>
+            </varlistentry>
+            
+            <varlistentry id="zend.cloud.infrastructure.methods.wait-status-instance">
+                <term>
+                    <methodsynopsis>
+                        <methodname>waitStatusInstance</methodname>
+                        <methodparam>
+                            <funcparams>string $id, string $status,integer $timeout=30</funcparams>
+                        </methodparam>
+                    </methodsynopsis>
+                </term>
+                
+                <listitem>
+                    <para>
+                        Wait the status change of an instance for a maximum time of <emphasis>n</emphasis> seconds.
+                        Return <emphasis>true</emphasis> if the status changes as expected, <emphasis>false</emphasis> if not.
+                    </para>
+                    <para>
+                        <emphasis>$id</emphasis> is the ID of the instance;
+                    </para>    
+                    <para>
+                        <emphasis>$status</emphasis> is the status to wait for;
+                    </para>
+                    <para>
+                        <emphasis>$timeout</emphasis> is the maximum time, in seconds, to wait for the status change. This parametr is optional and the default value is 30 seconds.
+                    </para>
+                </listitem>
+            </varlistentry>
+            
+            <varlistentry id="zend.cloud.infrastructure.methods.zones-instance">
+                <term>
+                    <methodsynopsis>
+                        <methodname>zonesInstance</methodname>
+                        <methodparam>
+                            <funcparams/>
+                        </methodparam>
+                    </methodsynopsis>
+                </term>
+                
+                <listitem>
+                    <para>
+                        Return all the available zones for an instance.
+                        The return value is an array.
+                    </para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+    </sect2>
+ 
+    <sect2 id="zend.cloud.infrastructure.examples">
+        <title>Examples</title>
+        
+        <example id="zend.cloud.infrastructure.examples.authenticate">
+            <title>Get the datetime system information of an instance</title>
+            
+            <para>Get the result of the <emphasis>date</emphasis> command line.</para>
+ 
+            <programlisting language="php"><![CDATA[
+$param = array (
+    Instance::SSH_USERNAME => 'username',
+    Instance::SSH_PASSWORD => 'password',
+);
+
+$cmd    = 'date';
+$output = $infrastructure->deployInstance('instance-id', $param, $cmd);
+
+echo $output;
+]]></programlisting>
+        </example>
+        
+        <example id="zend.cloud.infrastructure.examples.get-datetime">
+            <title>Get the datetime system information of an instance</title>
+ 
+            <para>Get the result of the <emphasis>date</emphasis> command line.</para>
+ 
+            <programlisting language="php"><![CDATA[
+$param = array (
+    Instance::SSH_USERNAME => 'username',
+    Instance::SSH_PASSWORD => 'password',
+);
+
+$cmd    = 'date';
+$output = $infrastructure->deployInstance('instance-id', $param, $cmd);
+
+echo $output;
+]]></programlisting>
+        </example>
+        
+        <example id="zend.cloud.infrastructure.examples.reboot">
+            <title>Reboot an instance and wait for the running status</title>
+ 
+            <para>Reboot an instance and wait 60 seconds for the running status.</para>
+ 
+            <programlisting language="php"><![CDATA[
+if (!$infrastructure->rebootInstance('instance-id')) {
+    die ('Error in the execution of the reboot command');
+}
+echo 'Reboot command executed successfully';
+
+if ($rackspace->waitStatusInstance('instance-id', Zend_Cloud_Infrastructure_Instance::STATUS_RUNNING, 60)) {
+    echo 'The instance is ready';
+} else {
+    echo 'The instance is not ready yet';
+}
+]]></programlisting>
+        </example>
+    </sect2>
+</sect1>

+ 159 - 0
documentation/manual/en/module_specs/Zend_Cloud_Infrastructure_Adapter.xml

@@ -0,0 +1,159 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Reviewed: no -->
+<sect1 id="zend.cloud.infrastructure.adapter">
+    <title>Zend_Cloud_Infrastructure_Adapter</title>
+
+    <sect2 id="zend.cloud.infrastructure.adapter.intro">
+        <title>Adapters</title>
+
+        <para>
+            The <classname>Zend_Cloud_Infrastructure</classname> supports the following adapters:
+        </para>
+
+        <itemizedlist>
+            <listitem>
+                <para>
+                    <ulink url="http://aws.amazon.com/ec2/">Amazon EC2</ulink>;
+                </para>
+            </listitem>  
+
+            <listitem>
+                <para>
+                    <ulink url="http://www.rackspace.com/cloud/cloud_hosting_products/servers/">Rackspace Cloud Servers</ulink>.
+                </para>
+            </listitem>
+        </itemizedlist>    
+    </sect2>    
+    
+    <sect2 id="zend.cloud.infrastructure.adapter.ec2">
+        <title>AMAZON EC2</title>
+
+        <para>
+            To initialize the AMAZON EC2 adapter you have to use the following code:
+        </para>
+        
+         <programlisting language="php"><![CDATA[
+$key    = 'key';
+$secret = 'secret';
+$region = 'region';
+
+$infrastructure = Zend_Cloud_Infrastructure_Factory::getAdapter(array( 
+    Zend_Cloud_Infrastructure_Factory::INFRASTRUCTURE_ADAPTER_KEY => 'Zend_Cloud_Infrastructure_Adapter_Ec2', 
+    Zend_Cloud_Infrastructure_Adapter_Ec2::AWS_ACCESS_KEY => $key, 
+    Zend_Cloud_Infrastructure_Adapter_Ec2::AWS_SECRET_KEY => $secret,
+    Zend_Cloud_Infrastructure_Adapter_Ec2::AWS_REGION     => $region,
+)); 
+]]></programlisting>
+
+        <para>
+            To create a new instance for AMAZON EC2 adapter you have to use the following parameters:
+        </para>
+        
+        <programlisting language="php"><![CDATA[
+$param = array (
+    'imageId'      => 'your-image-id',
+    'instanceType' => 'your-instance-type',
+);
+
+$instance = $infrastructure->createInstance('name of the instance', $param);
+
+printf("Name of the instance: %s\n", $instance->getName());
+printf("ID of the instance  : %s\n", $instance->getId());
+]]></programlisting>
+
+        <para>
+            The monitor an instance of AMAZON EC2 you can use the starting time and ending time optional parameters.
+            The times must be specified using the ISO 8601 format.
+        </para>
+        
+        <programlisting language="php"><![CDATA[
+$options= array (
+    Instance::MONITOR_START_TIME => '2008-02-26T19:00:00+00:00',
+    Instance::MONITOR_END_TIME   => '2008-02-26T20:00:00+00:00',
+);
+
+$cpuUsage= $infrastructure->monitorInstance('id-instance', Zend_Cloud_Infrastructure_Instance::MONITOR_CPU, $options);
+
+print_r($cpuUsage);
+]]></programlisting>
+
+        <para>
+            The <emphasis>instanceType</emphasis> parameter is optional. This parameter specify the
+            type of the instance to create (for instance, 't1.micro').
+        </para>
+    </sect2> 
+    
+    <sect2 id="zend.cloud.infrastructure.adapter.rackspace">
+        <title>Rackspace Cloud Servers</title>
+
+        <para>
+            To initialize the Rackspace Cloud Servers adapter you have to use the following code:
+        </para>
+        
+        <programlisting language="php"><![CDATA[
+$user = 'username';
+$key  = 'API key';
+
+$infrastructure = Zend_Cloud_Infrastructure_Factory::getAdapter(array( 
+    Zend_Cloud_Infrastructure_Factory::INFRASTRUCTURE_ADAPTER_KEY => 'Zend_Cloud_Infrastructure_Adapter_Rackspace', 
+    Zend_Cloud_Infrastructure_Adapter_Rackspace::RACKSPACE_USER => $user, 
+    Zend_Cloud_Infrastructure_Adapter_Rackspace::RACKSPACE_KEY  => $key,
+)); 
+]]></programlisting>
+
+        <para>
+            To create a new instance for Rackspace Cloud Servers adapter you have to use the
+            following parameters:
+        </para>
+        
+        <programlisting language="php"><![CDATA[
+$param = array (
+    'imageId'  => 'image-id-of-the-instance',
+    'flavorId' => 'flavor-id-of-the-instance',
+    'metadata' => array (
+        'foo' => 'bar',
+    ),
+    'file' => array (
+        'remote-instance-path' => 'local-path',
+    ),
+);
+
+$instance = $infrastructure->createInstance('name of the instance', $param);
+
+printf("Name of the instance: %s\n", $instance->getName());
+printf("ID of the instance  : %s\n", $instance->getId());
+]]></programlisting>
+
+        <para>
+            The <emphasis>metadata</emphasis> array and the <emphasis>file</emphasis> array are
+            optional parameters.
+        </para>
+        
+        <para>
+            To monitor an instance of Rackspace Cloud Servers we can use only the SSH2 extension.
+            The Rackspace API does not offer a dedicated service to monitor the instance.  The
+            monitoring features using the SSH2 connection are limited to the CPU usage, the RAM
+            usage and the DISK usage.
+        </para>
+        
+        <programlisting language="php"><![CDATA[
+$options = array (
+    'username' => 'your-username',
+    'password' => 'your-password',
+);
+
+$cpuUsage  = $infrastructure->monitorInstance('id-instance', Instance::MONITOR_CPU, $options);
+$ramUsage  = $infrastructure->monitorInstance('id-instance', Instance::MONITOR_RAM, $options);
+$diskUsage = $infrastructure->monitorInstance('id-instance', Instance::MONITOR_DISK, $options);
+
+print_r($cpuUsage);
+print_r($ramUsage);
+print_r($diskUsage);
+]]></programlisting>
+        
+        <para>
+            The <emphasis>$options</emphasis> contains the username and the password to be used for
+            the SSH connection.
+        </para>    
+    </sect2> 
+</sect1>

+ 0 - 1
library/Zend/Cloud/Infrastructure/Adapter/Rackspace.php

@@ -148,7 +148,6 @@ class Zend_Cloud_Infrastructure_Adapter_Rackspace extends Zend_Cloud_Infrastruct
             $this->rackspace->getHttpClient()->setAdapter($options[self::HTTP_ADAPTER]);
         }
         
-        $this->flavors= $this->rackspace->listFlavors(true);
     }
     /**
      * Convert the attributes of Rackspace server into attributes of Infrastructure

+ 1 - 3
library/Zend/Cloud/Infrastructure/Instance.php

@@ -70,9 +70,7 @@ class Zend_Cloud_Infrastructure_Instance
         self::INSTANCE_ID,
         self::INSTANCE_STATUS,
         self::INSTANCE_IMAGEID,
-        self::INSTANCE_ZONE,
-        self::INSTANCE_RAM,
-        self::INSTANCE_STORAGE,
+        self::INSTANCE_ZONE
     );
 
     /**

+ 3 - 0
tests/TestConfiguration.php.dist

@@ -812,6 +812,9 @@ defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_GENERATE_REPORT_TARGET') || define('TES
 /**
  * Proxy settings used by Zend_Cloud
  */
+defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_ACCOUNTNAME') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_ACCOUNTNAME','');
+defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_ACCOUNTKEY') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_ACCOUNTKEY','');
+defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_TABLE_HOST') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_TABLE_HOST','');
 defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_STORAGE_USEPROXY') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_STORAGE_USEPROXY',          false);
 defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_STORAGE_PROXY_HOST') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_STORAGE_PROXY_HOST',        '');
 defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_STORAGE_PROXY_PORT') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_STORAGE_PROXY_PORT',        '8080');

+ 9 - 20
tests/Zend/Cloud/Infrastructure/Adapter/RackspaceTest.php

@@ -57,9 +57,9 @@ class Zend_Cloud_Infrastructure_Adapter_RackspaceTest extends PHPUnit_Framework_
     {
         $this->infrastructure = Zend_Cloud_Infrastructure_Factory::getAdapter(array( 
             Zend_Cloud_Infrastructure_Factory::INFRASTRUCTURE_ADAPTER_KEY => 'Zend_Cloud_Infrastructure_Adapter_Rackspace', 
-            Zend_Cloud_Infrastructure_Adapter_Rackspace::RACKSPACE_USER   => constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_USER'), 
-            Zend_Cloud_Infrastructure_Adapter_Rackspace::RACKSPACE_KEY    => constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_KEY'), 
-            Zend_Cloud_Infrastructure_Adapter_Rackspace::RACKSPACE_REGION => constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_REGION')   
+            Zend_Cloud_Infrastructure_Adapter_Rackspace::RACKSPACE_USER   => 'foo', 
+            Zend_Cloud_Infrastructure_Adapter_Rackspace::RACKSPACE_KEY    => 'bar', 
+            Zend_Cloud_Infrastructure_Adapter_Rackspace::RACKSPACE_REGION => 'USA'   
         )); 
 
         $this->httpClientAdapterTest = new Zend_Http_Client_Adapter_Test();
@@ -69,10 +69,15 @@ class Zend_Cloud_Infrastructure_Adapter_RackspaceTest extends PHPUnit_Framework_
                              ->setAdapter($this->httpClientAdapterTest);
         
         // load the HTTP response (from a file)
-        $shortClassName = substr(__CLASS__,strlen('Zend_Cloud_Infrastructure_Adapter_'));
+        $shortClassName = 'RackspaceTest';
         $filename= dirname(__FILE__) . '/_files/' . $shortClassName . '_'. $this->getName().'.response';
         
         if (file_exists($filename)) {
+            // authentication (from file)
+            $content = file_get_contents(dirname(__FILE__) . '/_files/'.$shortClassName . '_testAuthenticate.response');
+            $this->httpClientAdapterTest->setResponse($content);
+            $this->assertTrue($this->infrastructure->getAdapter()->authenticate(),'Authentication failed');
+            
             $this->httpClientAdapterTest->setResponse($this->loadResponse($filename)); 
         }
         
@@ -150,22 +155,6 @@ class Zend_Cloud_Infrastructure_Adapter_RackspaceTest extends PHPUnit_Framework_
         $this->assertEquals(constant('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_IMAGEID'), $instance->getImageId());
     }
     /**
-     * Test last HTTP request
-     */
-    public function testGetLastHttpRequest()
-    {
-        $lastHttpRequest = $this->infrastructure->getLastHttpRequest();
-        $this->assertTrue(!empty($lastHttpRequest));
-    }
-    /**
-     * Test last HTTP response
-     */
-    public function testGetLastHttpResponse()
-    {
-        $lastHttpResponse = $this->infrastructure->getLastHttpResponse();
-        $this->assertTrue(!empty($lastHttpResponse));
-    }
-    /**
      * Test list of an instance
      */
     public function testListInstance()

+ 11 - 0
tests/Zend/Cloud/Infrastructure/Adapter/_files/RackspaceTest_testAuthenticate.response

@@ -0,0 +1,11 @@
+HTTP/1.1 204 No Content
+Date: Wed, 11 May 2011 08:04:48 GMT
+Server: Apache/2.2.3 (Mosso Engineering)
+X-storage-url: https://storage101.ord1.clouddrive.com/v1/test
+X-storage-token: 0f0223cd-f157-4d04-bb2d-ccda1a5643af
+X-cdn-management-url: https://cdn2.clouddrive.com/v1/test
+X-auth-token: 0f0223cd-f157-4d04-bb2d-ccda1a5643af
+X-server-management-url: https://servers.api.rackspacecloud.com/v1.0/583924
+Content-length: 0
+Connection: close
+Content-type: application/octet-stream

+ 10 - 10
tests/Zend/Cloud/Infrastructure/TestCase.php

@@ -93,16 +93,16 @@ abstract class Zend_Cloud_Infrastructure_TestCase extends PHPUnit_Framework_Test
         $this->assertEquals('shutting-down', Zend_Cloud_Infrastructure_Instance::STATUS_SHUTTING_DOWN);
         $this->assertEquals('rebooting', Zend_Cloud_Infrastructure_Instance::STATUS_REBOOTING);
         $this->assertEquals('terminated', Zend_Cloud_Infrastructure_Instance::STATUS_TERMINATED);
-        $this->assertEquals('id', Zend_Cloud_Infrastructure_Instance::Zend_Cloud_Infrastructure_Instance_ID);
-        $this->assertEquals('imageId', Zend_Cloud_Infrastructure_Instance::Zend_Cloud_Infrastructure_Instance_IMAGEID);
-        $this->assertEquals('name', Zend_Cloud_Infrastructure_Instance::Zend_Cloud_Infrastructure_Instance_NAME);
-        $this->assertEquals('status', Zend_Cloud_Infrastructure_Instance::Zend_Cloud_Infrastructure_Instance_STATUS);
-        $this->assertEquals('publicDns', Zend_Cloud_Infrastructure_Instance::Zend_Cloud_Infrastructure_Instance_PUBLICDNS);
-        $this->assertEquals('cpu', Zend_Cloud_Infrastructure_Instance::Zend_Cloud_Infrastructure_Instance_CPU);
-        $this->assertEquals('ram', Zend_Cloud_Infrastructure_Instance::Zend_Cloud_Infrastructure_Instance_RAM);
-        $this->assertEquals('storageSize', Zend_Cloud_Infrastructure_Instance::Zend_Cloud_Infrastructure_Instance_STORAGE);
-        $this->assertEquals('zone', Zend_Cloud_Infrastructure_Instance::Zend_Cloud_Infrastructure_Instance_ZONE);
-        $this->assertEquals('launchTime', Zend_Cloud_Infrastructure_Instance::Zend_Cloud_Infrastructure_Instance_LAUNCHTIME);
+        $this->assertEquals('id', Zend_Cloud_Infrastructure_Instance::INSTANCE_ID);
+        $this->assertEquals('imageId', Zend_Cloud_Infrastructure_Instance::INSTANCE_IMAGEID);
+        $this->assertEquals('name', Zend_Cloud_Infrastructure_Instance::INSTANCE_NAME);
+        $this->assertEquals('status', Zend_Cloud_Infrastructure_Instance::INSTANCE_STATUS);
+        $this->assertEquals('publicDns', Zend_Cloud_Infrastructure_Instance::INSTANCE_PUBLICDNS);
+        $this->assertEquals('cpu', Zend_Cloud_Infrastructure_Instance::INSTANCE_CPU);
+        $this->assertEquals('ram', Zend_Cloud_Infrastructure_Instance::INSTANCE_RAM);
+        $this->assertEquals('storageSize', Zend_Cloud_Infrastructure_Instance::INSTANCE_STORAGE);
+        $this->assertEquals('zone', Zend_Cloud_Infrastructure_Instance::INSTANCE_ZONE);
+        $this->assertEquals('launchTime', Zend_Cloud_Infrastructure_Instance::INSTANCE_LAUNCHTIME);
         $this->assertEquals('CpuUsage', Zend_Cloud_Infrastructure_Instance::MONITOR_CPU);
         $this->assertEquals('NetworkIn', Zend_Cloud_Infrastructure_Instance::MONITOR_NETWORK_IN);
         $this->assertEquals('NetworkOut', Zend_Cloud_Infrastructure_Instance::MONITOR_NETWORK_OUT);

+ 3 - 2
tests/Zend/Cloud/QueueService/TestCase.php

@@ -54,7 +54,8 @@ abstract class Zend_Cloud_QueueService_TestCase extends PHPUnit_Framework_TestCa
     protected $_commonQueue;
     protected $_dummyNamePrefix = '/TestItem';
     protected $_dummyDataPrefix = 'TestData';
-	protected $_clientType = 'stdClass';
+    protected $_clientType = 'stdClass';
+    
     /**
      * Config object
      *
@@ -79,7 +80,7 @@ abstract class Zend_Cloud_QueueService_TestCase extends PHPUnit_Framework_TestCa
 
     public function testGetClient()
     {
-    	$this->assertTrue(is_a($this->_commonQueue->getClient(), $this->_clientType));
+    	$this->assertTrue($this->_commonQueue->getClient() instanceof $this->_clientType);
     }
 
     public function testCreateQueue()