Browse Source

Transform IPAddress to string when creating port

If ip address is provided when running nova boot, nova compute
will invoke neutron client to create a port. However, the ip
address parameter is an IPAddress object so neutron client will
fail to send the request to neutron server. Transform IPAddress
object to string to address this issue.

Change-Id: I858cca475748795aa2532f32bfe0f1443b30966f
Closes-Bug: #1408529
changes/05/149905/2
zhiyuan_cai 7 years ago
parent
commit
aae858a246
  1. 3
      nova/network/neutronv2/api.py
  2. 4
      nova/tests/unit/network/test_neutronv2.py

3
nova/network/neutronv2/api.py

@ -257,7 +257,8 @@ class API(base_api.NetworkAPI):
"""
try:
if fixed_ip:
port_req_body['port']['fixed_ips'] = [{'ip_address': fixed_ip}]
port_req_body['port']['fixed_ips'] = [
{'ip_address': str(fixed_ip)}]
port_req_body['port']['network_id'] = network_id
port_req_body['port']['admin_state_up'] = True
port_req_body['port']['tenant_id'] = instance['project_id']

4
nova/tests/unit/network/test_neutronv2.py

@ -497,8 +497,8 @@ class TestNeutronv2Base(test.TestCase):
else:
request.address = fixed_ips.get(request.network_id)
if request.address:
port_req_body['port']['fixed_ips'] = [{'ip_address':
request.address}]
port_req_body['port']['fixed_ips'] = [
{'ip_address': str(request.address)}]
port_req_body['port']['network_id'] = request.network_id
port_req_body['port']['admin_state_up'] = True
port_req_body['port']['tenant_id'] = \

Loading…
Cancel
Save