Add service_network_host option for port host
Network port host can be totally different than manila host, So it's weird to force binding host to only manila host. `service_network_host` allow we specify host for network ports when `dhss` is True. Change-Id: I3d9a3bbc81f18d60a0710d9336ad6f97176875be
This commit is contained in:
parent
398722be59
commit
129dc9b28b
@ -78,6 +78,11 @@ share_servers_handling_mode_opts = [
|
||||
default="manila_service_network",
|
||||
help="Name of manila service network. Used only with Neutron. "
|
||||
"Only used if driver_handles_share_servers=True."),
|
||||
cfg.HostAddressOpt(
|
||||
"service_network_host",
|
||||
sample_default="<your_network_hostname>",
|
||||
help="Hostname to be used for service network binding. Used only with "
|
||||
"Neutron and if driver_handles_share_servers=True."),
|
||||
cfg.StrOpt(
|
||||
"service_network_cidr",
|
||||
default="10.254.0.0/16",
|
||||
@ -1020,7 +1025,7 @@ class NeutronNetworkHelper(BaseNetworkhelper):
|
||||
|
||||
This port will be used for connectivity with service instances.
|
||||
"""
|
||||
host = CONF.host
|
||||
host = self.get_config_option("service_network_host") or CONF.host
|
||||
search_opts = {'device_id': device_id,
|
||||
'binding:host_id': host}
|
||||
ports = [port for port in self.neutron_api.
|
||||
|
@ -45,8 +45,6 @@ def fake_get_config_option(key):
|
||||
return None
|
||||
elif key == 'service_instance_user':
|
||||
return 'fake_user'
|
||||
elif key == 'service_network_name':
|
||||
return 'fake_service_network_name'
|
||||
elif key == 'service_instance_flavor_id':
|
||||
return '100'
|
||||
elif key == 'service_instance_name_template':
|
||||
@ -67,6 +65,8 @@ def fake_get_config_option(key):
|
||||
return '99.254.0.0/24'
|
||||
elif key == 'service_network_division_mask':
|
||||
return 27
|
||||
elif key == 'service_network_host':
|
||||
return 'fake_service_network_host'
|
||||
elif key == 'service_network_name':
|
||||
return 'fake_service_network_name'
|
||||
elif key == 'interface_driver':
|
||||
@ -2161,7 +2161,7 @@ class NeutronNetworkHelperTestCase(test.TestCase):
|
||||
instance = self._init_neutron_network_plugin()
|
||||
admin_project_id = 'fake_admin_project_id'
|
||||
fake_port_values = {'device_id': 'manila-share',
|
||||
'binding:host_id': 'fake-host'}
|
||||
'binding:host_id': 'fake_service_network_host'}
|
||||
self.mock_object(
|
||||
service_instance.neutron.API, 'admin_project_id',
|
||||
mock.Mock(return_value=admin_project_id))
|
||||
@ -2182,14 +2182,15 @@ class NeutronNetworkHelperTestCase(test.TestCase):
|
||||
instance.neutron_api.create_port.assert_called_once_with(
|
||||
instance.admin_project_id, instance.service_network_id,
|
||||
device_id='manila-share', device_owner='manila:share',
|
||||
host_id='fake-host', subnet_id=None, port_security_enabled=False)
|
||||
host_id='fake_service_network_host',
|
||||
subnet_id=None, port_security_enabled=False)
|
||||
self.assertFalse(instance.neutron_api.update_port_fixed_ips.called)
|
||||
self.assertEqual(fake_service_port, result)
|
||||
|
||||
def test__get_service_port_one_exist_on_same_host(self):
|
||||
instance = self._init_neutron_network_plugin()
|
||||
fake_port_values = {'device_id': 'manila-share',
|
||||
'binding:host_id': 'fake-host'}
|
||||
'binding:host_id': 'fake_service_network_host'}
|
||||
fake_service_port = fake_network.FakePort(**fake_port_values)
|
||||
self.flags(host='fake-host')
|
||||
self.mock_object(instance.neutron_api, 'list_ports',
|
||||
@ -2208,7 +2209,9 @@ class NeutronNetworkHelperTestCase(test.TestCase):
|
||||
self.assertFalse(instance.neutron_api.update_port_fixed_ips.called)
|
||||
self.assertEqual(fake_service_port, result)
|
||||
|
||||
def test__get_service_port_one_exist_on_different_host(self):
|
||||
def test__get_service_port_default_host(self):
|
||||
self.mock_object(self.fake_manager, 'get_config_option',
|
||||
mock.Mock(return_value=None))
|
||||
instance = self._init_neutron_network_plugin()
|
||||
admin_project_id = 'fake_admin_project_id'
|
||||
fake_port = {'device_id': 'manila-share',
|
||||
@ -2225,6 +2228,32 @@ class NeutronNetworkHelperTestCase(test.TestCase):
|
||||
self.mock_object(instance.neutron_api, 'update_port_fixed_ips',
|
||||
mock.Mock(return_value=fake_service_port))
|
||||
|
||||
result = instance._get_service_port(instance.service_network_id,
|
||||
None, 'manila-share')
|
||||
instance.neutron_api.create_port.assert_called_once_with(
|
||||
instance.admin_project_id, instance.service_network_id,
|
||||
device_id='manila-share', device_owner='manila:share',
|
||||
host_id='fake-host', subnet_id=None,
|
||||
port_security_enabled=False)
|
||||
self.assertEqual(fake_service_port, result)
|
||||
|
||||
def test__get_service_port_one_exist_on_different_host(self):
|
||||
instance = self._init_neutron_network_plugin()
|
||||
admin_project_id = 'fake_admin_project_id'
|
||||
fake_port = {'device_id': 'manila-share',
|
||||
'binding:host_id': 'fake_service_network_host'}
|
||||
self.mock_object(
|
||||
service_instance.neutron.API, 'admin_project_id',
|
||||
mock.Mock(return_value=admin_project_id))
|
||||
fake_service_port = fake_network.FakePort(**fake_port)
|
||||
self.mock_object(instance.neutron_api, 'list_ports',
|
||||
mock.Mock(return_value=[]))
|
||||
self.flags(host='fake-host')
|
||||
self.mock_object(instance.neutron_api, 'create_port',
|
||||
mock.Mock(return_value=fake_service_port))
|
||||
self.mock_object(instance.neutron_api, 'update_port_fixed_ips',
|
||||
mock.Mock(return_value=fake_service_port))
|
||||
|
||||
result = instance._get_service_port(instance.service_network_id,
|
||||
None, 'manila-share')
|
||||
|
||||
@ -2233,7 +2262,8 @@ class NeutronNetworkHelperTestCase(test.TestCase):
|
||||
instance.neutron_api.create_port.assert_called_once_with(
|
||||
instance.admin_project_id, instance.service_network_id,
|
||||
device_id='manila-share', device_owner='manila:share',
|
||||
host_id='fake-host', subnet_id=None, port_security_enabled=False)
|
||||
host_id='fake_service_network_host', subnet_id=None,
|
||||
port_security_enabled=False)
|
||||
self.assertFalse(instance.neutron_api.update_port_fixed_ips.called)
|
||||
self.assertEqual(fake_service_port, result)
|
||||
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Add new config option 'service_network_host' for service instance with
|
||||
'dhss'=True. This helps us to define network host for ports and able to
|
||||
seperate from manila host.
|
Loading…
Reference in New Issue
Block a user