Use HostAddressOpt for opts that accept IP and hostnames

Some configuration options were accepting both IP addresses
and hostnames. Since there was no specific OSLO opt type to
support this, we were using 'StrOpt'. The support for
'HostAddressOpt' type was merged in Ocata and became
available for use with oslo version 3.22.

This patch changes the opt type of configuration options to
use this more relevant opt type - HostAddressOpt.

Co-Authored-By: John Garbutt <john.garbutt@rackspace.com>
Change-Id: I6116b4cc3deef4b9fad9383ea3e6a570a8becead
This commit is contained in:
dineshbhor 2017-03-14 17:53:46 +05:30
parent b93cd2bb3c
commit 128c75054b
10 changed files with 30 additions and 28 deletions

View File

@ -20,8 +20,8 @@ debugger_group = cfg.OptGroup('remote_debug',
title='debugger options')
CLI_OPTS = [
cfg.StrOpt('host',
help="""
cfg.HostAddressOpt('host',
help="""
Debug host (IP or name) to connect to. This command line parameter is used when
you want to connect to a nova service via a debugger running on a different
host.

View File

@ -586,8 +586,8 @@ Configuration options for enabling Trusted Platform Module.
""")
trusted_opts = [
cfg.StrOpt("attestation_server",
help="""
cfg.HostAddressOpt("attestation_server",
help="""
The host to use as the attestation server.
Cloud computing pools can involve thousands of compute nodes located at

View File

@ -31,7 +31,7 @@ Following requirements must be met in order to use SPICE:
""")
CLI_OPTS = [
cfg.StrOpt('html5proxy_host',
cfg.HostAddressOpt('html5proxy_host',
default='0.0.0.0',
help="""
IP address or a hostname on which the ``nova-spicehtml5proxy`` service

View File

@ -92,8 +92,8 @@ This option is ignored if serial_port_service_uri is not specified.
]
vmwareapi_opts = [
cfg.StrOpt('host_ip',
help="""
cfg.HostAddressOpt('host_ip',
help="""
Hostname or IP address for connection to VMware vCenter host."""),
cfg.PortOpt('host_port',
default=443,

View File

@ -54,7 +54,7 @@ Possible values:
of supported keyboard layouts at ``/usr/share/qemu/keymaps``.
"""),
cfg.StrOpt(
cfg.HostAddressOpt(
'vncserver_listen',
default='127.0.0.1',
deprecated_group='DEFAULT',
@ -63,7 +63,7 @@ The IP address or hostname on which an instance should listen to for
incoming VNC connection requests on this node.
"""),
cfg.StrOpt(
cfg.HostAddressOpt(
'vncserver_proxyclient_address',
default='127.0.0.1',
deprecated_group='DEFAULT',
@ -98,7 +98,7 @@ Related options:
* novncproxy_port
"""),
cfg.StrOpt(
cfg.HostAddressOpt(
'xvpvncproxy_host',
default='0.0.0.0',
deprecated_group='DEFAULT',

View File

@ -463,7 +463,7 @@ Related opitons:
cfg.StrOpt('sr_base_path',
default='/var/run/sr-mount',
help='Base path to the storage repository on the XenServer host.'),
cfg.StrOpt('target_host',
cfg.HostAddressOpt('target_host',
help="""
The iSCSI Target Host.

View File

@ -33,9 +33,9 @@ from nova import test
from nova.tests.unit import utils
test_service_opts = [
cfg.StrOpt("test_service_listen",
default='127.0.0.1',
help="Host to bind test service to"),
cfg.HostAddressOpt("test_service_listen",
default='127.0.0.1',
help="Host to bind test service to"),
cfg.IntOpt("test_service_listen_port",
default=0,
help="Port number to bind test service to"),

View File

@ -43,7 +43,7 @@ class ConfigDriveTestCase(test.NoDBTestCase):
vm_util.vm_refs_cache_reset()
self.context = context.RequestContext('fake', 'fake', is_admin=False)
self.flags(cluster_name='test_cluster',
host_ip='test_url',
host_ip='testhostname',
host_username='test_username',
host_password='test_pass',
use_linked_clone=False, group='vmware')

View File

@ -67,6 +67,8 @@ from nova.virt.vmwareapi import volumeops
CONF = nova.conf.CONF
HOST = 'testhostname'
DEFAULT_FLAVORS = [
{'memory_mb': 512, 'root_gb': 1, 'deleted_at': None, 'name': 'm1.tiny',
'deleted': 0, 'created_at': None, 'ephemeral_gb': 0, 'updated_at': None,
@ -201,7 +203,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
vm_util.vm_refs_cache_reset()
self.context = context.RequestContext('fake', 'fake', is_admin=False)
self.flags(cluster_name='test_cluster',
host_ip='test_url',
host_ip=HOST,
host_username='test_username',
host_password='test_pass',
api_retry_count=1,
@ -215,7 +217,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
stubs.set_stubs(self)
vmwareapi_fake.reset()
nova.tests.unit.image.fake.stub_out_image_service(self)
service = self._create_service(host='test_url')
service = self._create_service(host=HOST)
self.conn = driver.VMwareVCDriver(None, False)
self.assertFalse(service.disabled)
@ -251,7 +253,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
self.assertFalse(self.conn.need_legacy_block_device_info)
def test_get_host_ip_addr(self):
self.assertEqual('test_url', self.conn.get_host_ip_addr())
self.assertEqual(HOST, self.conn.get_host_ip_addr())
def test_init_host_with_no_session(self):
self.conn._session = mock.Mock()
@ -1700,9 +1702,9 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
connector_dict = self.conn.get_volume_connector(self.instance)
fake_vm = self._get_vm_record()
fake_vm_id = fake_vm.obj.value
self.assertEqual('test_url', connector_dict['ip'])
self.assertEqual(HOST, connector_dict['ip'])
self.assertEqual('iscsi-name', connector_dict['initiator'])
self.assertEqual('test_url', connector_dict['host'])
self.assertEqual(HOST, connector_dict['host'])
self.assertEqual(fake_vm_id, connector_dict['instance'])
def _test_vmdk_connection_info(self, type):
@ -1891,8 +1893,8 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
def test_connection_info_get(self):
self._create_vm()
connector = self.conn.get_volume_connector(self.instance)
self.assertEqual('test_url', connector['ip'])
self.assertEqual('test_url', connector['host'])
self.assertEqual(HOST, connector['ip'])
self.assertEqual(HOST, connector['host'])
self.assertEqual('iscsi-name', connector['initiator'])
self.assertIn('instance', connector)
@ -1900,8 +1902,8 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
self._create_vm()
self.conn.destroy(self.context, self.instance, self.network_info)
connector = self.conn.get_volume_connector(self.instance)
self.assertEqual('test_url', connector['ip'])
self.assertEqual('test_url', connector['host'])
self.assertEqual(HOST, connector['ip'])
self.assertEqual(HOST, connector['host'])
self.assertEqual('iscsi-name', connector['initiator'])
self.assertNotIn('instance', connector)

View File

@ -661,8 +661,8 @@ class VMwareVolumeOpsTestCase(test.NoDBTestCase):
vm_id = 'fake-vm'
vm_ref = mock.MagicMock(value=vm_id)
iqn = 'iscsi-name'
url = 'test_url'
self.flags(host_ip=url, group='vmware')
host_ip = 'testhostname'
self.flags(host_ip=host_ip, group='vmware')
with test.nested(
mock.patch.object(vm_util, 'get_vm_ref', return_value=vm_ref),
@ -675,7 +675,7 @@ class VMwareVolumeOpsTestCase(test.NoDBTestCase):
self._instance)
fake_iscsi_get_host_iqn.assert_called_once_with(self._instance)
self.assertEqual(url, connector['ip'])
self.assertEqual(url, connector['host'])
self.assertEqual(host_ip, connector['ip'])
self.assertEqual(host_ip, connector['host'])
self.assertEqual(iqn, connector['initiator'])
self.assertEqual(vm_id, connector['instance'])