Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ceph_devstack/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def kernel_version(self) -> Version:
self._kernel_version = parse_version(raw_version.split("-")[0])
return self._kernel_version

@property
def os_type(self) -> str:
if not hasattr(self, "_os_type"):
proc = self.run(["uname"])
Expand Down
10 changes: 5 additions & 5 deletions ceph_devstack/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class PodmanPlatform(LocalFixableRequirement):

@property
def fix_cmd(self):
host_os = self.host.os_type()
host_os = self.host.os_type
if host_os == "darwin":
return ["brew", "install", "podman"]
return ["sudo", host.package_manager(), "install", "-y", "podman"]
Expand Down Expand Up @@ -164,7 +164,7 @@ async def check(self):
class PodmanRuntime(Requirement):
@property
def fix_cmd(self):
if self.host.os_type() != "darwin":
if self.host.os_type != "darwin":
return ["sudo", self.host.package_manager(), "install", "-y", "crun"]
return []

Expand Down Expand Up @@ -214,7 +214,7 @@ class PodmanDNSPlugin(FixableRequirement):

@property
def dns_plugin_path(self):
os_type = self.host.os_type()
os_type = self.host.os_type
if os_type in ["ubuntu", "debian"]:
return "/usr/lib/cni/dnsname"
return "/usr/libexec/cni/dnsname"
Expand All @@ -225,7 +225,7 @@ def check_cmd(self):

@property
def fix_cmd(self):
os_type = self.host.os_type()
os_type = self.host.os_type
if os_type == "centos":
return ["sudo", "dnf", "install", "-y", self.dns_plugin_path]
elif os_type in ["ubuntu", "debian"]:
Expand Down Expand Up @@ -261,7 +261,7 @@ class AppArmorProfile(FixableRequirement):
async def check_requirements():
if not await PodmanPlatform().evaluate():
return False
if local_host.os_type() == "darwin":
if local_host.os_type == "darwin":
if not await PodmanMachinePresent().evaluate():
return False
if not await PodmanMachineRunning().evaluate():
Expand Down
7 changes: 5 additions & 2 deletions tests/test_requirements_core.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio
import pytest
from packaging.version import parse as parse_version
from unittest.mock import AsyncMock, MagicMock, patch
from unittest.mock import AsyncMock, MagicMock, patch, PropertyMock


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

def test_podman_dns_plugin_config(self, cls, os_type, dns_plugin_path):
with patch.object(cls.host, "os_type", return_value=os_type):
with patch(
"ceph_devstack.host.Host.os_type", new_callable=PropertyMock
) as MockHost:
MockHost.return_value = os_type
req = cls()
assert req.check_cmd == ["test", "-x", dns_plugin_path]

Expand Down
Loading