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
20 changes: 18 additions & 2 deletions kt/commands/list_kernels/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,31 @@

epilog = """
It list all the kernels we currently maintain.
If --automated or -a is used, it will list all the kernels we maintain
but are also part of KernelCI.

Example:

\b
$ kt list-kernels
cbr-7.9
fipslegacy-8.6
lts-8.6
lts-9.2
lts-9.4
lts-9.6

\b
$ kt list-kernels --automated
lts-8.6
lts-9.2
lts-9.4
lts-9.6

"""


@click.command(epilog=epilog)
def list_kernels():
main()
@click.option("-a", "--automated", is_flag=True, help="It selects only automated kernels")
def list_kernels(automated):
main(automated)
8 changes: 5 additions & 3 deletions kt/commands/list_kernels/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
from kt.ktlib.kernels import KernelsInfo


def main():
def main(automated: bool = False):
config = Config.load()
kernels = KernelsInfo.from_yaml(config=config).kernels
for k in sorted(kernels):
print(k)

for k in sorted(kernels.values(), key=lambda k: k.name):
if not automated or k.automated:
print(k.name)
13 changes: 6 additions & 7 deletions kt/data/kernels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,44 @@ kernels:
dist_git_root: dist-git-tree-cbr
dist_git_branch: cbr79-7
mock_config: centos-cbr79
automated: false

lts-8.6:
src_tree_root: kernel-src-tree
src_tree_branch: ciqlts8_6
dist_git_root: dist-git-tree-lts
dist_git_branch: lts86-8
mock_config: rocky-lts86
automated: true

lts-9.2:
src_tree_root: kernel-src-tree
src_tree_branch: ciqlts9_2
dist_git_root: dist-git-tree-lts
dist_git_branch: lts92-9
mock_config: rocky-lts92
automated: true

lts-9.4:
src_tree_root: kernel-src-tree
src_tree_branch: ciqlts9_4
dist_git_root: dist-git-tree-lts
dist_git_branch: lts94-9
mock_config: rocky-lts94
automated: true

lts-9.6:
src_tree_root: kernel-src-tree
src_tree_branch: ciqlts9_6
dist_git_root: dist-git-tree-lts
dist_git_branch: lts96-9
mock_config: rocky-lts96
automated: true

fipslegacy-8.6:
src_tree_root: kernel-src-tree
src_tree_branch: fips-legacy-8-compliant/4.18.0-425.13.1
dist_git_root: dist-git-tree-fips
dist_git_branch: fips-compliant8
mock_config: rocky-lts86-fips

fips-9.2:
src_tree_root: kernel-src-tree
src_tree_branch: fips-9-compliant/5.14.0-284.30.1
dist_git_root: dist-git-tree-fips
dist_git_branch: el92-fips-compliant-9
mock_config: rocky-fips92
automated: false
10 changes: 6 additions & 4 deletions kt/ktlib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,23 @@ class Config:
images_dir: Path

ssh_key: Path
user: str

DEFAULT: ClassVar = {
"base_path": "~/ciq",
"kernels_dir": "~/ciq/kernels",
"images_source_dir": "~/ciq/default_test_images",
"images_dir": "~/ciq/tmp/virt-images",
"ssh_key": "~/.ssh/id_ed25519_generic.pub",
"user": os.environ["USER"],
}

@classmethod
def from_str_dict(cls, data: dict[str, str]):
# Transform the str values to Path
new_data = {k: Path(v).expanduser() for k, v in data.items()}

if not all(v.is_absolute() for v in new_data.values()):
# Transform the str values to Path except for user
non_path_keys = {"user"}
new_data = {k: (Path(v).expanduser() if k not in non_path_keys else v) for k, v in data.items()}
if not all(v.is_absolute() for k, v in new_data.items() if k not in non_path_keys):
raise ValueError("all paths should be absolute; check your config")

return cls(**new_data)
Expand Down
3 changes: 1 addition & 2 deletions kt/ktlib/kernel_workspace.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
import os
from dataclasses import dataclass

from git import GitCommandError, Repo
Expand Down Expand Up @@ -171,7 +170,7 @@ def load(cls, name: str, config: Config, kernel_info: KernelInfo, extra: str):
name = name + "_" + extra

folder = config.kernels_dir / Path(name)
user = os.environ["USER"]
user = config.user
default_remote = "origin"

dist_folder = folder / Path(Constants.DIST_TREE)
Expand Down
2 changes: 2 additions & 0 deletions kt/ktlib/kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class KernelInfo:

mock_config: str

automated: bool


@dataclass
class KernelsInfo:
Expand Down
8 changes: 4 additions & 4 deletions kt/ktlib/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ def _setup_cloud_init(self, config: Config):
data = yaml.safe_load(f)

# replace placeholders with user data
data["users"][0]["name"] = os.environ["USER"]
data["users"][0]["name"] = config.user

# password remains the default for now
data["chpasswd"]["list"][0] = f"{os.environ['USER']}:test"
data["chpasswd"]["list"][0] = f"{config.user}:test"

# ssh key
with open(config.ssh_key) as f:
Expand All @@ -157,8 +157,8 @@ def _setup_cloud_init(self, config: Config):

# Because $HOME is the same as the host, during boot, cloud-init
# sees the home dir already exists and root remains the owner
# change it to $USER
data["runcmd"][0][1] = f"{os.environ['USER']}:{os.environ['USER']}"
# change it to {config.user}
data["runcmd"][0][1] = f"{config.user}:{config.user}"
data["runcmd"][0][2] = os.environ["HOME"]

# Install packages needed later
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ py-modules = []
[tool.setuptools.packages.find]
where = ["."]
include = ["kt*"]

[tool.setuptools.package-data]
"kt" = ["data/*.yaml"]