Add support for 'default_availability_zone' parameter.
I've added support for 'default_availability_zone' parameter. I've added charm parameter, modified 'nova.conf' templates and implemented it to be exposed via 'neutron-plugin' relation settings. Change-Id: I85008ac0f3540a2b5c817893d63e497b63f43043 Closes-Bug: 1595937
This commit is contained in:
13
config.yaml
13
config.yaml
@@ -331,3 +331,16 @@ options:
|
||||
description: |
|
||||
Experimental enable apparmor profile. Valid settings: 'complain', 'enforce' or 'disable'.
|
||||
AA disabled by default.
|
||||
default-availability-zone:
|
||||
type: string
|
||||
default: 'nova'
|
||||
description: |
|
||||
Default compute node availability zone.
|
||||
.
|
||||
This option determines the availability zone to be used when it is not
|
||||
specified in the VM creation request. If this option is not set, the
|
||||
default availability zone 'nova' is used.
|
||||
.
|
||||
NOTE: Availability zones must be created manually using the
|
||||
'openstack aggregate create' command.
|
||||
.
|
||||
|
@@ -645,3 +645,13 @@ class NovaNetworkAppArmorContext(context.AppArmorContext):
|
||||
return self.ctxt
|
||||
self._ctxt.update({'aa_profile': self.aa_profile})
|
||||
return self.ctxt
|
||||
|
||||
|
||||
class NovaComputeAvailabilityZoneContext(context.OSContextGenerator):
|
||||
|
||||
def __call__(self):
|
||||
ctxt = {}
|
||||
if config('default-availability-zone'):
|
||||
ctxt['default_availability_zone'] = config(
|
||||
'default-availability-zone')
|
||||
return ctxt
|
||||
|
@@ -445,7 +445,8 @@ def update_nrpe_config():
|
||||
@hooks.hook('neutron-plugin-relation-joined')
|
||||
def neutron_plugin_joined(relid=None, remote_restart=False):
|
||||
rel_settings = {
|
||||
'hugepage_number': get_hugepage_number()
|
||||
'hugepage_number': get_hugepage_number(),
|
||||
'default_availability_zone': config('default-availability-zone')
|
||||
}
|
||||
if remote_restart:
|
||||
rel_settings['restart-trigger'] = str(uuid.uuid4())
|
||||
|
@@ -111,6 +111,7 @@ from nova_compute_context import (
|
||||
NovaComputeAppArmorContext,
|
||||
NovaNetworkAppArmorContext,
|
||||
SerialConsoleContext,
|
||||
NovaComputeAvailabilityZoneContext,
|
||||
)
|
||||
|
||||
CA_CERT_PATH = '/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt'
|
||||
@@ -226,7 +227,8 @@ BASE_RESOURCE_MAP = {
|
||||
NovaComputeVirtContext(),
|
||||
context.LogLevelContext(),
|
||||
context.InternalEndpointContext(),
|
||||
SerialConsoleContext()],
|
||||
SerialConsoleContext(),
|
||||
NovaComputeAvailabilityZoneContext()],
|
||||
},
|
||||
NOVA_API_AA_PROFILE_PATH: {
|
||||
'services': ['nova-api'],
|
||||
|
@@ -138,6 +138,10 @@ instances_path = {{ instances_path }}
|
||||
{% endfor -%}
|
||||
{% endif -%}
|
||||
|
||||
{% if default_availability_zone -%}
|
||||
default_availability_zone = {{ default_availability_zone }}
|
||||
{% endif -%}
|
||||
|
||||
{% if console_access_protocol == 'spice' -%}
|
||||
[spice]
|
||||
agent_enabled = True
|
||||
|
@@ -131,6 +131,10 @@ instances_path = {{ instances_path }}
|
||||
{% endfor -%}
|
||||
{% endif -%}
|
||||
|
||||
{% if default_availability_zone -%}
|
||||
default_availability_zone = {{ default_availability_zone }}
|
||||
{% endif -%}
|
||||
|
||||
{% if console_access_protocol == 'spice' -%}
|
||||
[spice]
|
||||
agent_enabled = True
|
||||
|
@@ -124,6 +124,10 @@ pci_passthrough_whitelist = {{ pci_passthrough_whitelist }}
|
||||
|
||||
{% include "section-zeromq" %}
|
||||
|
||||
{% if default_availability_zone -%}
|
||||
default_availability_zone = {{ default_availability_zone }}
|
||||
{% endif -%}
|
||||
|
||||
{% if network_manager == 'neutron' and network_manager_config -%}
|
||||
[neutron]
|
||||
url = {{ network_manager_config.neutron_url }}
|
||||
|
@@ -130,6 +130,10 @@ pci_passthrough_whitelist = {{ pci_passthrough_whitelist }}
|
||||
|
||||
{% include "section-zeromq" %}
|
||||
|
||||
{% if default_availability_zone -%}
|
||||
default_availability_zone = {{ default_availability_zone }}
|
||||
{% endif -%}
|
||||
|
||||
{% if network_manager == 'neutron' and network_manager_config -%}
|
||||
[neutron]
|
||||
url = {{ network_manager_config.neutron_url }}
|
||||
|
@@ -131,6 +131,10 @@ pci_passthrough_whitelist = {{ pci_passthrough_whitelist }}
|
||||
|
||||
{% include "section-zeromq" %}
|
||||
|
||||
{% if default_availability_zone -%}
|
||||
default_availability_zone = {{ default_availability_zone }}
|
||||
{% endif -%}
|
||||
|
||||
{% if network_manager == 'neutron' and network_manager_config -%}
|
||||
[neutron]
|
||||
url = {{ network_manager_config.neutron_url }}
|
||||
@@ -220,4 +224,4 @@ disable_libvirt_livesnapshot = False
|
||||
|
||||
{% include "parts/section-ephemeral" %}
|
||||
|
||||
{% include "parts/section-serial-console" %}
|
||||
{% include "parts/section-serial-console" %}
|
||||
|
@@ -557,18 +557,26 @@ class NovaComputeRelationsTests(CharmTestCase):
|
||||
def test_neutron_plugin_joined_relid(self, get_hugepage_number):
|
||||
get_hugepage_number.return_value = None
|
||||
hooks.neutron_plugin_joined(relid='relid23')
|
||||
expect_rel_settings = {
|
||||
'hugepage_number': None,
|
||||
'default_availability_zone': 'nova',
|
||||
}
|
||||
self.relation_set.assert_called_with(
|
||||
relation_id='relid23',
|
||||
**{'hugepage_number': None}
|
||||
**expect_rel_settings
|
||||
)
|
||||
|
||||
@patch.object(hooks, 'get_hugepage_number')
|
||||
def test_neutron_plugin_joined_huge(self, get_hugepage_number):
|
||||
get_hugepage_number.return_value = 12
|
||||
hooks.neutron_plugin_joined()
|
||||
expect_rel_settings = {
|
||||
'hugepage_number': 12,
|
||||
'default_availability_zone': 'nova',
|
||||
}
|
||||
self.relation_set.assert_called_with(
|
||||
relation_id=None,
|
||||
**{'hugepage_number': 12}
|
||||
**expect_rel_settings
|
||||
)
|
||||
|
||||
@patch.object(hooks, 'get_hugepage_number')
|
||||
@@ -579,6 +587,7 @@ class NovaComputeRelationsTests(CharmTestCase):
|
||||
expect_rel_settings = {
|
||||
'hugepage_number': None,
|
||||
'restart-trigger': 'e030b959-7207',
|
||||
'default_availability_zone': 'nova',
|
||||
}
|
||||
self.relation_set.assert_called_with(
|
||||
relation_id=None,
|
||||
|
Reference in New Issue
Block a user