From b819bde42949169b0628f63e107ff15f0cb67401 Mon Sep 17 00:00:00 2001 From: Frode Nordahl Date: Thu, 1 Mar 2018 15:19:49 +0000 Subject: [PATCH] Revert "Resolve hostnames if needed to allow access in ufw" We need a new proposal that uses get_host_ip from charmhelpers.contrib.network.ip Reference: https://review.openstack.org/#/c/542381/ This reverts commit 4896ac5b5b98f66cfe79c3945680ac0ac5dbb2bf. Change-Id: Idd16369be776a10ac6332d7d8b2ce65f9f1ad972 --- lib/swift_storage_utils.py | 17 +---------------- unit_tests/test_swift_storage_utils.py | 7 ------- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/lib/swift_storage_utils.py b/lib/swift_storage_utils.py index 74a7d2d..dfdabf5 100644 --- a/lib/swift_storage_utils.py +++ b/lib/swift_storage_utils.py @@ -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 diff --git a/unit_tests/test_swift_storage_utils.py b/unit_tests/test_swift_storage_utils.py index d053562..ef07351 100644 --- a/unit_tests/test_swift_storage_utils.py +++ b/unit_tests/test_swift_storage_utils.py @@ -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')