[ 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 * Allows you to interface with the reserved instances on Amazon Ec2 30 * 31 * @category Zend 32 * @package Zend_Service_Amazon 33 * @subpackage Ec2 34 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 35 * @license http://framework.zend.com/license/new-bsd New BSD License 36 */ 37 class Zend_Service_Amazon_Ec2_Instance_Reserved extends Zend_Service_Amazon_Ec2_Abstract 38 { 39 /** 40 * Describes Reserved Instances that you purchased. 41 * 42 * @param string|array $instanceId IDs of the Reserved Instance to describe. 43 * @return array 44 */ 45 public function describeInstances($instanceId) 46 { 47 $params = array(); 48 $params['Action'] = 'DescribeReservedInstances'; 49 50 if(is_array($instanceId) && !empty($instanceId)) { 51 foreach($instanceId as $k=>$name) { 52 $params['ReservedInstancesId.' . ($k+1)] = $name; 53 } 54 } elseif($instanceId) { 55 $params['ReservedInstancesId.1'] = $instanceId; 56 } 57 58 $response = $this->sendRequest($params); 59 60 $xpath = $response->getXPath(); 61 $items = $xpath->query('//ec2:reservedInstancesSet/ec2:item'); 62 63 $return = array(); 64 foreach($items as $item) { 65 $i = array(); 66 $i['reservedInstancesId'] = $xpath->evaluate('string(ec2:reservedInstancesId/text())', $item); 67 $i['instanceType'] = $xpath->evaluate('string(ec2:instanceType/text())', $item); 68 $i['availabilityZone'] = $xpath->evaluate('string(ec2:availabilityZone/text())', $item); 69 $i['duration'] = $xpath->evaluate('string(ec2:duration/text())', $item); 70 $i['fixedPrice'] = $xpath->evaluate('string(ec2:fixedPrice/text())', $item); 71 $i['usagePrice'] = $xpath->evaluate('string(ec2:usagePrice/text())', $item); 72 $i['productDescription'] = $xpath->evaluate('string(ec2:productDescription/text())', $item); 73 $i['instanceCount'] = $xpath->evaluate('string(ec2:instanceCount/text())', $item); 74 $i['state'] = $xpath->evaluate('string(ec2:state/text())', $item); 75 76 $return[] = $i; 77 unset($i); 78 } 79 80 return $return; 81 } 82 83 /** 84 * Describes Reserved Instance offerings that are available for purchase. 85 * With Amazon EC2 Reserved Instances, you purchase the right to launch Amazon 86 * EC2 instances for a period of time (without getting insufficient capacity 87 * errors) and pay a lower usage rate for the actual time used. 88 * 89 * @return array 90 */ 91 public function describeOfferings() 92 { 93 $params = array(); 94 $params['Action'] = 'DescribeReservedInstancesOfferings'; 95 96 $response = $this->sendRequest($params); 97 98 $xpath = $response->getXPath(); 99 $items = $xpath->query('//ec2:reservedInstancesOfferingsSet/ec2:item'); 100 101 $return = array(); 102 foreach($items as $item) { 103 $i = array(); 104 $i['reservedInstancesOfferingId'] = $xpath->evaluate('string(ec2:reservedInstancesOfferingId/text())', $item); 105 $i['instanceType'] = $xpath->evaluate('string(ec2:instanceType/text())', $item); 106 $i['availabilityZone'] = $xpath->evaluate('string(ec2:availabilityZone/text())', $item); 107 $i['duration'] = $xpath->evaluate('string(ec2:duration/text())', $item); 108 $i['fixedPrice'] = $xpath->evaluate('string(ec2:fixedPrice/text())', $item); 109 $i['usagePrice'] = $xpath->evaluate('string(ec2:usagePrice/text())', $item); 110 $i['productDescription'] = $xpath->evaluate('string(ec2:productDescription/text())', $item); 111 112 $return[] = $i; 113 unset($i); 114 } 115 116 return $return; 117 } 118 119 /** 120 * Purchases a Reserved Instance for use with your account. With Amazon EC2 121 * Reserved Instances, you purchase the right to launch Amazon EC2 instances 122 * for a period of time (without getting insufficient capacity errors) and 123 * pay a lower usage rate for the actual time used. 124 * 125 * @param string $offeringId The offering ID of the Reserved Instance to purchase 126 * @param integer $intanceCount The number of Reserved Instances to purchase. 127 * @return string The ID of the purchased Reserved Instances. 128 */ 129 public function purchaseOffering($offeringId, $intanceCount = 1) 130 { 131 $params = array(); 132 $params['Action'] = 'PurchaseReservedInstancesOffering'; 133 $params['OfferingId.1'] = $offeringId; 134 $params['instanceCount.1'] = intval($intanceCount); 135 136 $response = $this->sendRequest($params); 137 138 $xpath = $response->getXPath(); 139 $reservedInstancesId = $xpath->evaluate('string(//ec2:reservedInstancesId/text())'); 140 141 return $reservedInstancesId; 142 } 143 }
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 |