#
# Copyright (c) SAS Institute Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#


"""
    Contains the DispatcherServer class and Dispatcher XMLRPC client.

    The DispatcherServer takes in requests to perform commands and passes
    those requests onto available nodes if any.

    The DispatcherClient provides and XMLRPC-over-messagebus interface
    to the dispatcher for querying the dispatcher status out-of-band.
"""

import signal
from conary.deps import deps
from rmake import errors
from rmake.lib import flavorutil
from rmake.lib import logger
from rmake.lib import server
from rmake.lib.apiutils import api, api_parameters, api_return
from rmake.messagebus.rpclib import SessionProxy
from rmake.multinode import messages
from rmake.multinode import nodeclient
from rmake.multinode import nodetypes


class DispatcherServer(server.Server):
    """
        The Dispatcher is given a list of packages to resolve and build
        and determines where the best location to build them is.
    """
    def __init__(self, cfg, db):