FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix regression in Host.os_type by zmc · Pull Request #44 · ceph/ceph-devstack · GitHub

Repository navigation

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

Filter by extension

Filter by extension .py  (3) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
1 change: 1 addition & 0 deletions ceph_devstack/host.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL