Skip to content

Commit c884832

Browse files
authored
Merge pull request #44 from ceph/mu-fix
Fix regression in Host.os_type
2 parents d566bad + 20fbfe6 commit c884832

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

‎ceph_devstack/host.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def kernel_version(self) -> Version:
7373
self._kernel_version = parse_version(raw_version.split("-")[0])
7474
return self._kernel_version
7575

76+
@property
7677
def os_type(self) -> str:
7778
if not hasattr(self, "_os_type"):
7879
proc = self.run(["uname"])

‎ceph_devstack/requirements.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class PodmanPlatform(LocalFixableRequirement):
5656

5757
@property
5858
def fix_cmd(self):
59-
host_os = self.host.os_type()
59+
host_os = self.host.os_type
6060
if host_os == "darwin":
6161
return ["brew", "install", "podman"]
6262
return ["sudo", host.package_manager(), "install", "-y", "podman"]
@@ -164,7 +164,7 @@ async def check(self):
164164
class PodmanRuntime(Requirement):
165165
@property
166166
def fix_cmd(self):
167-
if self.host.os_type() != "darwin":
167+
if self.host.os_type != "darwin":
168168
return ["sudo", self.host.package_manager(), "install", "-y", "crun"]
169169
return []
170170

@@ -214,7 +214,7 @@ class PodmanDNSPlugin(FixableRequirement):
214214

215215
@property
216216
def dns_plugin_path(self):
217-
os_type = self.host.os_type()
217+
os_type = self.host.os_type
218218
if os_type in ["ubuntu", "debian"]:
219219
return "/usr/lib/cni/dnsname"
220220
return "/usr/libexec/cni/dnsname"
@@ -225,7 +225,7 @@ def check_cmd(self):
225225

226226
@property
227227
def fix_cmd(self):
228-
os_type = self.host.os_type()
228+
os_type = self.host.os_type
229229
if os_type == "centos":
230230
return ["sudo", "dnf", "install", "-y", self.dns_plugin_path]
231231
elif os_type in ["ubuntu", "debian"]:
@@ -261,7 +261,7 @@ class AppArmorProfile(FixableRequirement):
261261
async def check_requirements():
262262
if not await PodmanPlatform().evaluate():
263263
return False
264-
if local_host.os_type() == "darwin":
264+
if local_host.os_type == "darwin":
265265
if not await PodmanMachinePresent().evaluate():
266266
return False
267267
if not await PodmanMachineRunning().evaluate():

‎tests/test_requirements_core.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import asyncio
22
import pytest
33
from packaging.version import parse as parse_version
4-
from unittest.mock import AsyncMock, MagicMock, patch
4+
from unittest.mock import AsyncMock, MagicMock, patch, PropertyMock
55

66

77
from ceph_devstack import config, requirements
@@ -303,7 +303,10 @@ def dns_plugin_path(self, os_type):
303303
return "/usr/lib/cni/dnsname"
304304

305305
def test_podman_dns_plugin_config(self, cls, os_type, dns_plugin_path):
306-
with patch.object(cls.host, "os_type", return_value=os_type):
306+
with patch(
307+
"ceph_devstack.host.Host.os_type", new_callable=PropertyMock
308+
) as MockHost:
309+
MockHost.return_value = os_type
307310
req = cls()
308311
assert req.check_cmd == ["test", "-x", dns_plugin_path]
309312

0 commit comments

Comments
 (0)