-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect if plugin is runnable as classmethod
This permits us to check much earlier and without having to instantiate the plugin which has a lot of pre-requisites.
- Loading branch information
Showing
44 changed files
with
458 additions
and
232 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,32 +1,42 @@ | ||
from functools import cached_property | ||
from dataclasses import dataclass, field | ||
|
||
from hotsos.core.plugintools import PluginPartBase | ||
from hotsos.core.host_helpers import ( | ||
APTPackageHelper, | ||
InstallInfoBase, | ||
SystemdHelper, | ||
) | ||
|
||
CORE_APT = ['landscape'] | ||
SERVICE_EXPRS = [s + '[A-Za-z0-9-]*' for s in CORE_APT] | ||
|
||
|
||
@dataclass | ||
class LandscapeInstallInfo(InstallInfoBase): | ||
""" Landscape installation information. """ | ||
apt: APTPackageHelper = field(default_factory=lambda: | ||
APTPackageHelper(core_pkgs=CORE_APT)) | ||
systemd: SystemdHelper = field(default_factory=lambda: | ||
SystemdHelper(service_exprs=SERVICE_EXPRS)) | ||
|
||
|
||
class LandscapeChecks(PluginPartBase): | ||
""" Base class for all Landscape checks. """ | ||
plugin_name = 'landscape' | ||
plugin_root_index = 14 | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.apt = APTPackageHelper(core_pkgs=CORE_APT) | ||
self.systemd = SystemdHelper(service_exprs=SERVICE_EXPRS) | ||
super().__init__() | ||
LandscapeInstallInfo().mixin(self) | ||
|
||
@cached_property | ||
def is_installed(self): | ||
if self.apt.core: | ||
@classmethod | ||
def is_runnable(cls): | ||
""" | ||
Determine whether or not this plugin can and should be run. | ||
@return: True or False | ||
""" | ||
if LandscapeInstallInfo().apt.core: | ||
return True | ||
|
||
return False | ||
|
||
@property | ||
def plugin_runnable(self): | ||
return self.is_installed |
This file contains 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
Oops, something went wrong.