使用 gcloud api gem 插入实例时出错
error inserting instance with gcloud api gem
尝试使用 google-api-client
0.9.2 在 Google 云中启动一个实例
所以我是 运行:
compute.insert_instance(project, zone, instance_opts)
其中 instance_opts
是:
---
machineType: https://www.googleapis.com/compute/v1/projects/openshift-gce-devel/zones/us-central1-a/machineTypes/n1-standard-1
disks:
- initializeParams:
sourceImage: https://www.googleapis.com/compute/v1/projects/myproject/global/images/myimage
type: SCRATCH
networkInterfaces:
- network: projects/myproject/global/networks/default
accessConfigs:
- name: external
name: mytest
但是我从服务器收到一个错误:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Required field 'resource.name' not specified"
}
],
"code": 400,
"message": "Required field 'resource.name' not specified"
}
}
即使我只制作 instance_opts
,我也会遇到完全相同的问题:
{"name": "mytest"}
如果我尝试在 instance_opts
中设置未知字段 "resource" 或 "resource.name",我会收到错误消息。设置磁盘名称也无济于事。所以我想知道问题可能是什么。
哈,可能很愚蠢,但我很长一段时间都无法理解我实际上必须创建一个 Instance
对象并将其用于调用。
io = Google::Apis::ComputeV1::Instance.new(instance_opts)
compute.insert_instance(project, zone, io)
但还有一个细节。哈希应该是 :machine_type
而不是 "machineType"
。这对所有哈希键都是一样的。
尝试使用 google-api-client
0.9.2 在 Google 云中启动一个实例
所以我是 运行:
compute.insert_instance(project, zone, instance_opts)
其中 instance_opts
是:
---
machineType: https://www.googleapis.com/compute/v1/projects/openshift-gce-devel/zones/us-central1-a/machineTypes/n1-standard-1
disks:
- initializeParams:
sourceImage: https://www.googleapis.com/compute/v1/projects/myproject/global/images/myimage
type: SCRATCH
networkInterfaces:
- network: projects/myproject/global/networks/default
accessConfigs:
- name: external
name: mytest
但是我从服务器收到一个错误:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Required field 'resource.name' not specified"
}
],
"code": 400,
"message": "Required field 'resource.name' not specified"
}
}
即使我只制作 instance_opts
,我也会遇到完全相同的问题:
{"name": "mytest"}
如果我尝试在 instance_opts
中设置未知字段 "resource" 或 "resource.name",我会收到错误消息。设置磁盘名称也无济于事。所以我想知道问题可能是什么。
哈,可能很愚蠢,但我很长一段时间都无法理解我实际上必须创建一个 Instance
对象并将其用于调用。
io = Google::Apis::ComputeV1::Instance.new(instance_opts)
compute.insert_instance(project, zone, io)
但还有一个细节。哈希应该是 :machine_type
而不是 "machineType"
。这对所有哈希键都是一样的。