Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Make LocalNode and RemoteNode extendable classes (yml-wise).
We do so by making use of BaseClassWithRunbookMixin, on the actual instance classes, and ExtendableSchemaMixin, on the respective schema classes. This makes it possible to have custom, type-defined sections on general (SUT) nodes coming from the runbook, together with Platform and Notifier. This will come in handy for LISA users who have node logic/fields that go beyond what is originally defined to work for (e.g.) Azure. Example of power/usage: By declaring this, on code: @dataclass_json() @DataClass class MyNodeSchema(schema.RemoteNode): type: str = field( default=MYNAME, metadata=schema.metadata( required=True, validate=validate.OneOf([MYNAME]), ), ) my_example_extra_field: Optional[str] = field(default=None) class MyNode(node.RemoteNode): def __init__( self, index: int, runbook: MyNodeSchema, logger_name: str, base_log_path: Optional[Path] = None, name: str = "", ) -> None: super().__init__(index, runbook, logger_name=logger_name, base_log_path=base_log_path, name=name) self.my_example_extra_field = runbook.my_example_extra_field assert self.my_example_extra_field, \ f"my_example_extra_field field of {MYNAME}-typed " \ "nodes cannot be empty " @classmethod def type_name(cls) -> str: return MYNAME @classmethod def type_schema(cls) -> Type[schema.TypedSchema]: return MyNodeSchema one is able to do this, yml-wise: environment: warn_as_error: true environments: - nodes: - type: MYNAME public_address: ... public_port: ... username: ... password: ... -> my_example_extra_field: ... Of course, custom logic for only that type of node will be at your fingertips, just by extending/overriding your node class. Of course this is advanced usage and not meant for the average user. UTs were added to help enforce regression testing. ammend to nodes
- Loading branch information