[Openstack] heat autoscaling group/instance relationships

Steven Hardy shardy at redhat.com
Wed Jun 11 10:46:35 UTC 2014


On Tue, Jun 10, 2014 at 09:45:49PM -0400, Aaron Knister wrote:
>    Awesome! Thank you Mike! Is there any way to programmatically determine if
>    a given stack resource contains nested stacks? I guess the simplest thing
>    to do is to query a given stack resource as it's own stack and see what
>    comes back. 

Yes, on recent versions of heat there is.

https://review.openstack.org/#/c/85781/

Since that patch was merged, there is a "nested" links entry which allows
you to identify that a resource is a nested stack, and hence you can
recurse and introspect the underlying nested stack if you wish.

I just posted a patch which makes this a little clearer by adding a suffix
to the links display in heat resource-show:

https://review.openstack.org/99326

I created a stack "r2" containing a nested stack containing one
RandomString resource (some lines snipped for readability):

-bash-4.2$ heat resource-list r2
+---------------+--------------
| resource_name | resource_type
resource_status | updated_time
+---------------+-------------
| random        | file:///opt/stack/heat-templates/hot/random.yaml
CREATE_COMPLETE | 2014-06-11T10:12:13Z |
+---------------+-------------

$ heat resource-show r2 random
| Property               | Value
| description            |
| links                  |
http://127.0.0.1:8004/v1/39522d06854447359cf7c377a62b776d/stacks/r2/68588705-62fa-4d68-859d-6b7ecb5ef570/resources/random
(self)      |
http://127.0.0.1:8004/v1/39522d06854447359cf7c377a62b776d/stacks/r2/68588705-62fa-4d68-859d-6b7ecb5ef570
(stack)                      |
http://127.0.0.1:8004/v1/39522d06854447359cf7c377a62b776d/stacks/r2-random-6illlpropnma/8c99f315-06e0-479a-8bcd-adf69407f212
(nested) |
| logical_resource_id    | random
| physical_resource_id   | 8c99f315-06e0-479a-8bcd-adf69407f212
| required_by            |
| resource_name          | random
| resource_status        | CREATE_COMPLETE
| resource_status_reason | state changed
| resource_type          | file:///opt/stack/heat-templates/hot/random.yaml
| updated_time           | 2014-06-11T10:12:13Z

Here you can see the third links entry, which won't exist for any resource
which isn't a nested stack.  The (nested) suffix is added by my patch
linked above.

Notice that the nested link contains the stack ID:

8c99f315-06e0-479a-8bcd-adf69407f212

This is the same as physical_resource_id, but the presence of the nested
link tells you it's a nested stack, thus you can recurse into it with stack
introspection operations like resource-list:

-bash-4.2$ heat resource-list 8c99f315-06e0-479a-8bcd-adf69407f212
| resource_name | resource_type          | resource_status | updated_time
+---------------+------------------------+-----------------+-------------
| random        | OS::Heat::RandomString | CREATE_COMPLETE |

Hope that helps.

Steve




More information about the Openstack mailing list