【问题标题】:Google Deployment Manager Issue: Can not create Instance TemplateGoogle 部署管理器问题:无法创建实例模板
【发布时间】:2018-03-24 20:11:36
【问题描述】:

我正在尝试使用 gcloud 部署管理器部署自定义实例模板,但我不断收到此错误:

错误:(gcloud.deployment-manager.deployments.update)操作错误 [operation-1507833758152-55b5de788f540-e3be8bf6-a792d98e]:错误: - 代码:RESOURCE_ERROR 位置:/deployments/my-project/resources/worker-template 消息:'{"ResourceType":"compute.v1.instanceTemplate","ResourceErrorCode":"400","ResourceErrorMessage":{"code":400,"errors":[{"domain":"global","消息":"无效 字段''resource.properties''的值:''''。实例模板必须提供 实例属性。","re​​ason":"invalid"}],"message":"字段值无效 ''resource.properties'':''''。实例模板必须提供实例属性。","statusMessage":"Bad 请求","re​​questPath":"https://www.googleapis.com/compute/v1/projects/my-project/global/instanceTemplates","httpMethod":"POST"}}'

我的 python generate_config 函数是这样的:

def generate_config(上下文): 资源 = [{ 'type': 'compute.v1.instanceTemplate', '名称':'工人模板', '特性': { 'zone': context.properties['zone'], 'description': '工人模板', 'machineType': context.properties['machineType'], “磁盘”:[{ 'deviceName': '启动', '类型':'持久', “引导”:是的, “自动删除”:是的, “初始化参数”:{ 'sourceImage': '/'.join([ context.properties['compute_base_url'], '项目',context.properties ['os_project'], 'global/images/family', context.properties['os_project_family'] ]) } }], “网络接口”:[{ 'network': '$(ref.' + context.properties['network'] + '.selfLink)', “访问配置”:[{ 'name': '外部 NAT', “类型”:“ONE_TO_ONE_NAT” }] }] } }] 返回{'资源':资源}

属性不为空,因此错误消息没有多大意义。有什么想法吗?

谢谢!

【问题讨论】:

    标签: python gcloud google-deployment-manager


    【解决方案1】:

    看了this example,才发现compute.v1.instanceTemplate的正确结构是:

    ... 'type': 'compute.v1.instanceTemplate', '名称':'工人模板', '特性': { “项目”:“我的项目”, '特性': { 'zone': context.properties['zone'], ... } } ...

    结构遵循this doc

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-16
      • 2020-04-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-29
      • 2011-04-21
      相关资源
      最近更新 更多