Use is_valid_ipv6() from oslo.utils

oslo.utils contains is_valid_ipv6() function, so we can reuse it.

Change-Id: Ib5898486ab79b9103edd2cd16f9a7b71b409b4f0
This commit is contained in:
Victor Sergeyev 2015-04-27 12:33:31 +03:00
parent 19fede378a
commit 73bf032b29
1 changed files with 2 additions and 10 deletions

View File

@ -19,10 +19,10 @@ import hashlib
import httplib
import logging
import os
import socket
from oslo_config import cfg
from oslo_utils import excutils
from oslo_utils import netutils
from oslo_utils import units
from oslo_vmware import api
from oslo_vmware import constants
@ -115,14 +115,6 @@ _VMWARE_OPTS = [
'selected.'))]
def is_valid_ipv6(address):
try:
socket.inet_pton(socket.AF_INET6, address)
return True
except Exception:
return False
def http_response_iterator(conn, response, size):
"""Return an iterator for a file-like object.
@ -219,7 +211,7 @@ class StoreLocation(location.StoreLocation):
self.query = urlparse.urlencode(param_list)
def get_uri(self):
if is_valid_ipv6(self.server_host):
if netutils.is_valid_ipv6(self.server_host):
base_url = '%s://[%s]%s' % (self.scheme,
self.server_host, self.path)
else: