Fix a NameError exception in _nat_destination_port
Yeah, it was burried deep but still. Added a unit test just to quickly exercise this code path. Change-Id: Ibec3f24483214f8af514c8be512b7c3f3840b32e
This commit is contained in:
parent
d2123c20b5
commit
acac3b986b
|
@ -4137,7 +4137,7 @@ class OpenStackCloud(_normalize.Normalizer):
|
||||||
return port, fixed_address
|
return port, fixed_address
|
||||||
raise OpenStackCloudException(
|
raise OpenStackCloudException(
|
||||||
"unable to find a free fixed IPv4 address for server "
|
"unable to find a free fixed IPv4 address for server "
|
||||||
"{0}".format(server_id))
|
"{0}".format(server['id']))
|
||||||
# unfortunately a port can have more than one fixed IP:
|
# unfortunately a port can have more than one fixed IP:
|
||||||
# we can't use the search_ports filtering for fixed_address as
|
# we can't use the search_ports filtering for fixed_address as
|
||||||
# they are contained in a list. e.g.
|
# they are contained in a list. e.g.
|
||||||
|
|
|
@ -20,6 +20,8 @@ Tests floating IP resource methods for Neutron and Nova-network.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from mock import patch
|
from mock import patch
|
||||||
|
|
||||||
|
from shade import exc
|
||||||
from shade import meta
|
from shade import meta
|
||||||
from shade import OpenStackCloud
|
from shade import OpenStackCloud
|
||||||
from shade.tests.fakes import FakeServer
|
from shade.tests.fakes import FakeServer
|
||||||
|
@ -223,3 +225,12 @@ class TestFloatingIP(base.TestCase):
|
||||||
|
|
||||||
mock_add_auto_ip.assert_called_with(
|
mock_add_auto_ip.assert_called_with(
|
||||||
server_dict, wait=False, timeout=60, reuse=True)
|
server_dict, wait=False, timeout=60, reuse=True)
|
||||||
|
|
||||||
|
@patch.object(OpenStackCloud, 'search_ports', return_value=[{}])
|
||||||
|
def test_nat_destination_port_when_no_free_fixed_ip(
|
||||||
|
self, mock_search_ports):
|
||||||
|
server = {'id': 42}
|
||||||
|
self.assertRaisesRegexp(
|
||||||
|
exc.OpenStackCloudException, 'server 42$',
|
||||||
|
self.cloud._nat_destination_port, server
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue