config: allow to create VMs with unique names

This commit introduces option osapi_compute_unique_server_name_scope
which allows operators to ensure VMs are created with unique names per
project or cloud.

Change-Id: Idacb60bb31cd60cb1deaec7cb3ec061f0c04da24
Closes-Bug: #1829782
Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@canonical.com>
This commit is contained in:
Sahid Orentino Ferdjaoui 2019-05-22 16:23:06 +02:00 committed by Felipe Reyes
parent e38ce7bb71
commit 40282e0356
11 changed files with 38 additions and 0 deletions

View File

@ -617,3 +617,13 @@ options:
. .
For Windows guests is recommended to set this to configuration option to For Windows guests is recommended to set this to configuration option to
False and for those images set the property hw_pointer_model=usbtablet False and for those images set the property hw_pointer_model=usbtablet
unique-server-names:
type: string
default:
description: |
Sets the scope of the check for unique instance names.
.
An empty value (the default) means that no uniqueness check is done and
duplicate names are possible. 'project': The instance name check is done
only for instances within the same project. 'global': The instance name
check is done for all instances regardless of the project.

View File

@ -404,6 +404,7 @@ class NovaConfigContext(ch_context.WorkerConfigContext):
ctxt['console_access_port'] = hookenv.config('console-access-port') ctxt['console_access_port'] = hookenv.config('console-access-port')
ctxt['scheduler_host_subset_size'] = hookenv.config( ctxt['scheduler_host_subset_size'] = hookenv.config(
'scheduler-host-subset-size') 'scheduler-host-subset-size')
ctxt['unique_server_names'] = hookenv.config('unique-server-names')
return ctxt return ctxt

View File

@ -24,6 +24,9 @@ auth_strategy=keystone
compute_driver=libvirt.LibvirtDriver compute_driver=libvirt.LibvirtDriver
use_ipv6 = {{ use_ipv6 }} use_ipv6 = {{ use_ipv6 }}
osapi_compute_listen = {{ bind_host }} osapi_compute_listen = {{ bind_host }}
{% if unique_server_names -%}
osapi_compute_unique_unique_server_names = {{ unique_server_names }}
{% endif -%}
metadata_host = {{ bind_host }} metadata_host = {{ bind_host }}
s3_listen = {{ bind_host }} s3_listen = {{ bind_host }}
ec2_listen = {{ bind_host }} ec2_listen = {{ bind_host }}

View File

@ -24,6 +24,9 @@ auth_strategy=keystone
compute_driver=libvirt.LibvirtDriver compute_driver=libvirt.LibvirtDriver
use_ipv6 = {{ use_ipv6 }} use_ipv6 = {{ use_ipv6 }}
osapi_compute_listen = {{ bind_host }} osapi_compute_listen = {{ bind_host }}
{% if unique_server_names -%}
osapi_compute_unique_unique_server_names = {{ unique_server_names }}
{% endif -%}
metadata_host = {{ bind_host }} metadata_host = {{ bind_host }}
s3_listen = {{ bind_host }} s3_listen = {{ bind_host }}
ec2_listen = {{ bind_host }} ec2_listen = {{ bind_host }}

View File

@ -23,6 +23,9 @@ auth_strategy=keystone
compute_driver=libvirt.LibvirtDriver compute_driver=libvirt.LibvirtDriver
use_ipv6 = {{ use_ipv6 }} use_ipv6 = {{ use_ipv6 }}
osapi_compute_listen = {{ bind_host }} osapi_compute_listen = {{ bind_host }}
{% if unique_server_names -%}
osapi_compute_unique_unique_server_names = {{ unique_server_names }}
{% endif -%}
metadata_host = {{ bind_host }} metadata_host = {{ bind_host }}
s3_listen = {{ bind_host }} s3_listen = {{ bind_host }}
ec2_listen = {{ bind_host }} ec2_listen = {{ bind_host }}

View File

@ -22,6 +22,9 @@ auth_strategy=keystone
compute_driver=libvirt.LibvirtDriver compute_driver=libvirt.LibvirtDriver
use_ipv6 = {{ use_ipv6 }} use_ipv6 = {{ use_ipv6 }}
osapi_compute_listen = {{ bind_host }} osapi_compute_listen = {{ bind_host }}
{% if unique_server_names -%}
osapi_compute_unique_unique_server_names = {{ unique_server_names }}
{% endif -%}
metadata_host = {{ bind_host }} metadata_host = {{ bind_host }}
s3_listen = {{ bind_host }} s3_listen = {{ bind_host }}
enable_new_services = {{ enable_new_services }} enable_new_services = {{ enable_new_services }}

View File

@ -22,6 +22,9 @@ auth_strategy=keystone
compute_driver=libvirt.LibvirtDriver compute_driver=libvirt.LibvirtDriver
use_ipv6 = {{ use_ipv6 }} use_ipv6 = {{ use_ipv6 }}
osapi_compute_listen = {{ bind_host }} osapi_compute_listen = {{ bind_host }}
{% if unique_server_names -%}
osapi_compute_unique_unique_server_names = {{ unique_server_names }}
{% endif -%}
metadata_host = {{ bind_host }} metadata_host = {{ bind_host }}
s3_listen = {{ bind_host }} s3_listen = {{ bind_host }}
enable_new_services = {{ enable_new_services }} enable_new_services = {{ enable_new_services }}

View File

@ -19,6 +19,9 @@ enabled_apis=osapi_compute,metadata
compute_driver=libvirt.LibvirtDriver compute_driver=libvirt.LibvirtDriver
use_ipv6 = {{ use_ipv6 }} use_ipv6 = {{ use_ipv6 }}
osapi_compute_listen = {{ bind_host }} osapi_compute_listen = {{ bind_host }}
{% if unique_server_names -%}
osapi_compute_unique_unique_server_names = {{ unique_server_names }}
{% endif -%}
metadata_host = {{ bind_host }} metadata_host = {{ bind_host }}
s3_listen = {{ bind_host }} s3_listen = {{ bind_host }}
enable_new_services = {{ enable_new_services }} enable_new_services = {{ enable_new_services }}

View File

@ -19,6 +19,9 @@ enabled_apis=osapi_compute,metadata
compute_driver=libvirt.LibvirtDriver compute_driver=libvirt.LibvirtDriver
use_ipv6 = {{ use_ipv6 }} use_ipv6 = {{ use_ipv6 }}
osapi_compute_listen = {{ bind_host }} osapi_compute_listen = {{ bind_host }}
{% if unique_server_names -%}
osapi_compute_unique_unique_server_names = {{ unique_server_names }}
{% endif -%}
metadata_host = {{ bind_host }} metadata_host = {{ bind_host }}
s3_listen = {{ bind_host }} s3_listen = {{ bind_host }}
enable_new_services = {{ enable_new_services }} enable_new_services = {{ enable_new_services }}

View File

@ -19,6 +19,9 @@ enabled_apis=osapi_compute,metadata
compute_driver=libvirt.LibvirtDriver compute_driver=libvirt.LibvirtDriver
use_ipv6 = {{ use_ipv6 }} use_ipv6 = {{ use_ipv6 }}
osapi_compute_listen = {{ bind_host }} osapi_compute_listen = {{ bind_host }}
{% if unique_server_names -%}
osapi_compute_unique_unique_server_names = {{ unique_server_names }}
{% endif -%}
metadata_host = {{ bind_host }} metadata_host = {{ bind_host }}
s3_listen = {{ bind_host }} s3_listen = {{ bind_host }}
enable_new_services = {{ enable_new_services }} enable_new_services = {{ enable_new_services }}

View File

@ -334,6 +334,7 @@ class NovaComputeContextTests(CharmTestCase):
mock_config_ip.side_effect = self.test_config.get mock_config_ip.side_effect = self.test_config.get
mock_unit_get.return_value = '127.0.0.1' mock_unit_get.return_value = '127.0.0.1'
self.test_config.set('scheduler-default-filters', 'TestFilter') self.test_config.set('scheduler-default-filters', 'TestFilter')
self.test_config.set('unique-server-names', 'project')
ctxt = context.NovaConfigContext()() ctxt = context.NovaConfigContext()()
self.assertEqual(ctxt['scheduler_default_filters'], self.assertEqual(ctxt['scheduler_default_filters'],
self.config('scheduler-default-filters')) self.config('scheduler-default-filters'))
@ -379,6 +380,8 @@ class NovaComputeContextTests(CharmTestCase):
self.config('console-access-protocol')) self.config('console-access-protocol'))
self.assertEqual(ctxt['console_access_port'], self.assertEqual(ctxt['console_access_port'],
self.config('console-access-port')) self.config('console-access-port'))
self.assertEqual(ctxt['unique_server_names'],
self.config('unique-server-names'))
_pci_alias1 = { _pci_alias1 = {
"name": "IntelNIC", "name": "IntelNIC",