55import tmt .steps
66import tmt .steps .provision
77import tmt .utils
8- from tmt .container import container , field
8+ from tmt .container import container , field , option_to_key
99from tmt .guest import RebootMode
1010from tmt .utils import Command , ShellScript
1111from tmt .utils .wait import Waiting
@@ -74,15 +74,17 @@ def to_spec(self) -> tmt.steps._RawStepData:
7474 'systemd-soft-reboot' : str (self .systemd_soft_reboot )
7575 if isinstance (self .systemd_soft_reboot , ShellScript )
7676 else None ,
77- 'hard-reboot' : str (self .systemd_soft_reboot )
78- if isinstance (self .systemd_soft_reboot , ShellScript )
77+ 'hard-reboot' : str (self .hard_reboot )
78+ if isinstance (self .hard_reboot , ShellScript )
7979 else None ,
8080 },
8181 )
8282
8383 def to_minimal_spec (self ) -> tmt .steps ._RawStepData :
8484 spec = {** super ().to_minimal_spec ()}
8585
86+ # Some fields need special handling.
87+ # Map them to functions that will correctly convert them.
8688 field_map : dict [str , Callable [[Any ], Any ]] = {
8789 'soft-reboot' : lambda reboot : str (reboot ) if isinstance (reboot , ShellScript ) else None ,
8890 'systemd-soft-reboot' : lambda reboot : (
@@ -92,9 +94,10 @@ def to_minimal_spec(self) -> tmt.steps._RawStepData:
9294 }
9395
9496 for key , transform in field_map .items ():
95- value = getattr (self , key , None )
97+ value = getattr (self , option_to_key ( key ) , None )
9698 if value is not None :
9799 value = transform (value )
100+ # Do not include empty values
98101 if value in (None , [], {}):
99102 spec .pop (key , None )
100103 else :
0 commit comments