Python 3 fixes for tripleo-hieradata role

1) all_nodes.j2: use DICT.items() instead of dict.iteritems
The DICT.iteritems method has been removed in Python 3.

There are two recommended alternatives:

  for KEY, VALUE in DICT.items():
      pass

  or

  from ansible.module_utils.six import iteritems

  for KEY, VALUE in iteritems(DICT):
      pass

This patch replace iteritems by items.

2) vip_data.j2: use "in" instead of "has_key()"

dict.has_key() was removed in Python 3 and we should use "in" operator
instead.

  https://docs.python.org/3.1/whatsnew/3.0.html#builtins

This patch changes the vip data to use "in".

Closes-Bug: #1835456
Change-Id: If9515b8b09cf17028cc4c43278560e8d8b866eed
This commit is contained in:
Emilien Macchi 2019-07-04 15:22:09 -04:00
parent e1061bbecb
commit d60eb1b4be
2 changed files with 2 additions and 2 deletions

View File

@ -30,7 +30,7 @@
{% endfor %}
{# <service>_network: <network> #}
{% for service, network in service_net_map.iteritems() %}
{% for service, network in service_net_map.items() %}
{{ '"' ~ service ~ '": "' ~ network ~ '",' }}
{% endfor %}

View File

@ -43,7 +43,7 @@
"enable_internal_tls": {{ enable_internal_tls | lower }}
{%- for service in enabled_services %}
{%- if net_vip_map.has_key(service_net_map.get(service ~ '_network', 'noop')) %}
{%- if service_net_map.get(service ~ '_network', 'noop') in net_vip_map %}
{# we set explicit vips for these services, no need to calculate them dynamically #}
{%- if service not in ['redis', 'ganesha', 'keystone_admin_api_vip', 'keystone_public_api_vip'] %}
,"{{service}}_vip": "{{ net_vip_map[service_net_map[service ~ '_network']] }}"