1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

move to use ansible logging

This commit is contained in:
Brian Coca 2017-10-16 10:00:15 -04:00 committed by Toshio Kuratomi
parent 844e58aedb
commit 07f1e7540b

View file

@ -122,10 +122,6 @@ class KubernetesAnsibleModule(AnsibleModule):
:return: None :return: None
""" """
if self.params.get('debug'):
self.helper.enable_debug(reset_logfile=False)
self.helper.log_argspec()
resource_definition = self.params.get('resource_definition') resource_definition = self.params.get('resource_definition')
if self.params.get('src'): if self.params.get('src'):
resource_definition = self.load_resource_definition(self.params['src']) resource_definition = self.load_resource_definition(self.params['src'])
@ -225,10 +221,10 @@ class KubernetesAnsibleModule(AnsibleModule):
return_attributes[self.kind] = existing.to_dict() return_attributes[self.kind] = existing.to_dict()
self.exit_json(**return_attributes) self.exit_json(**return_attributes)
else: else:
self.helper.log('Existing:') self.log('Existing:')
self.helper.log(existing.to_str()) self.log(json.dumps(existing.to_str(), indent=4))
self.helper.log('\nDifferences:') self.log('\nDifferences:')
self.helper.log(json.dumps(diff, indent=4)) self.log(json.dumps(diff, indent=4))
# Differences exist between the existing obj and requested params # Differences exist between the existing obj and requested params
if not self.check_mode: if not self.check_mode:
try: try:
@ -267,7 +263,7 @@ class KubernetesAnsibleModule(AnsibleModule):
""" Load the requested src path """ """ Load the requested src path """
result = None result = None
path = os.path.normpath(src) path = os.path.normpath(src)
self.helper.log("Reading definition from {}".format(path)) self.log("Reading definition from {}".format(path))
if not os.path.exists(path): if not os.path.exists(path):
self.fail_json(msg="Error accessing {}. Does the file exist?".format(path)) self.fail_json(msg="Error accessing {}. Does the file exist?".format(path))
try: try:
@ -290,7 +286,7 @@ class KubernetesAnsibleModule(AnsibleModule):
parameters[key] = value parameters[key] = value
elif isinstance(value, dict): elif isinstance(value, dict):
self._add_parameter(value, [key], parameters) self._add_parameter(value, [key], parameters)
self.helper.log("Request to parameters: {}".format(json.dumps(parameters))) self.log("Request to parameters: {}".format(json.dumps(parameters)))
return parameters return parameters
def _add_parameter(self, request, path, parameters): def _add_parameter(self, request, path, parameters):