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

Checkpoint httpapi plugin #49929

Merged
merged 36 commits into from Jan 7, 2019

Conversation

Projects
None yet
3 participants
@rcarrillocruz
Copy link
Contributor

rcarrillocruz commented Dec 14, 2018

SUMMARY

Add Checkpoint httpapi plugin and module_utils

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

plugins/httpapi/checkpoint

@ansibot

This comment has been minimized.

@ansibot

This comment has been minimized.

Copy link
Contributor

ansibot commented Dec 14, 2018

@rcarrillocruz this PR contains more than one new module.

Please submit only one new module per pull request. For a detailed explanation, please read the grouped modules documentation

click here for bot help

@rcarrillocruz rcarrillocruz changed the title WIP Checkpoint modules WIP Checkpoint httpapi plugin Dec 14, 2018

if username and password:
payload = {'user': username, 'password': password}
url = '/web_api/login'
response, response_data = self._send_auth_request(

This comment has been minimized.

@Qalthos

Qalthos Dec 14, 2018

Contributor

You can probably get away with a normal send_request here

Show resolved Hide resolved lib/ansible/plugins/httpapi/checkpoint.py Outdated
Show resolved Hide resolved lib/ansible/plugins/httpapi/checkpoint.py Outdated
self.refresh_token = None
self.access_token = None

def _send_auth_request(self, path, data, **kwargs):

This comment has been minimized.

@Qalthos

Qalthos Dec 14, 2018

Contributor

You haven't kept the overridden handle_httperror, so setting _ignore_http_errors doesn't do anything. I would probably remove this method.

Show resolved Hide resolved lib/ansible/plugins/httpapi/checkpoint.py Outdated
Show resolved Hide resolved lib/ansible/plugins/httpapi/checkpoint.py Outdated
@Qalthos
Copy link
Contributor

Qalthos left a comment

I might be getting a little pedantic here, but I'd like this to be a sterling example of a proper httpapi plugin when we're done.

Show resolved Hide resolved lib/ansible/plugins/httpapi/checkpoint.py Outdated
Show resolved Hide resolved lib/ansible/plugins/httpapi/checkpoint.py Outdated
Show resolved Hide resolved lib/ansible/plugins/httpapi/checkpoint.py Outdated
Show resolved Hide resolved lib/ansible/plugins/httpapi/checkpoint.py Outdated
Show resolved Hide resolved lib/ansible/plugins/httpapi/checkpoint.py Outdated
Show resolved Hide resolved lib/ansible/plugins/httpapi/checkpoint.py Outdated

@rcarrillocruz rcarrillocruz force-pushed the rcarrillocruz:checkpoint branch from 98315dc to 39ed75b Dec 21, 2018

@ansibot

This comment has been minimized.

Copy link
Contributor

ansibot commented Dec 26, 2018

The test ansible-test sanity --test validate-modules [explain] failed with 10 errors:

lib/ansible/modules/network/checkpoint/checkpoint_access_rule.py:0:0: E105 GPLv3 license header not found in the first 20 lines of the module
lib/ansible/modules/network/checkpoint/checkpoint_access_rule.py:0:0: E305 DOCUMENTATION.options.enabled.type: not a valid value for dictionary value @ data['options']['enabled']['type']. Got 'boolean'
lib/ansible/modules/network/checkpoint/checkpoint_access_rule.py:0:0: E310 No EXAMPLES provided
lib/ansible/modules/network/checkpoint/checkpoint_access_rule.py:0:0: E312 No RETURN provided
lib/ansible/modules/network/checkpoint/checkpoint_access_rule.py:0:0: E324 Value for "default" from the argument_spec ('present') for "state" does not match the documentation (None)
lib/ansible/modules/network/checkpoint/checkpoint_access_rule.py:0:0: E324 Value for "default" from the argument_spec (True) for "enabled" does not match the documentation (False)
lib/ansible/modules/network/checkpoint/checkpoint_access_rule.py:0:0: E325 argument_spec for "enabled" defines type="bool" but documentation does not
lib/ansible/modules/network/checkpoint/checkpoint_access_rule.py:6:0: E106 Import found before documentation variables. All imports must appear below DOCUMENTATION/EXAMPLES/RETURN/ANSIBLE_METADATA.
lib/ansible/modules/network/checkpoint/checkpoint_access_rule.py:6:0: E107 Imports should be directly below DOCUMENTATION/EXAMPLES/RETURN/ANSIBLE_METADATA.
lib/ansible/modules/network/checkpoint:0:0: E502 Ansible module subdirectories must contain an __init__.py

click here for bot help

@ansibot ansibot added the stale_ci label Jan 6, 2019

@rcarrillocruz rcarrillocruz reopened this Jan 6, 2019

@rcarrillocruz rcarrillocruz changed the title WIP Checkpoint httpapi plugin Checkpoint httpapi plugin Jan 6, 2019

@ansibot ansibot removed the stale_review label Jan 7, 2019

rcarrillocruz added some commits Jan 7, 2019

@Qalthos

Qalthos approved these changes Jan 7, 2019

@rcarrillocruz rcarrillocruz merged commit f907927 into ansible:devel Jan 7, 2019

1 check passed

Shippable Run 100858 status is SUCCESS.
Details

rcarrillocruz added a commit to rcarrillocruz/ansible that referenced this pull request Jan 9, 2019

Checkpoint httpapi plugin (ansible#49929)
* Add checkpoint httpapi plugin and access rule facts module

* WIP checkpoint_access_rule module

* Add publish and install policy, plus fix empty json object request for publish

* Refactor publish and install_policy onto module_utils

* Add update resource logic

* Add checkpoint_host_facts module

* Return code and response on get_acess_rule function

* Add checkpoint_host module

* Add checkpoint_run_script module

* Add checkpoint_task_facts module

* Show all tasks if no task id is passed

Note, this is only available on v1.3 of Checkpoint WS API

* Add update logic to checkpoint host

* Add full details on get task call

* Add checkpoint httpapi plugin

* Fix pep8

* Use auth instead of sid property and return False on handle_httperror method

* Fix version in docstring

* Remove constructor

* Remove Accept from base headers

* Do not override http error handler and assign Checkpoint sid to connection _auth

There is scaffolding in the base class to autoappend the token, given
it is assigned to connection _send

* Use new connection queue message method instead of display

* Remove unused display

* Catch ValueError, since it's a parent of JSONDecodeError

* Make static methods that are not used outside the class regular methods

* Add missing self to previously static methods

* Fix logout

Was carrying copy pasta from ftd plugin

* Remove send_auth_request

* Use BASE_HEADERS constant

* Simplify copyright header on httpapi plugin

* Remove access rule module

* Remove unused imports

* Add unit test

* Fix pep8

* Add test

* Add test

* Fix pep8

kbreit added a commit to kbreit/ansible that referenced this pull request Jan 11, 2019

Checkpoint httpapi plugin (ansible#49929)
* Add checkpoint httpapi plugin and access rule facts module

* WIP checkpoint_access_rule module

* Add publish and install policy, plus fix empty json object request for publish

* Refactor publish and install_policy onto module_utils

* Add update resource logic

* Add checkpoint_host_facts module

* Return code and response on get_acess_rule function

* Add checkpoint_host module

* Add checkpoint_run_script module

* Add checkpoint_task_facts module

* Show all tasks if no task id is passed

Note, this is only available on v1.3 of Checkpoint WS API

* Add update logic to checkpoint host

* Add full details on get task call

* Add checkpoint httpapi plugin

* Fix pep8

* Use auth instead of sid property and return False on handle_httperror method

* Fix version in docstring

* Remove constructor

* Remove Accept from base headers

* Do not override http error handler and assign Checkpoint sid to connection _auth

There is scaffolding in the base class to autoappend the token, given
it is assigned to connection _send

* Use new connection queue message method instead of display

* Remove unused display

* Catch ValueError, since it's a parent of JSONDecodeError

* Make static methods that are not used outside the class regular methods

* Add missing self to previously static methods

* Fix logout

Was carrying copy pasta from ftd plugin

* Remove send_auth_request

* Use BASE_HEADERS constant

* Simplify copyright header on httpapi plugin

* Remove access rule module

* Remove unused imports

* Add unit test

* Fix pep8

* Add test

* Add test

* Fix pep8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment