diff options
| author | Sven Kieske <s.kieske@mittwald.de> | 2020-10-16 16:24:02 +0200 |
|---|---|---|
| committer | Sven Kieske <s.kieske@mittwald.de> | 2022-03-24 17:52:17 +0100 |
| commit | 159925248375727ae67ef93a606b09a54e83ba2d (patch) | |
| tree | 4ce8ca17607f7e0a035a0d4acd1ca513bbd838de /kolla_ansible/put_address_in_context.py | |
| parent | b668e27356adcd9824a67703d4d96b1a229d9a3c (diff) | |
| download | kolla-ansible-159925248375727ae67ef93a606b09a54e83ba2d.tar.gz kolla-ansible-159925248375727ae67ef93a606b09a54e83ba2d.zip | |
re-add rabbitmq config for clustering interface
this adds back the ability to configure
the rabbitmq/erlang kernel network interface
which was removed in https://review.opendev.org/#/c/584427/
seemingly by accident.
Closes-Bug: 1900160
Change-Id: I6f00396495853e117429c17fadfafe809e322a31
Diffstat (limited to 'kolla_ansible/put_address_in_context.py')
| -rw-r--r-- | kolla_ansible/put_address_in_context.py | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/kolla_ansible/put_address_in_context.py b/kolla_ansible/put_address_in_context.py index d176a5611..69355283f 100644 --- a/kolla_ansible/put_address_in_context.py +++ b/kolla_ansible/put_address_in_context.py @@ -14,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from ipaddress import ip_address from kolla_ansible.exception import FilterError @@ -27,18 +28,32 @@ def put_address_in_context(address, context): :returns: string with address in proper context """ - if context not in ['url', 'memcache']: + if context not in ['url', 'memcache', 'rabbitmq']: raise FilterError("Unknown context '{context}'" .format(context=context)) - if ':' not in address: + if ':' not in address and context != 'rabbitmq': return address # must be IPv6 raw address if context == 'url': return '[{address}]'.format(address=address) - elif context == 'memcache': + if context == 'memcache': return 'inet6:[{address}]'.format(address=address) + # rabbitmq/erlang has special syntax for ip addresses in IPv4 and IPv6 + # see: https://www.erlang.org/doc/man/inet.html + # replacing dots and colons with decimal points + # and converting IPv6 as described here: + # https://www.erlang.org/doc/man/inet.html#type-ip6_address + + if context == 'rabbitmq': + if ip_address(address).version == 6: + return (",".join(['16#%x' % int(x, 16) + for x in + ip_address(address).exploded.split(':')])) + + return address.replace('.', ',') + return address |
