Remove profile from opts after creating LXC container

When using cloud states to manage LXC containers __opts__['profile'] is
not implicitly reset between operations on different containers. However
list_nodes will hide container if profile is set in opts assuming that
it have to be created. But in cloud state we do want to check at first
if it really exists hence the need to remove profile from global opts
once current container is created.

Before this change salt would try to bootstrap other LXC containers
configured with help of LXC cloud state after legitimately creating new
container, even if those other containers were already up and running.

Probably the better solution would be to change filtering algorithm in
list_nodes but I'm not confident enough to do that.
This commit is contained in:
cellscape 2015-05-08 13:35:07 +06:00
parent c4047d2a71
commit 64250a67e5

View file

@ -428,6 +428,17 @@ def create(vm_, call=None):
ret['Error'] = 'Error while creating {0},'.format(vm_['name'])
else:
ret['changes']['created'] = 'created'
# When using cloud states to manage LXC containers
# __opts__['profile'] is not implicitly reset between operations
# on different containers. However list_nodes will hide container
# if profile is set in opts assuming that it have to be created.
# But in cloud state we do want to check at first if it really
# exists hence the need to remove profile from global opts once
# current container is created.
if 'profile' in __opts__:
del __opts__['profile']
return ret