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

Add initial Node and NodeInfo types and expose node info functionality in Python module #6

Merged
merged 10 commits into from
Aug 31, 2023

Conversation

simu
Copy link
Member

@simu simu commented Aug 30, 2023

The PR adds a new struct Node which is used to represent Reclass nodes and classes, code to load YAML files from the filesystem, and a function which transforms relative class includes into their absolute form, based on the node's location within the inventory structure.

We also add a very simple example inventory in tests/inventory which will be extended with additional cases as new features are implemented.

Additionally, the PR add NodeInfo and NodeInfoMeta types which provide structured forms of the return value of the Python Reclass nodeinfo() method.

Finally, the PR introduces initial versions of as_py_obj() and as_py_dict() for the serde_yaml Value and Mapping types. These won't remain as-is, but allow us to transform serde_yaml data into Python objects for now.

Checklist

  • The PR has a meaningful title. The title will be used to auto generate the changelog
  • PR contains a single logical change (to build a better changelog).
  • Update tests.
  • Categorize the PR by setting a good title and adding one of the labels:
    bug, enhancement, documentation, change, breaking, dependency, internal
    as they show up in the changelog

@simu simu added the enhancement New feature or request label Aug 30, 2023
@simu simu changed the title Add initial NodeInfo types and expose node info functionality in Python module Add initial Node and NodeInfo types and expose node info functionality in Python module Aug 30, 2023
@simu simu force-pushed the feat/basic-inventory branch 4 times, most recently from 79266d9 to a658823 Compare August 31, 2023 09:54
simu added 10 commits August 31, 2023 11:55
The commit adds a new struct `Node` which is used to represent Reclass
nodes and classes, code to load YAML files from the filesystem, and a
function which transforms relative class includes into their absolute
form, based on the node's location within the inventory structure.

We also add a very simple example inventory in `tests/inventory` which
will be extended with additional cases as new features are implemented.
The `NodeInfo` and `NodeInfoMeta` types provide structured forms of the
return value of the Python Reclass `nodeinfo()` method.

We introduce initial versions of `as_py_obj()` and `as_py_dict()` for
the serde_yaml `Value` and `Mapping` types. These won't remain as-is,
but allow us to transform serde_yaml data into Python objects for now.

We also add the `chrono` crate to manage the Node's render timestamp in
Rust. Additionally, we enable the pyo3 `chrono` feature to get
conversion between `chrono::DateTime` and `PyDateTime`.
The `_reclass_` parameter can be used in references in Python reclass.
To allow this, we need to inject the parameter into the Node's
parameters just after we parse the node.
We add a default getter named `__reclass__` for `NodeInfo` which returns
a typed `NodeInfoMeta`, and rename the previous `__reclass__` getter
which returns the `NodeInfoMeta` as a dict to `reclass_as_dict` and make
it a regular method.
@simu simu force-pushed the feat/basic-inventory branch from a658823 to bf1a1e7 Compare August 31, 2023 09:55
@simu simu marked this pull request as ready for review August 31, 2023 09:57
@simu simu requested a review from a team August 31, 2023 09:57
@simu simu merged commit 8659efb into main Aug 31, 2023
@simu simu deleted the feat/basic-inventory branch August 31, 2023 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants