Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/zend/Zend/Service/Amazon/Ec2/Keypair.php
Go to the documentation of this file.
00001 <?php
00026 require_once 'Zend/Service/Amazon/Ec2/Abstract.php';
00027 
00037 class Zend_Service_Amazon_Ec2_Keypair extends Zend_Service_Amazon_Ec2_Abstract
00038 {
00047     public function create($keyName)
00048     {
00049         $params = array();
00050 
00051         $params['Action'] = 'CreateKeyPair';
00052 
00053         if(!$keyName) {
00054             require_once 'Zend/Service/Amazon/Ec2/Exception.php';
00055             throw new Zend_Service_Amazon_Ec2_Exception('Invalid Key Name');
00056         }
00057 
00058         $params['KeyName'] = $keyName;
00059 
00060         $response = $this->sendRequest($params);
00061         $xpath = $response->getXPath();
00062 
00063         $return = array();
00064         $return['keyName']          = $xpath->evaluate('string(//ec2:keyName/text())');
00065         $return['keyFingerprint']   = $xpath->evaluate('string(//ec2:keyFingerprint/text())');
00066         $return['keyMaterial']      = $xpath->evaluate('string(//ec2:keyMaterial/text())');
00067 
00068         return $return;
00069     }
00070 
00079     public function describe($keyName = null)
00080     {
00081         $params = array();
00082 
00083         $params['Action'] = 'DescribeKeyPairs';
00084         if(is_array($keyName) && !empty($keyName)) {
00085             foreach($keyName as $k=>$name) {
00086                 $params['KeyName.' . ($k+1)] = $name;
00087             }
00088         } elseif($keyName) {
00089             $params['KeyName.1'] = $keyName;
00090         }
00091 
00092         $response = $this->sendRequest($params);
00093         $xpath = $response->getXPath();
00094 
00095         $nodes  = $xpath->query('//ec2:keySet/ec2:item');
00096 
00097         $return = array();
00098         foreach ($nodes as $k => $node) {
00099             $item = array();
00100             $item['keyName']          = $xpath->evaluate('string(ec2:keyName/text())', $node);
00101             $item['keyFingerprint']   = $xpath->evaluate('string(ec2:keyFingerprint/text())', $node);
00102 
00103             $return[] = $item;
00104             unset($item);
00105         }
00106 
00107         return $return;
00108     }
00109 
00117     public function delete($keyName)
00118     {
00119         $params = array();
00120 
00121         $params['Action'] = 'DeleteKeyPair';
00122 
00123         if(!$keyName) {
00124             require_once 'Zend/Service/Amazon/Ec2/Exception.php';
00125             throw new Zend_Service_Amazon_Ec2_Exception('Invalid Key Name');
00126         }
00127 
00128         $params['KeyName'] = $keyName;
00129 
00130         $response = $this->sendRequest($params);
00131 
00132         $xpath = $response->getXPath();
00133         $success  = $xpath->evaluate('string(//ec2:return/text())');
00134 
00135         return ($success === "true");
00136     }
00137 }
 All Data Structures Namespaces Files Functions Variables Enumerations