Google Compute Engine API - 尝试创建新VM实例时出错

时间:2014-07-18 13:27:29

标签: php

我正在尝试使用自定义500G磁盘在Compute Engine上创建新的VM实例。我正在使用以下代码:

$options = array(
  'name' => 'ti4', 
  'machine_type' => 'https://www.googleapis.com/compute/v1/projects/' . $project . '/zones/us-central1-a/machineTypes/f1-micro',
  'disks' => array(
      array(
          'type' => 'PERSISTENT',
          'boot' => true,
          'initializeParams' => array(
              'diskName' => 'ti4',
              'diskSizeGb' => 500,
              'sourceImage' => 'https://www.googleapis.com/compute/v1/projects/' . $project . '/zones/us-central1-a/disks?sourceImage=' . urlencode('http://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20140619')
          )
      )
  ),
  'networkInterfaces' => array(
      array(
          'network' => 'https://www.googleapis.com/compute/v1/projects/' . $project . '/global/networks/default'
      )
  ) 
);


$resource = $service->instances->insert($project, 'us-central1-a', new Google_Service_Compute_Instance($options), array());

我收到以下错误消息:

...(400) Invalid value for field 'resource.disks[0].initializeParams.sourceImage': 'https://www.googleapis.com/compute/v1/projects/467549724285/zones/us-central1-a/disks?sourceImage=http%3A%2F%2Fwww.googleapis.com%2Fcompute%2Fv1%2Fprojects%2Fcentos-cloud%2Fglobal%2Fimages%2Fcentos-6-v20140619'. Must be the URL to a Compute resource of the correct type...

但是根据this描述,sourceImage参数是正确的。

我该如何解决这个问题?

提前感谢您的帮助:)

0 个答案:

没有答案