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 4896ac5b5b.

Change-Id: Idd16369be776a10ac6332d7d8b2ce65f9f1ad972
This commit is contained in:
Frode Nordahl 2018-03-01 15:19:49 +00:00
parent 4896ac5b5b
commit b819bde429
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')