
OVS crashes if there are multiple conflicting installations. As such, the charm currently errors out when detecting system OVS services. The problem is that with DPDK, we expect OVS bridges and bonds to be preconfigured through MAAS/Netplan, which currently use system (deb) OVS packages. Instead of erroring out, we'll stop and mask system OVS services, then reapply Netplan to move the OVS bridges to the snap based OVS installation. Netplan is expected to contain the following patch: https://github.com/canonical/netplan/pull/549 Note that any configuration defined in the system OVS db that's not set in Netplan will be lost. Change-Id: Id398a2e4ef4cd138aa2db35d71e021f61f94b67d Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
68 lines
2.1 KiB
Python
68 lines
2.1 KiB
Python
# Copyright 2023 Canonical Ltd.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
"""Tests for Openstack hypervisor utils."""
|
|
|
|
import unittest
|
|
from unittest import (
|
|
mock,
|
|
)
|
|
|
|
import utils
|
|
|
|
|
|
class TestOpenstackHypervisorUtils(unittest.TestCase):
|
|
"""Tests for Openstack hypervisor utils."""
|
|
|
|
@mock.patch("subprocess.run")
|
|
def test_get_systemd_unit_status_not_found(self, mock_run):
|
|
"""Test retrieving inexistent systemd unit status."""
|
|
mock_run.return_value.stdout = "[]"
|
|
|
|
self.assertIsNone(utils.get_systemd_unit_status("test.service"))
|
|
|
|
@mock.patch("subprocess.run")
|
|
def test_get_systemd_unit_status(self, mock_run):
|
|
"""Test retrieving systemd unit status."""
|
|
mock_run.return_value.stdout = (
|
|
'[{"unit":"ovs-vswitchd.service","load":"masked",'
|
|
'"active":"inactive","sub":"dead",'
|
|
'"description":"ovs-vswitchd.service"}]'
|
|
)
|
|
|
|
exp_out = {
|
|
"name": "ovs-vswitchd.service",
|
|
"load_state": "masked",
|
|
"active_state": "inactive",
|
|
"substate": "dead",
|
|
"description": "ovs-vswitchd.service",
|
|
}
|
|
out = utils.get_systemd_unit_status("ovs-vswitchd.service")
|
|
|
|
self.assertEqual(exp_out, out)
|
|
mock_run.assert_called_once_with(
|
|
[
|
|
"systemctl",
|
|
"list-units",
|
|
"--all",
|
|
"-o",
|
|
"json",
|
|
"--no-pager",
|
|
"ovs-vswitchd.service",
|
|
],
|
|
capture_output=True,
|
|
text=True,
|
|
check=True,
|
|
)
|