Skip to content

Commit

Permalink
add support for availability zone in OVN cms options
Browse files Browse the repository at this point in the history
LP#2002449 That fix enables AZ support in OVN via external-ids:ovn-cms-options
It relies on JUJU_AVAILABILITY_ZONE env variable.
  • Loading branch information
mastier committed Mar 15, 2023
1 parent 4562fbb commit ab51fc4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,16 @@ options:
.
NOTE: It is also possible to enable this option on several OVN chassis
applications at the same time, e.g. on 2 out of 3.
customize-failure-domain:
type: boolean
default: false
description: |
Juju propagates availability zone information to charms from the
underlying machine provider such as MAAS and this option allows the
charm to use JUJU_AVAILABILITY_ZONE to set default_availability_zone for
Nova nodes. This option overrides the default-availability-zone charm
config setting only when the Juju provider sets JUJU_AVAILABILITY_ZONE.
More details: https://docs.openstack.org/neutron/latest/admin/ovn/availability_zones.html
nagios_context:
default: "juju"
type: string
Expand Down
4 changes: 4 additions & 0 deletions lib/charms/ovn_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,10 @@ def _get_ovn_cms_options(self):
if self.options.card_serial_number:
cms_opts.append(
f'card-serial-number={self.options.card_serial_number}')
if self.options.customize_failure_domain and \
'JUJU_AVAILABILITY_ZONE' in os.environ:
cms_opts.append(
f'availability-zones={os.environ["JUJU_AVAILABILITY_ZONE"]}')
return cms_opts

def render_nrpe(self):
Expand Down
10 changes: 10 additions & 0 deletions unit_tests/test_lib_charms_ovn_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import collections
import copy
import io
import os
import textwrap
import subprocess
import unittest.mock as mock
Expand Down Expand Up @@ -764,6 +765,7 @@ def setUp(self):
'vpd-device-spec': '',
'pmd-cpu-set': '',
'ovn-source': 'distro',
'customize-failure-domain': False,
})
self.patch_object(ovn_charm.OVNConfigurationAdapter,
'_ovs_dpdk_cpu_overlap_check')
Expand Down Expand Up @@ -1097,6 +1099,7 @@ def setUp(self):
'[{"bus": "pci", "vendor_id": "beef", "device_id": "cafe"}]',
'ovn-source': 'distro',
'ovs-exporter-channel': '',
'customize-failure-domain': False,
})

def test_optional_openstack_metadata(self):
Expand Down Expand Up @@ -1734,6 +1737,13 @@ def test_assess_exporter_no_channel_not_installed(self):
self.refresh.assert_not_called()
self.remove.assert_not_called()

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


class TestOVNChassisCharmOvsExporter(Helper):

Expand Down

0 comments on commit ab51fc4

Please sign in to comment.