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.

Conflicts:
	nova/tests/unit/network/test_neutronv2.py

Change-Id: I858cca475748795aa2532f32bfe0f1443b30966f
Closes-Bug: #1408529
(cherry picked from commit aae858a246)
This commit is contained in:
zhiyuan_cai 2015-01-23 18:21:17 +08:00 committed by Artom Lifshitz
parent 91faa7b1da
commit 86efb1dac2
2 changed files with 4 additions and 3 deletions

View File

@ -197,7 +197,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']

View File

@ -498,8 +498,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'] = \