blob: 5e066f1bf5d0921d2bc652af4f8060fe56bf394c [file] [log] [blame]
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import logging
import logging.handlers
import common
from autotest_lib.client.common_lib import error
from autotest_lib.client.cros import constants
from autotest_lib.client.cros import xmlrpc_server
from autotest_lib.client.cros.networking import apmanager_proxy
class ApmanagerXmlRpcDelegate(xmlrpc_server.XmlRpcDelegate):
"""Exposes methods called remotely during APManager autotests.
All instance methods of this object without a preceding '_' are exposed via
an XMLRPC server. This is not a stateless handler object, which means that
if you store state inside the delegate, that state will remain around for
future calls.
def __init__(self):
self._apmanager_proxy = apmanager_proxy.ApmanagerProxy()
def __enter__(self):
super(ApmanagerXmlRpcDelegate, self).__enter__()
def __exit__(self, exception, value, traceback):
super(ApmanagerXmlRpcDelegate, self).__exit__(exception, value, traceback)
def start_service(self, config_params):
"""Create/start an AP service.
@param config_params dictionary of configuration parameters.
@return string object path for the AP service.
return self._apmanager_proxy.start_service(config_params)
def terminate_service(self, service):
"""Remove/terminate an AP service.
@param service string object path of the AP service.
if __name__ == '__main__':
handler = logging.handlers.SysLogHandler(address='/dev/log')
formatter = logging.Formatter(
'apmanager_xmlrpc_server: [%(levelname)s] %(message)s')
logging.debug('apmanager_xmlrpc_server main...')
server = xmlrpc_server.XmlRpcServer('localhost',
if server is None:
raise error.TestFail('Failed to setup xmlrpc server for apmanager')
logging.debug('Server setup')