簡體   English   中英

如何使用熱量模板中存在於地平線中的安全組

[英]How to use the security group existing in horizon in heat template

我是OpenStack加載的Heat yaml模板的新手,我知道此命令可以正常工作:

openstack server create --image RHEL-7.4   --flavor std.cpu1ram1 --nic net-id=network-name.admin-network --security-group security-name.group-sec-default   value instance-name

我試圖用上面的命令寫這個熱文件:

heat_template_version: 2014-10-16

description: Simple template to deploy a single compute instance with an attached volume

resources:
  my_instance:
    type: OS::Nova::Server
    properties:
      name: instance-name
      image: RHEL-7.4
      flavor: std.cpu1ram1
      networks:
        - network: network-name.admin-network
      security_group: 
        - security_group: security-name.group-sec-default

security-group: 
  type: OS::Neutron::SecurityGroup
properties:
  rules: security-name.group-sec-default

  my_volume:
    type: OS::Cinder::Volume
    properties:
      size: 10

  my_attachment:
      type: OS::Cinder::VolumeAttachment
      properties:
        instance_uuid:  { get_resource: my_instance }
        volume_id: { get_resource: my_volume }
        mountpoint: /dev/vdb

堆棧創建失敗,並顯示以下消息錯誤:

 openstack stack create -t my_first.yaml First_stack
 openstack stack show First_stack
.../...
   | stack_status_reason   | Resource CREATE failed: BadRequest: resources.my_instance: Unable to find security_group with name or id 'sec_group1' (HTTP 400) (Request-ID: req-1c5d041c-2254-4e43-8785-c421319060d0) 
.../...

感謝您的幫助,

經過挖掘,我終於在熱量文件中發現了問題所在。 我必須像這樣聲明我的實例:

my_instance:
    type: OS::Nova::Server
    properties:
      name: instance-name
      image: RHEL-7.4
      flavor: std.cpu1ram1
      networks:
        - network: network-name.admin-network
      security_groups: [security-name.group-sec-default]

謝謝你的支持

根據模板指南,期望規則類型為list

在此處輸入圖片說明

因此,為security-group更改模板的內容,如下所示:

security-group: 
  type: OS::Neutron::SecurityGroup
  properties:
    rules: [security-name.group-sec-default]

要么

security-group: 
  type: OS::Neutron::SecurityGroup
  properties:
    rules: 
      - security-name.group-sec-default

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM