Skip to content

Commit 7e9529c

Browse files
committed
add support for availability zone in OVN cms options
LP#2002449 That fix enables AZ support in OVN via external-ids:ovn-cms-options It relies on JUJU_AVAILABILITY_ZONE env variable.
1 parent 1e312c8 commit 7e9529c

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,16 @@ options:
297297
.
298298
NOTE: It is also possible to enable this option on several OVN chassis
299299
applications at the same time, e.g. on 2 out of 3.
300+
customize-failure-domain:
301+
type: boolean
302+
default: false
303+
description: |
304+
Juju propagates availability zone information to charms from the
305+
underlying machine provider such as MAAS and this option allows the
306+
charm to use JUJU_AVAILABILITY_ZONE to set default_availability_zone for
307+
OVN nodes. This option overrides the default-availability-zone charm
308+
config setting only when the Juju provider sets JUJU_AVAILABILITY_ZONE.
309+
More details: https://docs.openstack.org/neutron/latest/admin/ovn/availability_zones.html
300310
nagios_context:
301311
default: "juju"
302312
type: string

lib/charms/ovn_charm.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,10 @@ def _get_ovn_cms_options(self):
13411341
if self.options.card_serial_number:
13421342
cms_opts.append(
13431343
f'card-serial-number={self.options.card_serial_number}')
1344+
if self.options.customize_failure_domain and \
1345+
'JUJU_AVAILABILITY_ZONE' in os.environ:
1346+
cms_opts.append(
1347+
f'availability-zones={os.environ["JUJU_AVAILABILITY_ZONE"]}')
13441348
return cms_opts
13451349

13461350
def render_nrpe(self):

unit_tests/test_lib_charms_ovn_charm.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import collections
1616
import copy
1717
import io
18+
import os
1819
import textwrap
1920
import subprocess
2021
import unittest.mock as mock
@@ -764,6 +765,7 @@ def setUp(self):
764765
'vpd-device-spec': '',
765766
'pmd-cpu-set': '',
766767
'ovn-source': 'distro',
768+
'customize-failure-domain': False,
767769
})
768770
self.patch_object(ovn_charm.OVNConfigurationAdapter,
769771
'_ovs_dpdk_cpu_overlap_check')
@@ -1097,6 +1099,7 @@ def setUp(self):
10971099
'[{"bus": "pci", "vendor_id": "beef", "device_id": "cafe"}]',
10981100
'ovn-source': 'distro',
10991101
'ovs-exporter-channel': '',
1102+
'customize-failure-domain': False,
11001103
})
11011104

11021105
def test_optional_openstack_metadata(self):
@@ -1734,6 +1737,13 @@ def test_assess_exporter_no_channel_not_installed(self):
17341737
self.refresh.assert_not_called()
17351738
self.remove.assert_not_called()
17361739

1740+
@mock.patch.dict(os.environ, {"JUJU_AVAILABILITY_ZONE": "az1"}, clear=True)
1741+
def test_configure_customize_failure_domain(self):
1742+
self.target.options.customize_failure_domain = True
1743+
self.assertEqual(
1744+
self.target._get_ovn_cms_options(),
1745+
['enable-chassis-as-gw', 'availability-zones=az1'])
1746+
17371747

17381748
class TestOVNChassisCharmOvsExporter(Helper):
17391749

0 commit comments

Comments
 (0)