Merge "network: Fix nova boot with multiple security-groups"

This commit is contained in:
Jenkins
2016-04-28 12:55:43 +00:00
committed by Gerrit Code Review
2 changed files with 12 additions and 8 deletions

View File

@@ -453,8 +453,8 @@ class API(base_api.NetworkAPI):
creating ports so it's not necessary to specify it to the creating ports so it's not necessary to specify it to the
request. request.
""" """
if DEFAULT_SECGROUP in security_groups: if security_groups == [DEFAULT_SECGROUP]:
security_groups.remove(DEFAULT_SECGROUP) security_groups = []
return security_groups return security_groups
def _process_security_groups(self, instance, neutron, security_groups): def _process_security_groups(self, instance, neutron, security_groups):

View File

@@ -4405,7 +4405,8 @@ class TestNeutronPortSecurity(test.NoDBTestCase):
mock_process_requested_networks.return_value = [ mock_process_requested_networks.return_value = [
None, ['net1', 'net2'], onets, None] None, ['net1', 'net2'], onets, None]
mock_get_available_networks.return_value = nets mock_get_available_networks.return_value = nets
mock_process_security_groups.return_value = ['secgrp-uuid1', mock_process_security_groups.return_value = ['default-uuid',
'secgrp-uuid1',
'secgrp-uuid2'] 'secgrp-uuid2']
api = neutronapi.API() api = neutronapi.API()
@@ -4414,20 +4415,22 @@ class TestNeutronPortSecurity(test.NoDBTestCase):
security_groups=secgroups) security_groups=secgroups)
mock_process_security_groups.assert_called_once_with( mock_process_security_groups.assert_called_once_with(
instance, mock.ANY, ['secgrp1', 'secgrp2']) instance, mock.ANY, ['default', 'secgrp1', 'secgrp2'])
mock_create_port.assert_has_calls([ mock_create_port.assert_has_calls([
mock.call( mock.call(
mock.ANY, instance, mock.ANY, instance,
u'net1', {'port': u'net1', {'port':
{'device_owner': u'compute:nova', {'device_owner': u'compute:nova',
'device_id': uuids.instance}}, 'device_id': uuids.instance}},
None, ['secgrp-uuid1', 'secgrp-uuid2'], None, None), None, ['default-uuid', 'secgrp-uuid1', 'secgrp-uuid2'],
None, None),
mock.call( mock.call(
mock.ANY, instance, mock.ANY, instance,
u'net2', {'port': u'net2', {'port':
{'device_owner': u'compute:nova', {'device_owner': u'compute:nova',
'device_id': uuids.instance}}, 'device_id': uuids.instance}},
None, ['secgrp-uuid1', 'secgrp-uuid2'], None, None)]) None, ['default-uuid', 'secgrp-uuid1', 'secgrp-uuid2'],
None, None)])
@mock.patch.object(neutronapi.API, 'get_instance_nw_info') @mock.patch.object(neutronapi.API, 'get_instance_nw_info')
@mock.patch.object(neutronapi.API, '_update_port_dns_name') @mock.patch.object(neutronapi.API, '_update_port_dns_name')
@@ -4524,7 +4527,8 @@ class TestNeutronPortSecurity(test.NoDBTestCase):
mock_process_requested_networks.return_value = [ mock_process_requested_networks.return_value = [
None, ['net1', 'net2'], onets, None] None, ['net1', 'net2'], onets, None]
mock_get_available_networks.return_value = nets mock_get_available_networks.return_value = nets
mock_process_security_groups.return_value = ['secgrp-uuid1', mock_process_security_groups.return_value = ['default-uuid',
'secgrp-uuid1',
'secgrp-uuid2'] 'secgrp-uuid2']
api = neutronapi.API() api = neutronapi.API()
@@ -4535,4 +4539,4 @@ class TestNeutronPortSecurity(test.NoDBTestCase):
security_groups=secgroups) security_groups=secgroups)
mock_process_security_groups.assert_called_once_with( mock_process_security_groups.assert_called_once_with(
instance, mock.ANY, ['secgrp1', 'secgrp2']) instance, mock.ANY, ['default', 'secgrp1', 'secgrp2'])