File 0007-fence_gce-minor-changes-in-logging.patch of Package fence-agents.10129
From a52e643708908539d6e5fdb5d36a6cea935e4481 Mon Sep 17 00:00:00 2001
From: Helen Koike <helen.koike@collabora.com>
Date: Wed, 11 Jul 2018 17:16:49 -0300
Subject: [PATCH 7/7] fence_gce: minor changes in logging
- Remove hostname (use --plug instead).
- Supress messages from googleapiclient and oauth2client if not error in
non verbose mode.
- s/stonish/stonith
---
agents/gce/fence_gce.py | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/fence/agents/gce/fence_gce.py b/fence/agents/gce/fence_gce.py
index 1d5095ae..3eca0139 100644
--- a/fence/agents/gce/fence_gce.py
+++ b/fence/agents/gce/fence_gce.py
@@ -3,7 +3,6 @@
import atexit
import logging
import os
-import platform
import sys
import time
if sys.version_info >= (3, 0):
@@ -180,8 +179,6 @@ def define_new_opts():
def main():
conn = None
- hostname = platform.node()
-
device_opt = ["port", "no_password", "zone", "project", "stackdriver-logging", "method"]
atexit.register(atexit_handler)
@@ -207,18 +204,20 @@ def main():
run_delay(options)
# Prepare logging
- if options.get('--stackdriver-logging') is not None:
+ if options.get('--verbose') is None:
+ logging.getLogger('googleapiclient').setLevel(logging.ERROR)
+ logging.getLogger('oauth2client').setLevel(logging.ERROR)
+ if options.get('--stackdriver-logging') is not None and options.get('--plug'):
try:
import google.cloud.logging.handlers
client = google.cloud.logging.Client()
- handler = google.cloud.logging.handlers.CloudLoggingHandler(client, name=hostname)
+ handler = google.cloud.logging.handlers.CloudLoggingHandler(client, name=options['--plug'])
handler.setLevel(logging.INFO)
- formatter = logging.Formatter('gcp:stonish "%(message)s"')
+ formatter = logging.Formatter('gcp:stonith "%(message)s"')
handler.setFormatter(formatter)
root_logger = logging.getLogger()
if options.get('--verbose') is None:
root_logger.setLevel(logging.INFO)
- logging.getLogger("googleapiclient").setLevel(logging.ERROR)
root_logger.addHandler(handler)
except ImportError:
logging.error('Couldn\'t import google.cloud.logging, '
--
2.16.4