[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Zend Framework 4 * 5 * LICENSE 6 * 7 * This source file is subject to the new BSD license that is bundled 8 * with this package in the file LICENSE.txt. 9 * It is also available through the world-wide-web at this URL: 10 * http://framework.zend.com/license/new-bsd 11 * If you did not receive a copy of the license and are unable to 12 * obtain it through the world-wide-web, please send an email 13 * to [email protected] so we can send you a copy immediately. 14 * 15 * @category Zend 16 * @package Zend_Service_Amazon 17 * @subpackage Ec2 18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 19 * @license http://framework.zend.com/license/new-bsd New BSD License 20 * @version $Id$ 21 */ 22 23 /** 24 * @see Zend_Service_Amazon_Ec2_Abstract 25 */ 26 require_once 'Zend/Service/Amazon/Ec2/Abstract.php'; 27 28 /** 29 * An Amazon EC2 interface to allocate, associate, describe and release Elastic IP address 30 * from your account. 31 * 32 * @category Zend 33 * @package Zend_Service_Amazon 34 * @subpackage Ec2 35 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 36 * @license http://framework.zend.com/license/new-bsd New BSD License 37 */ 38 class Zend_Service_Amazon_Ec2_Elasticip extends Zend_Service_Amazon_Ec2_Abstract 39 { 40 /** 41 * Acquires an elastic IP address for use with your account 42 * 43 * @return string Returns the newly Allocated IP Address 44 */ 45 public function allocate() 46 { 47 $params = array(); 48 $params['Action'] = 'AllocateAddress'; 49 50 $response = $this->sendRequest($params); 51 52 $xpath = $response->getXPath(); 53 $ip = $xpath->evaluate('string(//ec2:publicIp/text())'); 54 55 return $ip; 56 } 57 58 /** 59 * Lists elastic IP addresses assigned to your account. 60 * 61 * @param string|array $publicIp Elastic IP or list of addresses to describe. 62 * @return array 63 */ 64 public function describe($publicIp = null) 65 { 66 $params = array(); 67 $params['Action'] = 'DescribeAddresses'; 68 69 if(is_array($publicIp) && !empty($publicIp)) { 70 foreach($publicIp as $k=>$name) { 71 $params['PublicIp.' . ($k+1)] = $name; 72 } 73 } elseif($publicIp) { 74 $params['PublicIp.1'] = $publicIp; 75 } 76 77 $response = $this->sendRequest($params); 78 79 $xpath = $response->getXPath(); 80 $nodes = $xpath->query('//ec2:item'); 81 82 $return = array(); 83 foreach ($nodes as $k => $node) { 84 $item = array(); 85 $item['publicIp'] = $xpath->evaluate('string(ec2:publicIp/text())', $node); 86 $item['instanceId'] = $xpath->evaluate('string(ec2:instanceId/text())', $node); 87 88 $return[] = $item; 89 unset($item); 90 } 91 92 return $return; 93 } 94 95 /** 96 * Releases an elastic IP address that is associated with your account 97 * 98 * @param string $publicIp IP address that you are releasing from your account. 99 * @return boolean 100 */ 101 public function release($publicIp) 102 { 103 $params = array(); 104 $params['Action'] = 'ReleaseAddress'; 105 $params['PublicIp'] = $publicIp; 106 107 $response = $this->sendRequest($params); 108 $xpath = $response->getXPath(); 109 110 $return = $xpath->evaluate('string(//ec2:return/text())'); 111 112 return ($return === "true"); 113 } 114 115 /** 116 * Associates an elastic IP address with an instance 117 * 118 * @param string $instanceId The instance to which the IP address is assigned 119 * @param string $publicIp IP address that you are assigning to the instance. 120 * @return boolean 121 */ 122 public function associate($instanceId, $publicIp) 123 { 124 $params = array(); 125 $params['Action'] = 'AssociateAddress'; 126 $params['PublicIp'] = $publicIp; 127 $params['InstanceId'] = $instanceId; 128 129 $response = $this->sendRequest($params); 130 $xpath = $response->getXPath(); 131 132 $return = $xpath->evaluate('string(//ec2:return/text())'); 133 134 return ($return === "true"); 135 } 136 137 /** 138 * Disassociates the specified elastic IP address from the instance to which it is assigned. 139 * This is an idempotent operation. If you enter it more than once, Amazon EC2 does not return an error. 140 * 141 * @param string $publicIp IP address that you are disassociating from the instance. 142 * @return boolean 143 */ 144 public function disassocate($publicIp) 145 { 146 $params = array(); 147 $params['Action'] = 'DisssociateAddress'; 148 $params['PublicIp'] = $publicIp; 149 150 $response = $this->sendRequest($params); 151 $xpath = $response->getXPath(); 152 153 $return = $xpath->evaluate('string(//ec2:return/text())'); 154 155 return ($return === "true"); 156 } 157 158 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |