Openstack heat template: interfaces with fixed IPs are not configured automatically

时间:2017-04-06 17:15:04

标签: openstack-nova openstack-neutron openstack-heat

I assign a fixed IP to an interface in the heat template.

private_port_1:
    type: OS::Neutron::Port
    properties:
        network: { get_param: private_net }
        fixed_ips: [{"subnet": { get_param: private_subnet }, "ip_address": { get_param: private_ip_1 }}]

my_vm_123:
    type: OS::Nova::Server
    properties:
        image: { get_param: image_name }
        flavor: { get_param: flavor_name }
        name: { get_param: vm_name }
     networks:
        - network: { get_param: public_net }
        - port: { get_resource: private_port_1 }

The VM is successfully instantiated and its private IP (private_ip_1) is shown in the Horizon GUI. However, the "eth1" appears to be down and the /etc/network/interfaces contains configuration only for the public "eth0".

I can do a workaround by manually populating "/etc/network/interfaces" and turning the eth1 on in the "user_data:" part. The question is - is this the way it should be or there is something wrong with my heat or Openstack that prevents eth1 to be configured automatically?

Thanks! Michael.

1 个答案:

答案 0 :(得分:1)

是的,它应该是这样的。 OpenStack(Nova,Neutron)设置VM并提供正确的连接。但是,在VM中运行的操作系统必须调出接口。默认的cloud-init映像是硬编码的,只能显示eth0(使用DHCP)。因此,您必须在VM中明确显示eth1。

您可以使用OS :: Nova :: Server资源类型的user_data变量在启动VM时运行自定义脚本。我有一个类似的用例,我需要自动调出eth1。您可以在https://github.com/ypraveen/openstack-installer/blob/master/vm-heat-template/devstack.yaml

查看我是如何实现这一目标的

第33行显示了user_data的用法。 您可以检查初始化脚本中出现eth1:https://github.com/ypraveen/openstack-installer/blob/master/vm-heat-template/devstack_vm_init.sh

的第41-45行