Fix for missing import and boilerplate

Fix adds missing imports and boilerplate for proxysql.
It also remove get_exception calls in-favor of native exception.

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2017-08-03 13:42:24 +05:30 committed by Toshio Kuratomi
parent afbad8789f
commit 97240a9ebc
8 changed files with 75 additions and 168 deletions

View file

@ -1,20 +1,10 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2017, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
#
# Ansible 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.
#
# Ansible 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 Ansible. If not, see <http://www.gnu.org/licenses/>.
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = '''
---
@ -111,7 +101,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.0',
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.mysql import mysql_connect
from ansible.module_utils.pycompat24 import get_exception
from ansible.module_utils._text import to_native
try:
import MySQLdb
@ -249,10 +239,9 @@ def main():
login_password,
config_file,
cursor_class=MySQLdb.cursors.DictCursor)
except MySQLdb.Error:
e = get_exception()
except MySQLdb.Error as e:
module.fail_json(
msg="unable to connect to ProxySQL Admin Module.. %s" % e
msg="unable to connect to ProxySQL Admin Module.. %s" % to_native(e)
)
result = {}
@ -269,10 +258,9 @@ def main():
msg="The variable \"%s\" was not found" % variable
)
except MySQLdb.Error:
e = get_exception()
except MySQLdb.Error as e:
module.fail_json(
msg="unable to get config.. %s" % e
msg="unable to get config.. %s" % to_native(e)
)
else:
try:
@ -303,10 +291,9 @@ def main():
msg="The variable \"%s\" was not found" % variable
)
except MySQLdb.Error:
e = get_exception()
except MySQLdb.Error as e:
module.fail_json(
msg="unable to set config.. %s" % e
msg="unable to set config.. %s" % to_native(e)
)
module.exit_json(**result)