Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE
fence-agents.9831
0005-fence_gce-s-loging-stackdriver-logging.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0005-fence_gce-s-loging-stackdriver-logging.patch of Package fence-agents.9831
From f8f3f11187341622c26e4e439dfda6a37ad660b0 Mon Sep 17 00:00:00 2001 From: Helen Koike <helen.koike@collabora.com> Date: Thu, 5 Jul 2018 11:05:32 -0300 Subject: [PATCH 5/7] fence_gce: s/--loging/--stackdriver-logging/ --- agents/gce/fence_gce.py | 42 ++++++++++++++++++--------------------- tests/data/metadata/fence_gce.xml | 11 +++++++--- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/fence/agents/gce/fence_gce.py b/fence/agents/gce/fence_gce.py index 9b7b5e55..a6befe39 100644 --- a/fence/agents/gce/fence_gce.py +++ b/fence/agents/gce/fence_gce.py @@ -167,14 +167,13 @@ def define_new_opts(): "required" : "0", "order" : 3 } - all_opt["logging"] = { - "getopt" : ":", - "longopt" : "logging", - "help" : "--logging=[bool] Logging, true/false", + all_opt["stackdriver-logging"] = { + "getopt" : "", + "longopt" : "stackdriver-logging", + "help" : "--stackdriver-logging Enable Logging to Stackdriver", "shortdesc" : "Stackdriver-logging support.", - "longdesc" : "If enabled (set to true), IP failover logs will be posted to stackdriver logging.", + "longdesc" : "If enabled IP failover logs will be posted to stackdriver logging.", "required" : "0", - "default" : "false", "order" : 4 } @@ -185,7 +184,7 @@ def main(): hostname = platform.node() - device_opt = ["port", "no_password", "zone", "project", "logging", "method"] + device_opt = ["port", "no_password", "zone", "project", "stackdriver-logging", "method"] atexit.register(atexit_handler) @@ -210,22 +209,19 @@ def main(): run_delay(options) # Prepare logging - logging_env = options.get('--logging') - if logging_env: - logging_env = logging_env.lower() - if any(x in logging_env for x in ['yes', 'true', 'enabled']): - try: - import google.cloud.logging.handlers - client = google.cloud.logging.Client() - handler = google.cloud.logging.handlers.CloudLoggingHandler(client, name=hostname) - formatter = logging.Formatter('gcp:stonish "%(message)s"') - LOGGER = logging.getLogger(hostname) - handler.setFormatter(formatter) - LOGGER.addHandler(handler) - LOGGER.setLevel(logging.INFO) - except ImportError: - LOGGER.error('Couldn\'t import google.cloud.logging, ' - 'disabling Stackdriver-logging support') + if options.get('--stackdriver-logging'): + try: + import google.cloud.logging.handlers + client = google.cloud.logging.Client() + handler = google.cloud.logging.handlers.CloudLoggingHandler(client, name=hostname) + formatter = logging.Formatter('gcp:stonish "%(message)s"') + LOGGER = logging.getLogger(hostname) + handler.setFormatter(formatter) + LOGGER.addHandler(handler) + LOGGER.setLevel(logging.INFO) + except ImportError: + LOGGER.error('Couldn\'t import google.cloud.logging, ' + 'disabling Stackdriver-logging support') # Prepare cli try: diff --git a/tests/data/metadata/fence_gce.xml b/tests/data/metadata/fence_gce.xml index f522550f..79b82ebb 100644 --- a/tests/data/metadata/fence_gce.xml +++ b/tests/data/metadata/fence_gce.xml @@ -38,9 +38,14 @@ For instructions see: https://cloud.google.com/compute/docs/tutorials/python-gui <content type="string" /> <shortdesc lang="en">Project ID.</shortdesc> </parameter> - <parameter name="logging" unique="0" required="0"> - <getopt mixed="--logging=[bool]" /> - <content type="string" default="false" /> + <parameter name="stackdriver-logging" unique="0" required="0" deprecated="1"> + <getopt mixed="--stackdriver-logging" /> + <content type="boolean" /> + <shortdesc lang="en">Stackdriver-logging support.</shortdesc> + </parameter> + <parameter name="stackdriver_logging" unique="0" required="0" obsoletes="stackdriver-logging"> + <getopt mixed="--stackdriver-logging" /> + <content type="boolean" /> <shortdesc lang="en">Stackdriver-logging support.</shortdesc> </parameter> <parameter name="quiet" unique="0" required="0"> -- 2.16.4
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor