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

Adding allow_bool for rpc and enhancing log error #564

Merged
merged 1 commit into from
Aug 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,15 @@ def __init__(self,
A JuniperJunosModule instance object.
"""

#initialize default values here for error scenario while super is called

# by default local
self.conn_type = "local"
# Initialize the dev attribute
self.dev = None
# Initialize the config attribute
self.config = None

# Update argument_spec with the internal_spec
argument_spec.update(internal_spec)
# Update argument_spec with the top_spec
Expand Down Expand Up @@ -623,11 +632,6 @@ def initialize_params(self):
# Parse the console option
self._parse_console_options()

# Initialize the dev attribute
self.dev = None
# Initialize the config attribute
self.config = None

# Check that we have a user and host
if not self.params.get('host'):
self.fail_json(msg="missing required arguments: host")
Expand Down Expand Up @@ -944,6 +948,10 @@ def parse_arg_to_list_of_dicts(self,
"invalid. Unable to translate into a list "
"of dicts." %
(option_name, string_val))
# check if allow_bool_values passed in kwargs
if "allow_bool_values" in kwarg:
allow_bool_values = kwarg.pop("allow_bool_values")

# Now we just need to make sure the key is a string and the value
# is a string or bool.
return_item = {}
Expand Down
7 changes: 7 additions & 0 deletions ansible_collections/juniper/device/plugins/modules/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@
two lists must always contain the same number of elements. For RPC
arguments which do not require a value, specify the value of True as
shown in the :ref:`rpc-examples-label`.
- By default "0" and "1" will be converted to boolean values. In case
it doesn't need to be transformed to boolean pass first kwargs as
allow_bool_values : "0"
example -
kwargs:
allow_bool_values: "0"
data: "1"
required: false
default: none
type: dict or list of dict
Expand Down