当前位置: 首页>>代码示例>>PHP>>正文


PHP Amazon_EC2_Interface::requestSpotInstances方法代码示例

本文整理汇总了PHP中Amazon_EC2_Interface::requestSpotInstances方法的典型用法代码示例。如果您正苦于以下问题:PHP Amazon_EC2_Interface::requestSpotInstances方法的具体用法?PHP Amazon_EC2_Interface::requestSpotInstances怎么用?PHP Amazon_EC2_Interface::requestSpotInstances使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Amazon_EC2_Interface的用法示例。


在下文中一共展示了Amazon_EC2_Interface::requestSpotInstances方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: invokeRequestSpotInstances

/**
 * Request Spot Instances Action Sample
 * Creates a Spot Instance request. Spot Instances are instances that automatically launch when your
 * request price exceeds the Spot Price that Amazon EC2 periodically calculates.  
 * @param Amazon_EC2_Interface $service instance of Amazon_EC2_Interface
 * @param mixed $request Amazon_EC2_Model_RequestSpotInstances or array of parameters
 */
function invokeRequestSpotInstances(Amazon_EC2_Interface $service, $request)
{
    try {
        $response = $service->requestSpotInstances($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        RequestSpotInstancesResponse\n";
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        if ($response->isSetRequestSpotInstancesResult()) {
            echo "            RequestSpotInstancesResult\n";
            $requestSpotInstancesResult = $response->getRequestSpotInstancesResult();
            $spotInstanceRequestList = $requestSpotInstancesResult->getSpotInstanceRequest();
            foreach ($spotInstanceRequestList as $spotInstanceRequest) {
                echo "                SpotInstanceRequest\n";
                if ($spotInstanceRequest->isSetSpotInstanceRequestId()) {
                    echo "                    SpotInstanceRequestId\n";
                    echo "                        " . $spotInstanceRequest->getSpotInstanceRequestId() . "\n";
                }
                if ($spotInstanceRequest->isSetSpotPrice()) {
                    echo "                    SpotPrice\n";
                    echo "                        " . $spotInstanceRequest->getSpotPrice() . "\n";
                }
                if ($spotInstanceRequest->isSetType()) {
                    echo "                    Type\n";
                    echo "                        " . $spotInstanceRequest->getType() . "\n";
                }
                if ($spotInstanceRequest->isSetState()) {
                    echo "                    State\n";
                    echo "                        " . $spotInstanceRequest->getState() . "\n";
                }
                if ($spotInstanceRequest->isSetFault()) {
                    echo "                    Fault\n";
                    $fault = $spotInstanceRequest->getFault();
                    if ($fault->isSetCode()) {
                        echo "                        Code\n";
                        echo "                            " . $fault->getCode() . "\n";
                    }
                    if ($fault->isSetMessage()) {
                        echo "                        Message\n";
                        echo "                            " . $fault->getMessage() . "\n";
                    }
                }
                if ($spotInstanceRequest->isSetValidFrom()) {
                    echo "                    ValidFrom\n";
                    echo "                        " . $spotInstanceRequest->getValidFrom() . "\n";
                }
                if ($spotInstanceRequest->isSetValidUntil()) {
                    echo "                    ValidUntil\n";
                    echo "                        " . $spotInstanceRequest->getValidUntil() . "\n";
                }
                if ($spotInstanceRequest->isSetLaunchGroup()) {
                    echo "                    LaunchGroup\n";
                    echo "                        " . $spotInstanceRequest->getLaunchGroup() . "\n";
                }
                if ($spotInstanceRequest->isSetAvailabilityZoneGroup()) {
                    echo "                    AvailabilityZoneGroup\n";
                    echo "                        " . $spotInstanceRequest->getAvailabilityZoneGroup() . "\n";
                }
                if ($spotInstanceRequest->isSetLaunchSpecification()) {
                    echo "                    LaunchSpecification\n";
                    $launchSpecification = $spotInstanceRequest->getLaunchSpecification();
                    if ($launchSpecification->isSetImageId()) {
                        echo "                        ImageId\n";
                        echo "                            " . $launchSpecification->getImageId() . "\n";
                    }
                    if ($launchSpecification->isSetKeyName()) {
                        echo "                        KeyName\n";
                        echo "                            " . $launchSpecification->getKeyName() . "\n";
                    }
                    $securityGroupList = $launchSpecification->getSecurityGroup();
                    foreach ($securityGroupList as $securityGroup) {
                        echo "                        SecurityGroup\n";
                        echo "                            " . $securityGroup;
                    }
                    if ($launchSpecification->isSetUserData()) {
                        echo "                        UserData\n";
                        echo "                            " . $launchSpecification->getUserData() . "\n";
                    }
                    if ($launchSpecification->isSetAddressingType()) {
                        echo "                        AddressingType\n";
                        echo "                            " . $launchSpecification->getAddressingType() . "\n";
                    }
                    if ($launchSpecification->isSetInstanceType()) {
                        echo "                        InstanceType\n";
                        echo "                            " . $launchSpecification->getInstanceType() . "\n";
                    }
//.........这里部分代码省略.........
开发者ID:edasque,项目名称:ec2-manage-snapshots,代码行数:101,代码来源:RequestSpotInstancesSample.php


注:本文中的Amazon_EC2_Interface::requestSpotInstances方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。