Removes the usage of the IPy module in favor of the netaddr module.
This commit is contained in:
@@ -56,11 +56,11 @@
|
|||||||
import gettext
|
import gettext
|
||||||
import glob
|
import glob
|
||||||
import json
|
import json
|
||||||
|
import netaddr
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import IPy
|
|
||||||
|
|
||||||
# If ../nova/__init__.py exists, add ../ to Python search path, so that
|
# If ../nova/__init__.py exists, add ../ to Python search path, so that
|
||||||
# it will override what happens to be installed in /usr/(local/)lib/python...
|
# it will override what happens to be installed in /usr/(local/)lib/python...
|
||||||
@@ -518,7 +518,7 @@ class FloatingIpCommands(object):
|
|||||||
def create(self, host, range):
|
def create(self, host, range):
|
||||||
"""Creates floating ips for host by range
|
"""Creates floating ips for host by range
|
||||||
arguments: host ip_range"""
|
arguments: host ip_range"""
|
||||||
for address in IPy.IP(range):
|
for address in netaddr.IPNetwork(range):
|
||||||
db.floating_ip_create(context.get_admin_context(),
|
db.floating_ip_create(context.get_admin_context(),
|
||||||
{'address': str(address),
|
{'address': str(address),
|
||||||
'host': host})
|
'host': host})
|
||||||
@@ -526,7 +526,7 @@ class FloatingIpCommands(object):
|
|||||||
def delete(self, ip_range):
|
def delete(self, ip_range):
|
||||||
"""Deletes floating ips by range
|
"""Deletes floating ips by range
|
||||||
arguments: range"""
|
arguments: range"""
|
||||||
for address in IPy.IP(ip_range):
|
for address in netaddr.IPNetwork(ip_range):
|
||||||
db.floating_ip_destroy(context.get_admin_context(),
|
db.floating_ip_destroy(context.get_admin_context(),
|
||||||
str(address))
|
str(address))
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
"""
|
"""
|
||||||
Unit Tests for flat network code
|
Unit Tests for flat network code
|
||||||
"""
|
"""
|
||||||
import IPy
|
import netaddr
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
@@ -45,8 +45,8 @@ class FlatNetworkTestCase(base.NetworkTestCase):
|
|||||||
|
|
||||||
self.context._project = self.projects[0]
|
self.context._project = self.projects[0]
|
||||||
self.context.project_id = self.projects[0].id
|
self.context.project_id = self.projects[0].id
|
||||||
pubnet = IPy.IP(flags.FLAGS.floating_range)
|
pubnet = netaddr.IPRange(flags.FLAGS.floating_range)
|
||||||
address = str(pubnet[0])
|
address = str(list(pubnet)[0])
|
||||||
try:
|
try:
|
||||||
db.floating_ip_get_by_address(context.get_admin_context(), address)
|
db.floating_ip_get_by_address(context.get_admin_context(), address)
|
||||||
except exception.NotFound:
|
except exception.NotFound:
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
"""
|
"""
|
||||||
Unit Tests for network code
|
Unit Tests for network code
|
||||||
"""
|
"""
|
||||||
import IPy
|
import netaddr
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from nova import test
|
from nova import test
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
"""
|
"""
|
||||||
Unit Tests for vlan network code
|
Unit Tests for vlan network code
|
||||||
"""
|
"""
|
||||||
import IPy
|
import netaddr
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from nova import context
|
from nova import context
|
||||||
@@ -44,8 +44,8 @@ class VlanNetworkTestCase(base.NetworkTestCase):
|
|||||||
# TODO(vish): better way of adding floating ips
|
# TODO(vish): better way of adding floating ips
|
||||||
self.context._project = self.projects[0]
|
self.context._project = self.projects[0]
|
||||||
self.context.project_id = self.projects[0].id
|
self.context.project_id = self.projects[0].id
|
||||||
pubnet = IPy.IP(flags.FLAGS.floating_range)
|
pubnet = netaddr.IPNetwork(flags.FLAGS.floating_range)
|
||||||
address = str(pubnet[0])
|
address = str(list(pubnet)[0])
|
||||||
try:
|
try:
|
||||||
db.floating_ip_get_by_address(context.get_admin_context(), address)
|
db.floating_ip_get_by_address(context.get_admin_context(), address)
|
||||||
except exception.NotFound:
|
except exception.NotFound:
|
||||||
|
|||||||
Reference in New Issue
Block a user