diff --git a/config.yaml b/config.yaml index e08fef2d..2908bdd0 100644 --- a/config.yaml +++ b/config.yaml @@ -617,3 +617,13 @@ options: . For Windows guests is recommended to set this to configuration option to 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. diff --git a/hooks/nova_cc_context.py b/hooks/nova_cc_context.py index 5d996861..84040c90 100644 --- a/hooks/nova_cc_context.py +++ b/hooks/nova_cc_context.py @@ -404,6 +404,7 @@ class NovaConfigContext(ch_context.WorkerConfigContext): ctxt['console_access_port'] = hookenv.config('console-access-port') ctxt['scheduler_host_subset_size'] = hookenv.config( 'scheduler-host-subset-size') + ctxt['unique_server_names'] = hookenv.config('unique-server-names') return ctxt diff --git a/templates/icehouse/nova.conf b/templates/icehouse/nova.conf index ffa62be9..1b08e1a2 100644 --- a/templates/icehouse/nova.conf +++ b/templates/icehouse/nova.conf @@ -24,6 +24,9 @@ auth_strategy=keystone compute_driver=libvirt.LibvirtDriver use_ipv6 = {{ use_ipv6 }} osapi_compute_listen = {{ bind_host }} +{% if unique_server_names -%} +osapi_compute_unique_unique_server_names = {{ unique_server_names }} +{% endif -%} metadata_host = {{ bind_host }} s3_listen = {{ bind_host }} ec2_listen = {{ bind_host }} diff --git a/templates/juno/nova.conf b/templates/juno/nova.conf index 25a1b80f..0238f262 100644 --- a/templates/juno/nova.conf +++ b/templates/juno/nova.conf @@ -24,6 +24,9 @@ auth_strategy=keystone compute_driver=libvirt.LibvirtDriver use_ipv6 = {{ use_ipv6 }} osapi_compute_listen = {{ bind_host }} +{% if unique_server_names -%} +osapi_compute_unique_unique_server_names = {{ unique_server_names }} +{% endif -%} metadata_host = {{ bind_host }} s3_listen = {{ bind_host }} ec2_listen = {{ bind_host }} diff --git a/templates/liberty/nova.conf b/templates/liberty/nova.conf index 30d51476..efabdc80 100644 --- a/templates/liberty/nova.conf +++ b/templates/liberty/nova.conf @@ -23,6 +23,9 @@ auth_strategy=keystone compute_driver=libvirt.LibvirtDriver use_ipv6 = {{ use_ipv6 }} osapi_compute_listen = {{ bind_host }} +{% if unique_server_names -%} +osapi_compute_unique_unique_server_names = {{ unique_server_names }} +{% endif -%} metadata_host = {{ bind_host }} s3_listen = {{ bind_host }} ec2_listen = {{ bind_host }} diff --git a/templates/mitaka/nova.conf b/templates/mitaka/nova.conf index de667269..743208fb 100644 --- a/templates/mitaka/nova.conf +++ b/templates/mitaka/nova.conf @@ -22,6 +22,9 @@ auth_strategy=keystone compute_driver=libvirt.LibvirtDriver use_ipv6 = {{ use_ipv6 }} osapi_compute_listen = {{ bind_host }} +{% if unique_server_names -%} +osapi_compute_unique_unique_server_names = {{ unique_server_names }} +{% endif -%} metadata_host = {{ bind_host }} s3_listen = {{ bind_host }} enable_new_services = {{ enable_new_services }} diff --git a/templates/newton/nova.conf b/templates/newton/nova.conf index 8c8a4410..341dd458 100644 --- a/templates/newton/nova.conf +++ b/templates/newton/nova.conf @@ -22,6 +22,9 @@ auth_strategy=keystone compute_driver=libvirt.LibvirtDriver use_ipv6 = {{ use_ipv6 }} osapi_compute_listen = {{ bind_host }} +{% if unique_server_names -%} +osapi_compute_unique_unique_server_names = {{ unique_server_names }} +{% endif -%} metadata_host = {{ bind_host }} s3_listen = {{ bind_host }} enable_new_services = {{ enable_new_services }} diff --git a/templates/ocata/nova.conf b/templates/ocata/nova.conf index aed4f19c..c32b199b 100644 --- a/templates/ocata/nova.conf +++ b/templates/ocata/nova.conf @@ -19,6 +19,9 @@ enabled_apis=osapi_compute,metadata compute_driver=libvirt.LibvirtDriver use_ipv6 = {{ use_ipv6 }} osapi_compute_listen = {{ bind_host }} +{% if unique_server_names -%} +osapi_compute_unique_unique_server_names = {{ unique_server_names }} +{% endif -%} metadata_host = {{ bind_host }} s3_listen = {{ bind_host }} enable_new_services = {{ enable_new_services }} diff --git a/templates/pike/nova.conf b/templates/pike/nova.conf index b39e1ec3..3775575f 100644 --- a/templates/pike/nova.conf +++ b/templates/pike/nova.conf @@ -19,6 +19,9 @@ enabled_apis=osapi_compute,metadata compute_driver=libvirt.LibvirtDriver use_ipv6 = {{ use_ipv6 }} osapi_compute_listen = {{ bind_host }} +{% if unique_server_names -%} +osapi_compute_unique_unique_server_names = {{ unique_server_names }} +{% endif -%} metadata_host = {{ bind_host }} s3_listen = {{ bind_host }} enable_new_services = {{ enable_new_services }} diff --git a/templates/rocky/nova.conf b/templates/rocky/nova.conf index d2a11e90..5069ae0f 100644 --- a/templates/rocky/nova.conf +++ b/templates/rocky/nova.conf @@ -19,6 +19,9 @@ enabled_apis=osapi_compute,metadata compute_driver=libvirt.LibvirtDriver use_ipv6 = {{ use_ipv6 }} osapi_compute_listen = {{ bind_host }} +{% if unique_server_names -%} +osapi_compute_unique_unique_server_names = {{ unique_server_names }} +{% endif -%} metadata_host = {{ bind_host }} s3_listen = {{ bind_host }} enable_new_services = {{ enable_new_services }} diff --git a/unit_tests/test_nova_cc_contexts.py b/unit_tests/test_nova_cc_contexts.py index 080a88f3..2bed2310 100644 --- a/unit_tests/test_nova_cc_contexts.py +++ b/unit_tests/test_nova_cc_contexts.py @@ -334,6 +334,7 @@ class NovaComputeContextTests(CharmTestCase): mock_config_ip.side_effect = self.test_config.get mock_unit_get.return_value = '127.0.0.1' self.test_config.set('scheduler-default-filters', 'TestFilter') + self.test_config.set('unique-server-names', 'project') ctxt = context.NovaConfigContext()() self.assertEqual(ctxt['scheduler_default_filters'], self.config('scheduler-default-filters')) @@ -379,6 +380,8 @@ class NovaComputeContextTests(CharmTestCase): self.config('console-access-protocol')) self.assertEqual(ctxt['console_access_port'], self.config('console-access-port')) + self.assertEqual(ctxt['unique_server_names'], + self.config('unique-server-names')) _pci_alias1 = { "name": "IntelNIC",