1

我们想使用 OpenStack API 来启动堆栈。但是模板文件将嵌套另一个模板文件。有什么方法可以实现吗?

主模板文件中的问题部分如下:

  node_vlan_group:
    type: OS::Heat::ResourceGroup
    depends_on: [node_sp_net]
    properties:
      count: {get_param: node_vlan_count}
      resource_def:
        type: node_vlan_template.yaml
        properties:
          vlan_index: '%index%'
          vlan_names: {get_param: node_vlan_names}
          vlan_cidrs4: {get_param: node_cidrs_ipv4}
          vlan_gateways4: {get_param: node_gateways_ipv4}

在“类型”字段中,包含另一个模板。但是如何通过 API 使用它呢?

(在 heat 客户端上使用 CLI 命令时,我可以将此模板和内联的 node_vlan_template.yaml 放在同一个文件夹中,它可以工作。但是通过 API,我需要一种方法来提供此 node_vlan_template.yaml 的内容。)

4

1 回答 1

1

通过将嵌套文件内容添加到 POST 正文以创建堆栈来解决此问题。它看起来像文件: {"node_vlan_template.yaml": "content of node_vlan_template.yaml"}

需要注意的另一件事是内容应该是从文件中转储的字符串,而不是 python dict 对象。

关于 ResourceGroup 的使用,在http://hardysteven.blogspot.com/2014/09/using-heat-resourcegroup-resources.html上有一篇很好的帖子

于 2017-02-15T15:25:10.120 回答