slapos.cli info/list: remove formatters for logger.

Allow to script it.
parent 495599e2
......@@ -27,13 +27,23 @@
#
##############################################################################
import logging
import pprint
import sys
from slapos.cli.config import ClientConfigCommand
from slapos.client import init, ClientConfig
from slapos.slap import ResourceNotReady, NotFoundError
def resetLogger(logger):
"""Remove all formatters, log files, etc."""
if not getattr(logger, 'parent', None):
return
handler = logger.parent.handlers[0]
logger.parent.removeHandler(handler)
logger.addHandler(logging.StreamHandler(sys.stdout))
class InfoCommand(ClientConfigCommand):
"""get status, software_release and parameters of an instance"""
......@@ -56,6 +66,7 @@ class InfoCommand(ClientConfigCommand):
def do_info(logger, conf, local):
resetLogger(logger)
try:
instance = local['slap'].registerOpenOrder().getInformation(
partition_reference=conf.reference,
......
......@@ -27,10 +27,19 @@
#
##############################################################################
import logging
import sys
from slapos.cli.config import ClientConfigCommand
from slapos.client import init, ClientConfig
from slapos.slap import ResourceNotReady
def resetLogger(logger):
"""Remove all formatters, log files, etc."""
if not getattr(logger, 'parent', None):
return
handler = logger.parent.handlers[0]
logger.parent.removeHandler(handler)
logger.addHandler(logging.StreamHandler(sys.stdout))
class ListCommand(ClientConfigCommand):
"""request an instance and get status and parameters of instance"""
......@@ -48,6 +57,7 @@ class ListCommand(ClientConfigCommand):
def do_list(logger, conf, local):
resetLogger(logger)
# XXX catch exception
instance_dict = local['slap'].getOpenOrderDict()
if instance_dict == {}:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment