mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-08 01:14:03 -07:00
Fix wildcard imports, remove get_exception, add boilerplate
Fixed for monitoring modules
This commit is contained in:
parent
aca1950150
commit
7cd81b802d
37 changed files with 288 additions and 618 deletions
|
@ -1,21 +1,11 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# LogicMonitor Ansible module for managing Collectors, Hosts and Hostgroups
|
||||
# Copyright (C) 2015 LogicMonitor
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
||||
'status': ['preview'],
|
||||
|
@ -136,8 +126,6 @@ RETURN = '''
|
|||
import socket
|
||||
import types
|
||||
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||
|
||||
HAS_LIB_JSON = True
|
||||
try:
|
||||
import json
|
||||
|
@ -159,6 +147,11 @@ except ImportError:
|
|||
except SyntaxError:
|
||||
HAS_LIB_JSON = False
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||
from ansible.module_utils._text import to_native
|
||||
from ansible.module_utils.urls import open_url
|
||||
|
||||
|
||||
class LogicMonitor(object):
|
||||
|
||||
|
@ -208,11 +201,10 @@ class LogicMonitor(object):
|
|||
self.fail(msg="Error: " + resp["errmsg"])
|
||||
else:
|
||||
return raw
|
||||
except IOError:
|
||||
ioe = get_exception()
|
||||
except IOError as ioe:
|
||||
self.fail(msg="Error: Exception making RPC call to " +
|
||||
"https://" + self.company + "." + self.lm_url +
|
||||
"/rpc/" + action + "\nException" + str(ioe))
|
||||
"/rpc/" + action + "\nException" + to_native(ioe))
|
||||
|
||||
def get_collectors(self):
|
||||
"""Returns a JSON object containing a list of
|
||||
|
@ -600,9 +592,6 @@ def main():
|
|||
|
||||
selector(module)
|
||||
|
||||
from ansible.module_utils.basic import *
|
||||
from ansible.module_utils.urls import *
|
||||
from ansible.module_utils.urls import open_url
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue