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

Allow to script it.
parent 495599e2
...@@ -27,13 +27,23 @@ ...@@ -27,13 +27,23 @@
# #
############################################################################## ##############################################################################
import logging
import pprint import pprint
import sys
from slapos.cli.config import ClientConfigCommand from slapos.cli.config import ClientConfigCommand
from slapos.client import init, ClientConfig from slapos.client import init, ClientConfig
from slapos.slap import ResourceNotReady, NotFoundError 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): class InfoCommand(ClientConfigCommand):
"""get status, software_release and parameters of an instance""" """get status, software_release and parameters of an instance"""
...@@ -56,6 +66,7 @@ class InfoCommand(ClientConfigCommand): ...@@ -56,6 +66,7 @@ class InfoCommand(ClientConfigCommand):
def do_info(logger, conf, local): def do_info(logger, conf, local):
resetLogger(logger)
try: try:
instance = local['slap'].registerOpenOrder().getInformation( instance = local['slap'].registerOpenOrder().getInformation(
partition_reference=conf.reference, partition_reference=conf.reference,
......
...@@ -27,10 +27,19 @@ ...@@ -27,10 +27,19 @@
# #
############################################################################## ##############################################################################
import logging
import sys
from slapos.cli.config import ClientConfigCommand from slapos.cli.config import ClientConfigCommand
from slapos.client import init, ClientConfig 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): class ListCommand(ClientConfigCommand):
"""request an instance and get status and parameters of instance""" """request an instance and get status and parameters of instance"""
...@@ -48,6 +57,7 @@ class ListCommand(ClientConfigCommand): ...@@ -48,6 +57,7 @@ class ListCommand(ClientConfigCommand):
def do_list(logger, conf, local): def do_list(logger, conf, local):
resetLogger(logger)
# XXX catch exception # XXX catch exception
instance_dict = local['slap'].getOpenOrderDict() instance_dict = local['slap'].getOpenOrderDict()
if instance_dict == {}: 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