openstack heat 无法识别 key_name 参数

openstack heat doesn't recognize key_name parameter

你好

我在笔记本电脑上部署了一个 openstack。我正在尝试用热量创建堆栈。

我已经创建了一个密钥对openstack keypair create heat_key > heat_key.priv 由 nova nova keypair-list 识别并给出以下输出:

+----------+------+-------------------------------------------------+
| Name     | Type | Fingerprint                                     |
+----------+------+-------------------------------------------------+
| heat_key | ssh  | 0b:7a:36:20:e2:e3:19:3b:ab:a1:95:ac:67:41:67:d7 |
+----------+------+-------------------------------------------------+

这是我的简单 HOT 模板:

heat_template_version: 2013-05-23

description: Hot Template to deploy a single server

parameters:
  image_id:
    type: string
    description: Image ID
  key_name:
    type: string
    description: name of keypair to enable ssh to the instance

resources:
  test_stack:
    type: OS::Nova::Server
    properties:
      name: "test_stack"
      image: { get_param: image_id }
      flavor: "ds1G"
      key_name:{ get_param: key_name }

outputs:
  test_stack_ip:
    description: IP of the server
    value: { get_attr: [ test_stack, first_address ] }

当我尝试创建堆栈时

openstack stack create -t myTemp.hot --parameter key_name=heat_key --parameter image_id=trusty-server-cloudimg-amd64-disk1 test_stack

我收到以下错误

ERROR: Property error: : resources.test_stack.properties: : Unknown Property key_name:{ get_param

我试过不同版本的模板,但我得到了同样的错误

知道为什么会这样吗?

尝试将参数名称key_name更改为其他名称并执行

heat_template_version: 2015-10-15

description: Hot Template to deploy a single server

parameters:
  image_id:
    type: string
    description: Image ID
  key_pair_name:
    type: string
    description: name of keypair to enable ssh to the instance

resources:
  test_stack:
    type: OS::Nova::Server
    properties:
      name: "test_stack"
      image: { get_param: image_id }
      flavor: "ds1G"
      key_name: { get_param: key_pair_name }

outputs:
  test_stack_ip:
    description: IP of the server
    value: { get_attr: [ test_stack, first_address ] }

关于 YAML 文件最糟糕的部分是,它 SPACE 敏感,因此我们在编辑或复制 HEAT 模板的内容时需要非常小心。 "key_name" 和“{”之间没有 space,这就是它失败的原因。

key_name:{ get_param: key_pair_name }

只要在它们之间加上 an extra space 就可以了。我测试了它:-)

key_name: { get_param: key_pair_name }

我能够通过在参数中提供详细信息来做到这一点。对我有用的 PFB 示例脚本。

heat_template_version: 2016-10-14

description: Admin VM - Test Heat
parameters:
  image_name_1:
    type: string
    label: Centos-7.0
    description: Centos Linux 7.0
    default: Centos-7.0
  network_id_E1:
    type: string
    label: 58e867ce-841c-48cf-8116-e72d998dbc89
    description: Admin External Network
    default: Admin
  network_id_E1:
    type: string
    label: 4f69c8e5-8f52-4804-89e0-2c8232f9f3aa
    description: Internal-1 Network
    default: SR-IOV Interface
  network_id_I2:
    type: string
    label: 28120cdb-7e8b-4e8b-821f-7c7d8df37c1d
    description: Internal-2 Network
    default: Internal-2
  KeyName:
    type: string
    default: IO_Perf_Cnt
    description: Name of an existing key pair to use for the instance
    constraints:
      - custom_constraint: nova.keypair
        description: Must name a public key (pair) known to Nova
resources:
  AdminVM1:
    type: OS::Nova::Server
    properties:
      availability_zone: naz3
      image:  { get_param: image_name_1 }
      flavor: 4vcpu_8192MBmem_40GBdisk
      key_name: { get_param: KeyName }
      networks:
        - network: { get_param : network_id_E1 }