settingsLogin | Registersettings

[Openstack] Heat template - get port ID of 'external' instance

0 votes

I've created a environment file:

resource_registry:
"OS::Nova::Server::Instance": "https://raw.githubusercontent.com/FransUrbo/Openstack-Bayour.COM/master/instance.yaml"

I then create an instance from the template:

adminfloating:
type: OS::Neutron::FloatingIP
description: LDAP/KRB5 Admin Floating IP
properties:
floating
network_id: physical

portid: { getattr: [admin, networks, { get_param: network }, 0, port]}

portid: { getattr: [admin, networks, 0, port]}

admin:
type: OS::Nova::Server::Instance
properties:
name: instance
image: { getparam: image }
size: 5
flavor: m1.2tiny
network: { get
param: network }

The problem here is the 'portid' of "adminfloating". I can't
seem to be able to get the port ID of the instance created..

If I don't rollback my stack, I can investigate the instance
using "openstack server show " and there's no network
or port in there..
--
If something's hard to do, then it's not worth doing.
- Homer Simpson


Mailing list: http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
Post to : openstack@lists.openstack.org
Unsubscribe : http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
asked Jul 31, 2016 in openstack by Turbo_Fredriksson (8,980 points)   7 13 19

4 Responses

0 votes

On 31/07/16 10:39, Turbo Fredriksson wrote:
I've created a environment file:

resource_registry:
"OS::Nova::Server::Instance": "https://raw.githubusercontent.com/FransUrbo/Openstack-Bayour.COM/master/instance.yaml"

BTW I really wouldn't recommend using the OS:: namespace for your own
custom types.

I then create an instance from the template:

adminfloating:
type: OS::Neutron::FloatingIP
description: LDAP/KRB5 Admin Floating IP
properties:
floating
network_id: physical

portid: { getattr: [admin, networks, { get_param: network }, 0, port]}

portid: { getattr: [admin, networks, 0, port]}

You want the second one.

admin:
type: OS::Nova::Server::Instance
properties:
name: instance
image: { getparam: image }
size: 5
flavor: m1.2tiny
network: { get
param: network }

You're assuming here that doing get_attr on your provider resource will
automatically reach into the nested stack and pull out the attributes of
the resource you're thinking of - which of course would require Heat to
be clairvoyant ;)

You actually need to explicitly export the attributes you want as
outputs from the instance.yaml template, just as you defined parameters
to accept the property values. To make this a bit easier, you can get
the API to generate a template that you can modify with the command:

heat resource-type-template -t hot -F yaml OS::Nova::Server

cheers,
Zane.

responded Aug 1, 2016 by Zane_Bitter (21,640 points)   4 6 9
0 votes

On Aug 1, 2016, at 3:53 PM, Zane Bitter wrote:

BTW I really wouldn't recommend using the OS:: namespace for your own custom types.

Thanx. I'll change that 'eventually' :).

 floating_network_id: physical

portid: { getattr: [admin, networks, { get_param: network }, 0, port]}

portid: { getattr: [admin, networks, 0, port]}

You want the second one.

It didn't work, that's why it's commented out. I got something like
'networks isn't available' or something to that affect.

You actually need to explicitly export the attributes you want as outputs from the instance.yaml template, just as you defined parameters to accept the property values.

Ok, thanx!

heat resource-type-template -t hot -F yaml OS::Nova::Server

Cool! Wish I knew that this weekend :). Thanx, will come in handy
in the future..
--
Geologists recently discovered that "earthquakes" are
nothing more than Bruce Schneier and Chuck Norris
communicating via a roundhouse kick-based cryptosystem.

responded Aug 1, 2016 by Turbo_Fredriksson (8,980 points)   7 13 19
0 votes

On Aug 1, 2016, at 4:41 PM, Turbo Fredriksson wrote:

You actually need to explicitly export the attributes you want as outputs from the instance.yaml template, just as you defined parameters to accept the property values.

This seems to mostly working, but i'm not sure how to 'export' the
instance UUID from "instance.yaml" to "volume.yaml" via "development.yaml"
(which is the 'primary' template):

https://github.com/FransUrbo/Openstack-Bayour.COM/blob/master/development.yaml#L41
https://github.com/FransUrbo/Openstack-Bayour.COM/blob/master/instance.yaml#L83
https://github.com/FransUrbo/Openstack-Bayour.COM/blob/master/volume.yaml#L40

This give me

Resource CREATE failed: ValueError: resources.volume: Value must be valid JSON: No JSON object could be decoded

I've also tried

value: { getattr: [instance, instanceuuid] }

=> The Referenced Attribute (instance instance_uuid) is incorrect.
--
God gave man both a penis and a brain,
but unfortunately not enough blood supply
to run both at the same time.
- R. Williams

responded Aug 1, 2016 by Turbo_Fredriksson (8,980 points)   7 13 19
0 votes

Dang! Never mind. I was sure I've tried a 'string' type as the
input to volume, but apparently not..

Changing that, now it works.
--
Choose a job you love, and you will never have
to work a day in your life.

responded Aug 1, 2016 by Turbo_Fredriksson (8,980 points)   7 13 19
...