Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provision plugins use self.data instead of self.get() #2578

Merged
merged 1 commit into from
Jan 4, 2024
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
2 changes: 1 addition & 1 deletion tmt/steps/provision/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1813,7 +1813,7 @@ def show(self, keys: Optional[list[str]] = None) -> None:
super().show(keys=keys)

if show_hardware:
hardware: Optional[tmt.hardware.Hardware] = self.get('hardware')
hardware: Optional[tmt.hardware.Hardware] = self.data.hardware

if hardware:
echo(tmt.utils.format('hardware', tmt.utils.dict_to_yaml(hardware.to_spec())))
Expand Down
8 changes: 3 additions & 5 deletions tmt/steps/provision/artemis.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,17 +697,15 @@ def go(self) -> None:
""" Provision the guest """
super().go()

api_version = self.get('api-version')

if api_version not in SUPPORTED_API_VERSIONS:
raise ArtemisProvisionError(f"API version '{api_version}' not supported.")
if self.data.api_version not in SUPPORTED_API_VERSIONS:
raise ArtemisProvisionError(f"API version '{self.data.api_version}' not supported.")

try:
user_data = {
key.strip(): value.strip()
for key, value in (
pair.split('=', 1)
for pair in self.get('user-data')
for pair in self.data.user_data
)
}

Expand Down
11 changes: 2 additions & 9 deletions tmt/steps/provision/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import tmt.steps
import tmt.steps.provision
import tmt.utils
from tmt.utils import Command, ShellScript, field, key_to_option
from tmt.utils import Command, ShellScript, field

DEFAULT_USER = "root"

Expand Down Expand Up @@ -168,7 +168,7 @@ def go(self) -> None:
super().go()

# Check guest and auth info
if not self.get('guest'):
if not self.data.guest:
raise tmt.utils.SpecificationError(
'Provide a host name or an ip address to connect.')

Expand All @@ -177,13 +177,6 @@ def go(self) -> None:
"Custom soft and hard reboot commands are allowed "
"only with the '--feeling-safe' option.")

data = ConnectGuestData(**{
key: self.get(key_to_option(key))
# SIM118: Use `{key} in {dict}` instead of `{key} in {dict}.keys()`.
# "Type[ConnectGuestData]" has no attribute "__iter__" (not iterable)
for key in ConnectGuestData.keys() # noqa: SIM118
})

data = ConnectGuestData.from_plugin(self)

data.show(verbose=self.verbosity_level, logger=self._logger)
Expand Down
2 changes: 1 addition & 1 deletion tmt/steps/provision/podman.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ class ProvisionPodman(tmt.steps.provision.ProvisionPlugin[ProvisionPodmanData]):
def default(self, option: str, default: Any = None) -> Any:
""" Return default data for given option """
if option == 'pull':
return self.get('force-pull', default=default)
return self.data.force_pull

return super().default(option, default=default)

Expand Down
2 changes: 1 addition & 1 deletion tmt/steps/provision/testcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ def go(self) -> None:
""" Provision the testcloud instance """
super().go()

if self.get('list-local-images'):
if self.data.list_local_images:
self._print_local_images()
# Clean up the run workdir and exit
if self.step.plan.my_run:
Expand Down
Loading