Merge "Don't allow specify fixed_ip and port at the same time"

This commit is contained in:
Jenkins 2016-01-25 09:00:48 +00:00 committed by Gerrit Code Review
commit f4f5d4ad75
2 changed files with 13 additions and 2 deletions

View File

@ -34,6 +34,7 @@ class ServerNetworkMixin(object):
net_id = network.get(self.NETWORK_ID)
port = network.get(self.NETWORK_PORT)
subnet = network.get(self.NETWORK_SUBNET)
fixed_ip = network.get(self.NETWORK_FIXED_IP)
if (net_id is None and port is None
and net_uuid is None and subnet is None):
@ -67,6 +68,12 @@ class ServerNetworkMixin(object):
network=network[self.NETWORK_ID],
server=self.name))
# Nova doesn't allow specify ip and port at the same time
if fixed_ip and port:
raise exception.ResourcePropertyConflict(
"/".join([self.NETWORKS, self.NETWORK_FIXED_IP]),
"/".join([self.NETWORKS, self.NETWORK_PORT]))
def _validate_belonging_subnet_to_net(self, network):
if network.get(self.NETWORK_PORT) is None and self.is_using_neutron():
net = self._get_network_id(network)

View File

@ -1384,12 +1384,16 @@ class ServersTest(common.HeatTestCase):
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().AndReturn(self.fc)
self._mock_get_image_id_success('F17-x86_64-gold', 'image_id')
self.stub_ImageConstraint_validate()
self.stub_NetworkConstraint_validate()
self.stub_PortConstraint_validate()
self.m.ReplayAll()
self.assertIsNone(server.validate())
error = self.assertRaises(exception.ResourcePropertyConflict,
server.validate)
self.assertEqual("Cannot define the following properties at the same "
"time: networks/fixed_ip, networks/port.",
six.text_type(error))
self.m.VerifyAll()
def test_server_validate_with_uuid_fixed_ip(self):