Merge "Revert "Resolve hostnames if needed to allow access in ufw""

This commit is contained in:
Zuul 2018-03-01 16:32:16 +00:00 committed by Gerrit Code Review
commit 7e7e4a4bf5
2 changed files with 1 additions and 23 deletions

View File

@ -1,7 +1,6 @@
import json
import os
import re
import socket
import subprocess
import shutil
import tempfile
@ -137,20 +136,6 @@ FIRST = 1
KV_DB_PATH = '/var/lib/juju/swift_storage/charm_kvdata.db'
def _ensure_ip(value):
"""Ensure to always return an ip address.
:param value: IP address or domain
See LP: #1747516
"""
if not value:
return value
resp = socket.getaddrinfo(value, None)
return resp[0][4][0]
def ensure_swift_directories():
'''
Ensure all directories required for a swift storage node exist with
@ -635,7 +620,7 @@ def setup_ufw():
allowed_hosts = RsyncContext()().get('allowed_hosts', '').split(' ')
# Storage clients (swift-proxy)
allowed_hosts += [_ensure_ip(ingress_address(rid=u.rid, unit=u.unit))
allowed_hosts += [ingress_address(rid=u.rid, unit=u.unit)
for u in iter_units_for_relation_name('swift-storage')]
# Grant access for peers and clients

View File

@ -500,10 +500,3 @@ class SwiftStorageUtilsTests(CharmTestCase):
for port in ports:
calls.append(call(addr, port))
mock_grant_access.assert_has_calls(calls)
def test_ensure_ip(self):
self.assertEqual(swift_utils._ensure_ip('ubuntu.com'), '91.189.94.40')
self.assertEqual(swift_utils._ensure_ip('91.189.94.40'),
'91.189.94.40')
self.assertEqual(swift_utils._ensure_ip('2001:67c:1560:8001::14'),
'2001:67c:1560:8001::14')