Skip to content

Commit

Permalink
fiql string in filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
Gevorg-Khachatryaan authored and Gevorg-Khachatryaan committed Oct 19, 2023
1 parent 923e9c7 commit d1c75d1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
8 changes: 6 additions & 2 deletions plugins/doc_fragments/ntnx_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@ class ModuleDocFragment(object):
type: int
filter:
description:
- The filter in FIQL syntax used for the results
- The filter in key-value syntax used for the results
type: dict
custom_filter:
description:
- The filter in FIQL syntax used for the results
- The filter in key-value syntax used for the results
type: dict
filter_string:
description:
- The filter in FIQL syntax used for the results
type: str
"""
9 changes: 9 additions & 0 deletions plugins/module_utils/base_info_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,21 @@ class BaseInfoModule(BaseModule):
length=dict(type="int"),
filter=dict(type="dict"),
custom_filter=dict(type="dict"),
filter_string=dict(type="str"),
)

info_args_mutually_exclusive = [
("filter", "filter_string"),
]

def __init__(self, skip_info_args=False, **kwargs):
self.argument_spec = deepcopy(BaseModule.argument_spec)
self.argument_spec.pop("state")
self.argument_spec.pop("wait")
if not skip_info_args:
self.argument_spec.update(self.info_argument_spec)
info_args_mutually_exclusive = deepcopy(self.info_args_mutually_exclusive)
if kwargs.get("mutually_exclusive"):
info_args_mutually_exclusive.append(kwargs["mutually_exclusive"])
kwargs["mutually_exclusive"] = info_args_mutually_exclusive
super(BaseInfoModule, self).__init__(**kwargs)
10 changes: 7 additions & 3 deletions plugins/module_utils/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,14 @@ def get_info_spec(self):
else:
spec.pop(key)

if params.get("filter", {}).get("name") and params.get("kind") == "vm":
spec["filter"]["vm_name"] = spec["filter"].pop("name")
if params.get("filter"):
if params.get("filter", {}).get("name") and params.get("kind") == "vm":
spec["filter"]["vm_name"] = spec["filter"].pop("name")

spec["filter"] = self._parse_filters(params.get("filter", {}))
spec["filter"] = self._parse_filters(params.get("filter", {}))

elif params.get("filter_string"):
spec["filter"] = params["filter_string"]

return spec, None

Expand Down

0 comments on commit d1c75d1

Please sign in to comment.