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

Allow to limit inventory to some expression #11

Closed
octo47 opened this issue Nov 26, 2013 · 2 comments
Closed

Allow to limit inventory to some expression #11

octo47 opened this issue Nov 26, 2013 · 2 comments

Comments

@octo47
Copy link

octo47 commented Nov 26, 2013

It is good to not load whole inventory, but only part of it.
Some simple expression to limit hosts/classes to display would help.

For example: reclass -i -c class1,class2 -h "w.*host.domain"

@madduck
Copy link
Owner

madduck commented Nov 26, 2013

The limit on the hostnames should be easily done using globbing, as you suggest. Basically, we need to propragate an optional globbing expression into the storage module's inventory()/_list_inventory() method. For yaml_fs, this glob filter then gets applied/evaluated within the register_fn callback.

To make this reasonably future-proof, I suggest that the filter argument be a dictionary, and glob be a key in the dictionary, such that filter['glob'] gets applied during the os.walk iteration, if defined. There could also be a filter['filelist'] with exact filenames, which then would make os.walk unnecessary.

However, limiting on classes will still require the whole inventory to be loaded and then filtered according to class membership. This is because we do not have a mapping from classes to nodenames until after we scanned the whole inventory. This would have to take place after the storage class returns, i.e. in the CLI or the adapters, via a common filter function probably best defined in reclass/__init__.py.

Patches welcome. ;)

@lottspot
Copy link
Collaborator

We're going to go ahead and close out this older issue. If someone comes up with some use cases for this or shows interest in implementing it, we can rehash the discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants