Make this change python3 compatible, also provide default if generator is exhausted

This commit is contained in:
Dmitri Muntean 2015-07-14 15:03:55 +10:00
parent 44a3812bff
commit 6785eb2bef

View File

@ -2318,7 +2318,7 @@ def get_cloud_config_value(name, vm_, opts, default=None, search_global=True):
if name and vm_ and name in vm_: if name and vm_ and name in vm_:
# The setting name exists in VM configuration. # The setting name exists in VM configuration.
if isinstance(vm_[name], types.GeneratorType): if isinstance(vm_[name], types.GeneratorType):
value = vm_[name].next() value = next(vm_[name], '')
else: else:
if isinstance(value, dict): if isinstance(value, dict):
value.update(vm_[name].copy()) value.update(vm_[name].copy())