mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 22:30:22 -07:00
parent
2f33c1a1a1
commit
5553b20828
206 changed files with 1853 additions and 1870 deletions
|
@ -37,8 +37,8 @@ from ansible.module_utils.aos import *
|
|||
"""
|
||||
import json
|
||||
|
||||
from distutils.version import LooseVersion
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
from distutils.version import LooseVersion
|
||||
|
||||
try:
|
||||
import yaml
|
||||
|
@ -53,6 +53,7 @@ try:
|
|||
except ImportError:
|
||||
HAS_AOS_PYEZ = False
|
||||
|
||||
|
||||
def check_aos_version(module, min=False):
|
||||
"""
|
||||
Check if the library aos-pyez is present.
|
||||
|
@ -71,6 +72,7 @@ def check_aos_version(module, min=False):
|
|||
|
||||
return True
|
||||
|
||||
|
||||
def get_aos_session(module, auth):
|
||||
"""
|
||||
Resume an existing session and return an AOS object.
|
||||
|
@ -94,6 +96,7 @@ def get_aos_session(module, auth):
|
|||
|
||||
return aos
|
||||
|
||||
|
||||
def find_collection_item(collection, item_name=False, item_id=False):
|
||||
"""
|
||||
Find collection_item based on name or id from a collection object
|
||||
|
@ -114,6 +117,7 @@ def find_collection_item(collection, item_name=False, item_id=False):
|
|||
else:
|
||||
return my_dict
|
||||
|
||||
|
||||
def content_to_dict(module, content):
|
||||
"""
|
||||
Convert 'content' into a Python Dict based on 'content_format'
|
||||
|
@ -144,12 +148,12 @@ def content_to_dict(module, content):
|
|||
except:
|
||||
module.fail_json(msg="Unable to convert 'content' to a dict, please check if valid")
|
||||
|
||||
|
||||
# replace the string with the dict
|
||||
module.params['content'] = content_dict
|
||||
|
||||
return content_dict
|
||||
|
||||
|
||||
def do_load_resource(module, collection, name):
|
||||
"""
|
||||
Create a new object (collection.item) by loading a datastructure directly
|
||||
|
@ -161,10 +165,7 @@ def do_load_resource(module, collection, name):
|
|||
module.fail_json(msg="An error occurred while running 'find_collection_item'")
|
||||
|
||||
if item.exists:
|
||||
module.exit_json( changed=False,
|
||||
name=item.name,
|
||||
id=item.id,
|
||||
value=item.value )
|
||||
module.exit_json(changed=False, name=item.name, id=item.id, value=item.value)
|
||||
|
||||
# If not in check mode, apply the changes
|
||||
if not module.check_mode:
|
||||
|
@ -175,7 +176,4 @@ def do_load_resource(module, collection, name):
|
|||
e = get_exception()
|
||||
module.fail_json(msg="Unable to write item content : %r" % e)
|
||||
|
||||
module.exit_json( changed=True,
|
||||
name=item.name,
|
||||
id=item.id,
|
||||
value=item.value )
|
||||
module.exit_json(changed=True, name=item.name, id=item.id, value=item.value)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue