# License for the specific language governing permissions and limitations
# under the License.
-import netaddr
from oslo.serialization import jsonutils
+from oslo.utils import netutils
import requests
import six.moves.urllib.parse as urlparse
hostname = parsed_url.hostname
scheme = parsed_url.scheme
- if netaddr.valid_ipv6(hostname):
+ if netutils.is_valid_ipv6(hostname):
hostname = "[%s]" % hostname
relative_url = parsed_url.path
import urllib
import urllib2
-import netaddr
+from oslo.utils import netutils
import six.moves.urllib.parse as urlparse
from cinder.i18n import _, _LI
"""Get size of the file to be read."""
raise NotImplementedError()
- def _is_valid_ipv6(self, address):
- """Whether given host address is a valid IPv6 address."""
- try:
- return netaddr.valid_ipv6(address)
- except Exception:
- return False
-
def get_soap_url(self, scheme, host):
"""return IPv4/v6 compatible url constructed for host."""
- if self._is_valid_ipv6(host):
+ if netutils.is_valid_ipv6(host):
return '%s://[%s]' % (scheme, host)
return '%s://%s' % (scheme, host)
The VMware API utility module.
"""
-import netaddr
+from oslo.utils import netutils
def get_soap_url(protocol, host, path='sdk'):
:param path: path part of the SOAP URL
:return: URL to SOAP services for ESX/VC server
"""
- if netaddr.valid_ipv6(host):
+ if netutils.is_valid_ipv6(host):
return '%s://[%s]/%s' % (protocol, host, path)
return '%s://%s/%s' % (protocol, host, path)