-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add webra import workflow * improve error logs * add revoke by certificate id * prepare release * add tests for horizon_import * fix tests * update import tests * catch ssl error * improve bug fix of content-type in case of bad authentication * Improve integration tests * fix integration tests
- Loading branch information
1 parent
2cf981b
commit 8115988
Showing
16 changed files
with
690 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Standard base includes and define this as a metaclass of type | ||
from __future__ import (absolute_import, division, print_function) | ||
|
||
__metaclass__ = type | ||
|
||
from ansible.errors import AnsibleError | ||
from ansible_collections.evertrust.horizon.plugins.module_utils.horizon_action import HorizonAction | ||
from ansible_collections.evertrust.horizon.plugins.module_utils.horizon_crypto import HorizonCrypto | ||
from ansible_collections.evertrust.horizon.plugins.module_utils.horizon_errors import HorizonError | ||
|
||
|
||
class ActionModule(HorizonAction): | ||
TRANSFERS_FILES = True | ||
|
||
def _args(self): | ||
return ['profile', 'certificate_id', 'certificate_pem', 'private_key', 'labels', 'metadata', 'owner', 'team', 'contact_email'] | ||
|
||
def run(self, tmp=None, task_vars=None): | ||
result = super(ActionModule, self).run(tmp, task_vars) | ||
|
||
try: | ||
client = self._get_client() | ||
content = self._get_content() | ||
response = client.webra_import(**content) | ||
|
||
if "certificate" in response: | ||
result["certificate"] = response["certificate"] | ||
result["chain"] = client.chain(result["certificate"]["certificate"]) | ||
|
||
if "pkcs12" in response.keys(): | ||
result["p12"] = response["pkcs12"]["value"] | ||
result["p12_password"] = response["password"]["value"] | ||
result["key"] = HorizonCrypto.get_key_from_p12(response["pkcs12"]["value"], | ||
response["password"]["value"]) | ||
|
||
except HorizonError as e: | ||
raise AnsibleError(e.full_message) | ||
|
||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.