使用Heat模板在OpenStack中使用固定IP和端口创建多个实例

时间:2019-08-25 19:03:46

标签: openstack openstack-heat

使用热模板在openstack中使用固定IP和端口创建多个实例

我想创建3个具有特定网络和固定IP的实例/虚拟机。想法是创建100个以上的虚拟机。要制作动态热量模板,我需要这样做,以便我可以进行一些更改。我尝试制作散热模板,但是在端口和该端口的ip分配方面遇到问题。 heat_template_version:“ 2016-04-08”

错误----> {u'fixed_ips':[{u'ip_address':u''}]

错误:ValueError :: resources.sm_instance_group.resources.0.resources.sm_instance ::“ {u'sm_oam_port':{u'type':u'OS :: Neutron :: Port',u'properties': {u'fixed_ips':[{u'ip_address':u''}],u'network':u'4a4e40f5-1c53-4089-85e6-5fa1d7706530',u'name':u'sm_oam_port0'}}}}“不是列表

#ENV file
parameters:
  sm_flavor: sm_capacity
  sm_availability_zone: performance-zone
  sm_image: 042386c6-0230-4a72-9255-ecb52fd0ec1d

  sm_net_oam: 4a4e40f5-1c53-4089-85e6-5fa1d7706530 ### 193.168.11.x
  sm_subnet_oam: 569a78c5f2334da3a7132d3d35cabc44 ### 193.168.11.x

  sm_oam_ip: ["193.168.11.185", "193.168.11.186", "193.168.11.187"]



#Template file
  description: for SM cluster test, SM2-Node1,SM2-Node2,SM2-Node3 in one template
  heat_template_version: '2016-04-08'

  parameters:
    sm_flavor: {description: Flavor to use for servers, type: string}
    sm_availability_zone: {description: Name of availability_zone to use for servers, type: string}
    sm_image: {description: Name of image to use for servers, type: string}

    sm_net_oam: {description: ID of Neutron network into which servers get deployed, type: string}
    sm_subnet_oam: {description: ID of Neutron network into which servers get deployed, type: string}

    sm_oam_ip:
      type: comma_delimited_list
      default: ['193.168.11.185', '193.168.11.186', '193.168.11.187']

  resources:

    sm_instance_group:
      type: OS::Heat::ResourceGroup
      properties:
        count: 3
        resource_def:
          type: sm_port.yaml
          properties:
            sm_vm_name: SM-%index%
            sm_oam_port_name: sm_oam_port%index%
            sm_oam_ip_index: { get_param: [sm_oam_ip, index] }
            sm_net_oam: { get_param: sm_net_oam }
            sm_subnet_oam: { get_param: sm_subnet_oam }
            sm_image: {get_param: sm_image}
            sm_availability_zone: {get_param: sm_availability_zone}
            sm_flavor: {get_param: sm_flavor}



#sm_port.yaml
description: for SM cluster test, SM2-Node1,SM2-Node2,SM2-Node3 in one template
heat_template_version: '2016-04-08'

  parameters:
    sm_flavor: {description: Flavor to use for servers, type: string}
    sm_availability_zone: {description: Name of availability_zone to use for servers, type: string}
    sm_image: {description: Name of image to use for servers, type: string}
    sm_vm_name: {type: string}
    sm_oam_port_name: {type: string}
    sm_oam_ip_index: {type: string}

    sm_net_oam: {description: ID of Neutron network into which servers get deployed, type: string}
    sm_subnet_oam: {description: ID of Neutron network into which servers get deployed, type: string}


  resources:

    sm_instance:
      type: OS::Nova::Server
      properties:
        flavor: {get_param: sm_flavor}
        availability_zone: {get_param: sm_availability_zone}
        name: {get_param: sm_vm_name}
        image: {get_param: sm_image}
        networks:
          sm_oam_port:
            type: OS::Neutron::Port
            properties:
              network: { get_param: sm_net_oam }
              name: { get_param: sm_oam_port_name }
              fixed_ips: 
              - { "ip_address": {get_param: sm_oam_ip_index }}
        config_drive: true
        user_data_format: RAW
        user_data:
          str_replace:
            template: {get_file: ud1}
            params:
        name: { get_param: sm_oam_port_name }

0 个答案:

没有答案