调用 waitFor 方法时使用 https 设置 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 url。你可以在这里看到这个:
https://github.com/rackspace/php-opencloud/blob/working/lib/OpenCloud/Common/Resource/BaseResource.php(第 148 行)
我有以下 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 url。你可以在这里看到这个: https://github.com/rackspace/php-opencloud/blob/working/lib/OpenCloud/Common/Resource/BaseResource.php(第 148 行)