Merge "Remove deprecated methods supported by neutron_lib"

This commit is contained in:
Jenkins 2017-03-01 22:03:51 +00:00 committed by Gerrit Code Review
commit 5d41e5f3f9
2 changed files with 0 additions and 191 deletions
neutron
common
tests/unit/common

@ -35,10 +35,7 @@ import eventlet
from eventlet.green import subprocess
import netaddr
from neutron_lib import constants as n_const
from neutron_lib.utils import file as file_utils
from neutron_lib.utils import helpers
from neutron_lib.utils import host
from neutron_lib.utils import net
from oslo_concurrency import lockutils
from oslo_config import cfg
from oslo_db import exception as db_exc
@ -97,59 +94,10 @@ def subprocess_popen(args, stdin=None, stdout=None, stderr=None, shell=False,
close_fds=close_fds, env=env)
@removals.remove(
message="Use parse_mappings from neutron_lib.utils.helpers")
def parse_mappings(mapping_list, unique_values=True, unique_keys=True):
return helpers.parse_mappings(mapping_list, unique_values=unique_values,
unique_keys=unique_keys)
@removals.remove(
message="Use get_hostname from neutron_lib.utils.net")
def get_hostname():
return net.get_hostname()
def get_first_host_ip(net, ip_version):
return str(netaddr.IPAddress(net.first + 1, ip_version))
@removals.remove(
message="Use compare_elements from neutron_lib.utils.helpers")
def compare_elements(a, b):
return helpers.compare_elements(a, b)
@removals.remove(
message="Use safe_sort_key from neutron_lib.utils.helpers")
def safe_sort_key(value):
return helpers.safe_sort_key(value)
@removals.remove(
message="Use dict2str from neutron_lib.utils.helpers")
def dict2str(dic):
return helpers.dict2str(dic)
@removals.remove(
message="Use str2dict from neutron_lib.utils.helpers")
def str2dict(string):
return helpers.str2dict(string)
@removals.remove(
message="Use dict2tuple from neutron_lib.utils.helpers")
def dict2tuple(d):
return helpers.dict2tuple(d)
@removals.remove(
message="Use diff_list_of_dict from neutron_lib.utils.helpers")
def diff_list_of_dict(old_list, new_list):
return helpers.diff_list_of_dict(old_list, new_list)
def is_extension_supported(plugin, ext_alias):
return ext_alias in getattr(
plugin, "supported_extension_aliases", [])
@ -177,12 +125,6 @@ def get_dhcp_agent_device_id(network_id, host):
return 'dhcp%s-%s' % (host_uuid, network_id)
@removals.remove(
message="Use cpu_count from neutron_lib.utils.host")
def cpu_count():
return host.cpu_count()
class exception_logger(object):
"""Wrap a function and log raised exception
@ -321,18 +263,6 @@ class DelayedStringRenderer(object):
return str(self.function(*self.args, **self.kwargs))
@removals.remove(
message="Use round_val from neutron_lib.utils.helpers")
def round_val(val):
return helpers.round_val(val)
@removals.remove(
message="Use replace_file from neutron_lib.utils")
def replace_file(file_name, data, file_mode=0o644):
file_utils.replace_file(file_name, data, file_mode=file_mode)
class _SilentDriverManager(driver.DriverManager):
"""The lamest of hacks to allow us to pass a kwarg to DriverManager parent.
@ -380,12 +310,6 @@ def load_class_by_alias_or_classname(namespace, name):
return class_to_load
@removals.remove(
message="Use safe_decode_utf8 from neutron_lib.utils.helpers")
def safe_decode_utf8(s):
return helpers.safe_decode_utf8(s)
def _hex_format(port, mask=0):
def hex_str(num):

@ -31,7 +31,6 @@ from neutron.common import utils
from neutron.plugins.common import constants as p_const
from neutron.plugins.common import utils as plugin_utils
from neutron.tests import base
from neutron.tests.common import helpers
from neutron.tests.unit import tests
load_tests = testscenarios.load_tests_apply_scenarios
@ -94,54 +93,6 @@ def _port_rule_masking(port_min, port_max):
return current.get_list()
class TestParseMappings(base.BaseTestCase):
def parse(self, mapping_list, unique_values=True, unique_keys=True):
return utils.parse_mappings(mapping_list, unique_values, unique_keys)
def test_parse_mappings_fails_for_missing_separator(self):
with testtools.ExpectedException(ValueError):
self.parse(['key'])
def test_parse_mappings_fails_for_missing_key(self):
with testtools.ExpectedException(ValueError):
self.parse([':val'])
def test_parse_mappings_fails_for_missing_value(self):
with testtools.ExpectedException(ValueError):
self.parse(['key:'])
def test_parse_mappings_fails_for_extra_separator(self):
with testtools.ExpectedException(ValueError):
self.parse(['key:val:junk'])
def test_parse_mappings_fails_for_duplicate_key(self):
with testtools.ExpectedException(ValueError):
self.parse(['key:val1', 'key:val2'])
def test_parse_mappings_fails_for_duplicate_value(self):
with testtools.ExpectedException(ValueError):
self.parse(['key1:val', 'key2:val'])
def test_parse_mappings_succeeds_for_one_mapping(self):
self.assertEqual({'key': 'val'}, self.parse(['key:val']))
def test_parse_mappings_succeeds_for_n_mappings(self):
self.assertEqual({'key1': 'val1', 'key2': 'val2'},
self.parse(['key1:val1', 'key2:val2']))
def test_parse_mappings_succeeds_for_duplicate_value(self):
self.assertEqual({'key1': 'val', 'key2': 'val'},
self.parse(['key1:val', 'key2:val'], False))
def test_parse_mappings_succeeds_for_no_mappings(self):
self.assertEqual({}, self.parse(['']))
def test_parse_mappings_succeeds_for_nonuniq_key(self):
self.assertEqual({'key': ['val1', 'val2']},
self.parse(['key:val1', 'key:val2', 'key:val2'],
unique_keys=False))
class TestParseTunnelRangesMixin(object):
TUN_MIN = None
TUN_MAX = None
@ -442,41 +393,6 @@ class TestParseVlanRangeList(UtilTestParseVlanRanges):
self.assertEqual(expected_networks, self.parse_list(config_list))
class TestDictUtils(base.BaseTestCase):
def test_dict2str(self):
dic = {"key1": "value1", "key2": "value2", "key3": "value3"}
expected = "key1=value1,key2=value2,key3=value3"
self.assertEqual(expected, utils.dict2str(dic))
def test_str2dict(self):
string = "key1=value1,key2=value2,key3=value3"
expected = {"key1": "value1", "key2": "value2", "key3": "value3"}
self.assertEqual(expected, utils.str2dict(string))
def test_dict_str_conversion(self):
dic = {"key1": "value1", "key2": "value2"}
self.assertEqual(dic, utils.str2dict(utils.dict2str(dic)))
def test_diff_list_of_dict(self):
old_list = [{"key1": "value1"},
{"key2": "value2"},
{"key3": "value3"}]
new_list = [{"key1": "value1"},
{"key2": "value2"},
{"key4": "value4"}]
added, removed = utils.diff_list_of_dict(old_list, new_list)
self.assertEqual([dict(key4="value4")], added)
self.assertEqual([dict(key3="value3")], removed)
class TestDict2Tuples(base.BaseTestCase):
def test_dict(self):
input_dict = {'foo': 'bar', '42': 'baz', 'aaa': 'zzz'}
expected = (('42', 'baz'), ('aaa', 'zzz'), ('foo', 'bar'))
output_tuple = utils.dict2tuple(input_dict)
self.assertEqual(expected, output_tuple)
class TestExceptionLogger(base.BaseTestCase):
def test_normal_call(self):
result = "Result"
@ -678,37 +594,6 @@ class TestDelayedStringRenderer(base.BaseTestCase):
self.assertTrue(my_func.called)
class TestRoundVal(base.BaseTestCase):
def test_round_val_ok(self):
for expected, value in ((0, 0),
(0, 0.1),
(1, 0.5),
(1, 1.49),
(2, 1.5)):
self.assertEqual(expected, utils.round_val(value))
class TestSafeDecodeUtf8(base.BaseTestCase):
@helpers.requires_py2
def test_py2_does_nothing(self):
s = 'test-py2'
self.assertIs(s, utils.safe_decode_utf8(s))
@helpers.requires_py3
def test_py3_decoded_valid_bytes(self):
s = bytes('test-py2', 'utf-8')
decoded_str = utils.safe_decode_utf8(s)
self.assertIsInstance(decoded_str, six.text_type)
self.assertEqual(s, decoded_str.encode('utf-8'))
@helpers.requires_py3
def test_py3_decoded_invalid_bytes(self):
s = bytes('test-py2', 'utf_16')
decoded_str = utils.safe_decode_utf8(s)
self.assertIsInstance(decoded_str, six.text_type)
class TestPortRuleMasking(base.BaseTestCase):
def test_port_rule_wrong_input(self):
with testtools.ExpectedException(ValueError):