[openstack-dev] [heat] [CustomResource] LifeCycle methods flow
Pradip Mukhopadhyay
pradip.interra at gmail.com
Wed Nov 26 11:40:53 UTC 2014
Thanks Pavlo.
One particular thing I did not comprehend is:
Suppose my resource code is something like:
class HelloWorld(resource.Resource):
def __init__(self, controller, deserializer, serializer=None):
LOG.info("[pradipm]:Inside HelloWorld ctor");
resource.Resource.__init__(self, controller, deserializer,
serializer)
## Re-setting the data value
self._data_value = self.properties['value']
properties_schema = {
'value': properties.Schema(
properties.Schema.STRING,
_('foo')
),
}
attributes_schema = {
'data': _('the data')
}
...........
def _set_param_values(self):
LOG.info("[pradipm]:Inside _set_param_values")
self._data_value = self.properties['value']
return
def handle_create(self):
LOG.info("[pradipm]:Inside handle_create")
container_id = 1 ## some arbitrary id
self.resource_id_set(container_id)
self._set_param_values()
return container_id
I am seeing the constructor is getting called *later on* compared to the
handle_create -> check_create_complete etc.
Is that a *defined* behavior? Or it is purely *temporal* (such that in some
cases the ctor might be called early also).
Thanks,
Pradip
On Wed, Nov 26, 2014 at 4:05 PM, Pavlo Shchelokovskyy <
pshchelokovskyy at mirantis.com> wrote:
> Pradip,
>
> https://github.com/openstack/heat/blob/master/heat/engine/resource.py#L473
>
> Basically, it calls handle_create that might return some data, yields, and
> than keeps calling check_create_complete with that data returned by
> handle_create, yielding control in-between, until check_create_complete
> returns True.
>
> Best regards,
> Pavlo Shchelokovskyy.
>
> On Wed, Nov 26, 2014 at 12:20 PM, Pradip Mukhopadhyay <
> pradip.interra at gmail.com> wrote:
>
>> Hello,
>>
>>
>>
>> Any pointer (document and/or code pointer) related to how the different
>> overridden methods are getting called when a custom resource is getting
>> deployed in the heat stack?
>>
>>
>> Basically just tried to annotate the h-eng log on a simple,
>> very-first-attempt 'hello world' resource. Noticed the log is something
>> like:
>>
>> 2014-11-26 15:38:30.251 INFO heat.engine.plugins.helloworld [-]
>> [pradipm]:Inside handle_create
>> 2014-11-26 15:38:30.257 INFO heat.engine.plugins.helloworld [-]
>> [pradipm]:Inside _set_param_values
>> 2014-11-26 15:38:31.259 INFO heat.engine.plugins.helloworld [-]
>> [pradipm]:Inside check_create_complete
>> 2014-11-26 15:38:44.227 INFO heat.engine.plugins.helloworld
>> [req-9979deb9-f911-4df4-bdf8-ecc3609f054b None demo] [pradipm]:Inside
>> HelloWorld ctor
>> 2014-11-26 15:38:44.234 INFO heat.engine.plugins.helloworld
>> [req-9979deb9-f911-4df4-bdf8-ecc3609f054b None demo] [pradipm]:Inside
>> _resolve_attribute
>>
>>
>>
>>
>> The constructor (ctor) is getting called in the flow after the
>> create-resource. So though understanding the flow would help.
>>
>>
>>
>> Thanks in advance,
>> Pradip
>>
>>
>> _______________________________________________
>> OpenStack-dev mailing list
>> OpenStack-dev at lists.openstack.org
>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>>
>>
>
>
> --
> Pavlo Shchelokovskyy
> Software Engineer
> Mirantis Inc
> www.mirantis.com
>
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20141126/0313b9f4/attachment.html>
More information about the OpenStack-dev
mailing list