Skip to content

Commit

Permalink
Add bindep and update black (ansible-collections#40)
Browse files Browse the repository at this point in the history
Add bindep and update black

SUMMARY

Add bindep and update black

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Trishna Guha <[email protected]>
  • Loading branch information
KB-perByte authored and justjais committed May 23, 2022
1 parent 187eca3 commit 5ace969
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 52 deletions.
8 changes: 8 additions & 0 deletions bindep.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This is a cross-platform list tracking distribution packages needed by tests;
# see https://docs.openstack.org/infra/bindep/ for additional information.

gcc-c++ [doc test platform:rpm]
python3-devel [test platform:rpm]
python3 [test platform:rpm]
libssh-devel [test platform:rpm]
libssh-dev [test platform:dpkg]
3 changes: 3 additions & 0 deletions changelogs/fragments/bindep_update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
trivial:
- "Add bindep file for installation of correct dependencies."
17 changes: 9 additions & 8 deletions plugins/action/deepsec_anti_malwares.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@


class ActionModule(ActionBase):
""" action module
"""
"""action module"""

def __init__(self, *args, **kwargs):
super(ActionModule, self).__init__(*args, **kwargs)
Expand Down Expand Up @@ -353,16 +352,18 @@ def run(self, tmp=None, task_vars=None):
or self._task.args["state"] == "replaced"
):
if self._task.args.get("config"):
self._result[self.module_return], self._result[
"changed"
] = self.configure_module_api(
(
self._result[self.module_return],
self._result["changed"],
) = self.configure_module_api(
conn_request, self._task.args["config"]
)
elif self._task.args["state"] == "deleted":
if self._task.args.get("config"):
self._result[self.module_return], self._result[
"changed"
] = self.delete_module_api_config(
(
self._result[self.module_return],
self._result["changed"],
) = self.delete_module_api_config(
conn_request, self._task.args["config"]
)

Expand Down
17 changes: 9 additions & 8 deletions plugins/action/deepsec_firewall_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@


class ActionModule(ActionBase):
""" action module
"""
"""action module"""

def __init__(self, *args, **kwargs):
super(ActionModule, self).__init__(*args, **kwargs)
Expand Down Expand Up @@ -342,16 +341,18 @@ def run(self, tmp=None, task_vars=None):
or self._task.args["state"] == "replaced"
):
if self._task.args.get("config"):
self._result[self.module_return], self._result[
"changed"
] = self.configure_module_api(
(
self._result[self.module_return],
self._result["changed"],
) = self.configure_module_api(
conn_request, self._task.args["config"]
)
elif self._task.args["state"] == "deleted":
if self._task.args.get("config"):
self._result[self.module_return], self._result[
"changed"
] = self.delete_module_api_config(
(
self._result[self.module_return],
self._result["changed"],
) = self.delete_module_api_config(
conn_request, self._task.args["config"]
)

Expand Down
17 changes: 9 additions & 8 deletions plugins/action/deepsec_integrity_monitoring_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@


class ActionModule(ActionBase):
""" action module
"""
"""action module"""

def __init__(self, *args, **kwargs):
super(ActionModule, self).__init__(*args, **kwargs)
Expand Down Expand Up @@ -318,16 +317,18 @@ def run(self, tmp=None, task_vars=None):
or self._task.args["state"] == "replaced"
):
if self._task.args.get("config"):
self._result[self.module_return], self._result[
"changed"
] = self.configure_module_api(
(
self._result[self.module_return],
self._result["changed"],
) = self.configure_module_api(
conn_request, self._task.args["config"]
)
elif self._task.args["state"] == "deleted":
if self._task.args.get("config"):
self._result[self.module_return], self._result[
"changed"
] = self.delete_module_api_config(
(
self._result[self.module_return],
self._result["changed"],
) = self.delete_module_api_config(
conn_request, self._task.args["config"]
)

Expand Down
38 changes: 25 additions & 13 deletions plugins/action/deepsec_intrusion_prevention_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@


class ActionModule(ActionBase):
""" action module
"""
"""action module"""

def __init__(self, *args, **kwargs):
super(ActionModule, self).__init__(*args, **kwargs)
Expand Down Expand Up @@ -126,8 +125,10 @@ def search_for_ipr_name(self, deepsec_conn_request, search_ipr_by_names):
}
],
}
temp_search_response = self.search_for_intrusion_prevention_rules(
deepsec_conn_request, search_payload
temp_search_response = (
self.search_for_intrusion_prevention_rules(
deepsec_conn_request, search_payload
)
)
if (
temp_search_response.get("intrusionPreventionRules")
Expand Down Expand Up @@ -241,7 +242,10 @@ def configure_module_api(self, deepsec_conn_request, module_config_params):
payload = map_params_to_obj(
each, self.key_transform
)
response_code, api_response = deepsec_conn_request.post(
(
response_code,
api_response,
) = deepsec_conn_request.post(
"{0}/{1}".format(self.api_object, every["id"]),
data=payload,
)
Expand All @@ -256,7 +260,10 @@ def configure_module_api(self, deepsec_conn_request, module_config_params):
)
)
elif self._task.args["state"] == "replaced":
response_code, api_response = deepsec_conn_request.delete(
(
response_code,
api_response,
) = deepsec_conn_request.delete(
"{0}/{1}".format(self.api_object, every["id"]),
data=each,
)
Expand All @@ -267,7 +274,10 @@ def configure_module_api(self, deepsec_conn_request, module_config_params):
payload = map_params_to_obj(
each, self.key_transform
)
response_code, api_response = deepsec_conn_request.post(
(
response_code,
api_response,
) = deepsec_conn_request.post(
"{0}".format(self.api_object), data=payload
)
self._check_for_response_code(
Expand Down Expand Up @@ -334,16 +344,18 @@ def run(self, tmp=None, task_vars=None):
or self._task.args["state"] == "replaced"
):
if self._task.args.get("config"):
self._result[self.module_return], self._result[
"changed"
] = self.configure_module_api(
(
self._result[self.module_return],
self._result["changed"],
) = self.configure_module_api(
deepsec_conn_request, self._task.args["config"]
)
elif self._task.args["state"] == "deleted":
if self._task.args.get("config"):
self._result[self.module_return], self._result[
"changed"
] = self.delete_module_api_config(
(
self._result[self.module_return],
self._result["changed"],
) = self.delete_module_api_config(
deepsec_conn_request, self._task.args["config"]
)

Expand Down
17 changes: 9 additions & 8 deletions plugins/action/deepsec_log_inspection_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@


class ActionModule(ActionBase):
""" action module
"""
"""action module"""

def __init__(self, *args, **kwargs):
super(ActionModule, self).__init__(*args, **kwargs)
Expand Down Expand Up @@ -401,16 +400,18 @@ def run(self, tmp=None, task_vars=None):
or self._task.args["state"] == "replaced"
):
if self._task.args.get("config"):
self._result[self.module_return], self._result[
"changed"
] = self.configure_module_api(
(
self._result[self.module_return],
self._result["changed"],
) = self.configure_module_api(
conn_request, self._task.args["config"]
)
elif self._task.args["state"] == "deleted":
if self._task.args.get("config"):
self._result[self.module_return], self._result[
"changed"
] = self.delete_module_api_config(
(
self._result[self.module_return],
self._result["changed"],
) = self.delete_module_api_config(
conn_request, self._task.args["config"]
)

Expand Down
8 changes: 4 additions & 4 deletions plugins/module_utils/deepsec.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def remove_get_keys_from_payload_dict(payload_dict, remove_key_list):


def map_params_to_obj(module_params, key_transform):
""" The fn to convert the api returned params to module params
"""The fn to convert the api returned params to module params
:param module_params: Module params
:param key_transform: Dict with module equivalent API params
:rtype: A dict
Expand All @@ -65,7 +65,7 @@ def map_params_to_obj(module_params, key_transform):


def map_obj_to_params(module_return_params, key_transform, return_param):
""" The fn to convert the api returned params to module params
"""The fn to convert the api returned params to module params
:param module_return_params: API returned response params
:param key_transform: Module params
:rtype: A dict
Expand Down Expand Up @@ -105,7 +105,7 @@ def check_if_config_exists(
field_name="name",
api_request="post",
):
""" The fn check if the config_name detect based on config
"""The fn check if the config_name detect based on config
:param deepsec_request: the objects from which the configuration should be read
:param config_name: config_name rule with which config will be searched
:param api: REST API for which search POST call is made
Expand Down Expand Up @@ -146,7 +146,7 @@ def delete_config_with_id(
api_or_rest=True,
handle_return=False,
):
""" The fn calls the delete API based on the config id
"""The fn calls the delete API based on the config id
:param deepsec_request: connection obj for TM
:param config_id: config id for the config that's supposed to be deleted
:param api_or_rest: Fire request for legacy or latest API call
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/deepsec_log_inspectionrules.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def map_params_to_obj(module_params):


def check_if_log_inspection_rules_exists(deepsec_request, log_inspection_name):
""" The fn check if the log_inspection detect based on log_inspection name
"""The fn check if the log_inspection detect based on log_inspection name
:param deepsec_request: the objects from which the configuration should be read
:param log_inspection_name: log_inspection name with which log_inspection will be searched
in existing log_inspection configurations
Expand All @@ -305,7 +305,7 @@ def check_if_log_inspection_rules_exists(deepsec_request, log_inspection_name):


def delete_log_inspection_with_id(module, deepsec_request, log_inspection_id):
""" The fn calls the delete API based on the log_inspection id
"""The fn calls the delete API based on the log_inspection id
:param module: ansible module object
:param deepsec_request: connection obj for TM
:param log_inspection_id: log_inspection id for the log_inspection that's supposed to be deleted
Expand Down
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
black==19.3b0 ; python_version > '3.5'
black==22.3.0 ; python_version > '3.5'
coverage==4.5.4
flake8
mock ; python_version < '3.5'
Expand Down

0 comments on commit 5ace969

Please sign in to comment.