[Openstack] Access the floating ip address in heat

Pavlo Shchelokovskyy pshchelokovskyy at mirantis.com
Mon May 9 12:28:38 UTC 2016


Hi David,

the last line in params for server's user_data seems wrong. I really doubt
you literally have template parameter named "OS::Nova::FloatingIP".
Instead you'd have to use get_attr on the OS::Nova::FloatingIP resource you
presumably already created in the template somewhere (you are using it in
the 'association' resource) like that [1]:

$FLOATING_IP: { get_attr: [floating_ip, ip ] }

[1]
http://docs.openstack.org/developer/heat/template_guide/openstack.html#OS::Nova::FloatingIP-attr-ip

Cheers,


Dr. Pavlo Shchelokovskyy
Senior Software Engineer
Mirantis Inc
www.mirantis.com

On Mon, May 9, 2016 at 3:04 PM, Davíð Örn Jóhannsson <davidoj at siminn.is>
wrote:

> I’m trying to access the floating ip assigned to an instance created with
> a heat template and write it to file during creation of the instance, my
> approach is not working and I’m wondering if anyone has any suggestions on
> how I could archive this.
>
>     server:
>         type: OS::Nova::Server
>         properties:
>             name: { get_param: server_name }
>             image: { get_param: image }
>             flavor: { get_param: flavor }
>             key_name: { get_param: key_name }
>             scheduler_hints:
>                 group: {get_param: server_group }
>             admin_user: { get_param: admin_user }
>             networks:
>               - port: { get_resource: test_data_server_port }
>             user_data_format: RAW
>             user_data:
>                 str_replace:
>                     template: |
>                         #!/bin/bash -v
>                         echo '127.0.0.1 $SERVER_NAME' >> /etc/hosts
>                         echo $PROJECT_ID > /etc/project_id
>                         echo $FLOATING_IP > /etc/floating_ip
>
>                     params:
>                         $SERVER_NAME: { get_param: server_name }
>                         $PROJECT_ID: { get_param: 'OS::project_id' }
>                         $FLOATING_IP: { get_param: 'OS::Nova::FloatingIP' }
>
>     test_data_server_port:
>         type: OS::Neutron::Port
>         properties:
>             network_id: { get_param: private_net_id }
>             security_groups: [{ get_param: test_security_group }, default]
>             replacement_policy: AUTO
>
>     association:
>         type: OS::Nova::FloatingIPAssociation
>         properties:
>             floating_ip: { get_resource: floating_ip }
>             server_id: { get_resource: test_server }
>
> _______________________________________________
> Mailing list:
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
> Post to     : openstack at lists.openstack.org
> Unsubscribe :
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack/attachments/20160509/ca24f5ac/attachment.html>


More information about the Openstack mailing list