使用https调用waitFor方法设置openstack nova服务器


Using https when calling waitFor method setting up openstack nova server

我有以下PHP脚本(这只是下半部分):

use Guzzle'Http'Exception'BadResponseException;
$server = $compute->server();
try {
     $response = $server->create(array(
        'name'   => 'My server',
        'image'  => $centos,
        'flavor' => $twoGbFlavor
     ));
} catch (BadResponseException $e) {
    // No! Something failed. Let's find out:
    printf("Request: %s'n'nResponse: %s", $e->getRequest(), $e->getResponse());
 }
use OpenCloud'Compute'Constants'ServerState;
$callback = function($server) {
    if (!empty($server->error)) {
    var_dump($server->error);
    exit;
    } else {
        echo sprintf(
            "Waiting on %s/%-12s %4s%%",
            $server->name(),
            $server->status(),
            isset($server->progress) ? $server->progress : 0
        );
    }
};
$server->waitFor(ServerState::ACTIVE, 600, $callback);

当我运行它时,我收到以下错误:

PHP Fatal error:  Uncaught exception 'Guzzle'Http'Exception'CurlException' with message '[curl] 52: Empty reply from server [url] http://api.openstack.ecloud.co.uk:8774/v2/b7db5fe13c044b6e95bf5b766ae49393/servers/f5bf8951-f662-4940-904c-023b98b724c0' in /var/www/html/nutshell/openstack/vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlMulti.php:359

我已经将其缩小到使用http而不是https的waitFor方法的问题。然而,我无法弄清楚如何获得这种方法使用https,或者如果有一个设置,我可以改变以强制所有调用https?

此外,我已经尝试在脚本之外的命令行上使用curl运行这些命令,并且可以确认https有效。所以我只需要弄清楚如何让脚本调用使用https。

另外,请注意上面的$server->create调用工作得很好,我只是希望waitFor以相同的方式工作(即通过https)。

您使用https创建了服务器,得到了服务器数据的响应。服务器数据包含self url,该url很可能是http。"waitFor"调用openstack获取服务器数据。你可以在这里看到:https://github.com/rackspace/php-opencloud/blob/working/lib/OpenCloud/Common/Resource/BaseResource.php(第148行)