Implement initial skeleton of a manager service.
This commit is contained in:
parent
8ac57c720c
commit
39a9f767ce
|
@ -39,8 +39,7 @@ def main():
|
|||
# Pase config file and command line options, then start logging
|
||||
prepare_service(sys.argv)
|
||||
|
||||
mgr = manager.AgentManager()
|
||||
topic = 'ironic.manager'
|
||||
ironic = rcp_service.Service(CONF.host, topic, mgr)
|
||||
launcher = service.launch(ironic)
|
||||
mgr = manager.ManagerService(CONF.host, topic)
|
||||
launcher = service.launch(mgr)
|
||||
launcher.wait()
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
#
|
||||
# Copyright © 2012 New Dream Network, LLC (DreamHost)
|
||||
#
|
||||
# Author: Doug Hellmann <doug.hellmann@dreamhost.com>
|
||||
#
|
||||
# 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.
|
||||
"""
|
||||
Base class for plugin loader.
|
||||
"""
|
||||
|
||||
from stevedore import enabled
|
||||
|
||||
from ironic.openstack.common import log
|
||||
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
def should_use_extension(namespace, ext, enabled_names):
|
||||
"""Return boolean indicating whether the extension should be used.
|
||||
|
||||
Tests the extension against a couple of criteria to see whether it
|
||||
should be used, logs the reason it is not used if not, and then
|
||||
returns the result.
|
||||
"""
|
||||
if ext.name not in enabled_names:
|
||||
LOG.debug(
|
||||
'%s extension %r disabled through configuration setting',
|
||||
namespace, ext.name,
|
||||
)
|
||||
return False
|
||||
if not ext.obj.is_enabled():
|
||||
LOG.debug(
|
||||
'%s extension %r reported that it is disabled',
|
||||
namespace,
|
||||
ext.name,
|
||||
)
|
||||
return False
|
||||
LOG.debug('using %s extension %r', namespace, ext.name)
|
||||
return True
|
||||
|
||||
|
||||
class ActivatedExtensionManager(enabled.EnabledExtensionManager):
|
||||
"""Loads extensions based on a configurable set that should be
|
||||
disabled and asking each one if it should be active or not.
|
||||
"""
|
||||
|
||||
def __init__(self, namespace, enabled_names, invoke_on_load=True,
|
||||
invoke_args=(), invoke_kwds={}):
|
||||
|
||||
def local_check_func(ext):
|
||||
return should_use_extension(namespace, ext, enabled_names)
|
||||
|
||||
super(ActivatedExtensionManager, self).__init__(
|
||||
namespace=namespace,
|
||||
check_func=local_check_func,
|
||||
invoke_on_load=invoke_on_load,
|
||||
invoke_args=invoke_args,
|
||||
invoke_kwds=invoke_kwds,
|
||||
)
|
|
@ -30,7 +30,7 @@ from ironic.openstack.common.rpc import service as rpc_service
|
|||
|
||||
cfg.CONF.register_opts([
|
||||
cfg.IntOpt('periodic_interval',
|
||||
default=600,
|
||||
default=60,
|
||||
help='seconds between running periodic tasks'),
|
||||
cfg.StrOpt('host',
|
||||
default=socket.getfqdn(),
|
||||
|
@ -72,12 +72,6 @@ class PeriodicService(rpc_service.Service):
|
|||
context=admin_context)
|
||||
|
||||
|
||||
def _sanitize_cmd_line(argv):
|
||||
"""Remove non-nova CLI options from argv."""
|
||||
cli_opt_names = ['--%s' % o.name for o in CLI_OPTIONS]
|
||||
return [a for a in argv if a in cli_opt_names]
|
||||
|
||||
|
||||
def prepare_service(argv=[]):
|
||||
rpc.set_defaults(control_exchange='ironic')
|
||||
cfg.set_defaults(log.log_opts,
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
# coding=utf-8
|
||||
|
||||
# Copyright 2013 Hewlett-Packard Development Company, L.P.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from ironic.openstack.common import context
|
||||
from ironic.openstack.common import log
|
||||
from ironic.openstack.common.rpc import dispatcher as rpc_dispatcher
|
||||
from ironic.openstack.common import timeutils
|
||||
|
||||
import ironic.openstack.common.notifier.rpc_notifier
|
||||
|
||||
from ironic import db
|
||||
from ironic.common import service
|
||||
from ironic.common import extension_manager
|
||||
|
||||
manager_opts = [
|
||||
cfg.StrOpt('power_driver',
|
||||
default='IPMI',
|
||||
help='Power driver. [IPMI, VPD, None]'
|
||||
),
|
||||
cfg.StrOpt('deployment_driver',
|
||||
default='PXE',
|
||||
help='Image deployment driver. [PXE]'
|
||||
),
|
||||
]
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(manager_opts)
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
class ManagerService(service.PeriodicService):
|
||||
|
||||
MANAGER_NAMESPACE = 'ironic.manager'
|
||||
|
||||
def start(self):
|
||||
super(ManagerService, self).start()
|
||||
# TODO: connect with storage driver
|
||||
|
||||
def initialize_(self, service):
|
||||
LOG.debug(_('Manager initializing service hooks'))
|
||||
|
||||
def process_notification(self, notification):
|
||||
LOG.debug(_('Received notification %r',
|
||||
notification.get('event_type')))
|
||||
|
||||
def periodic_tasks(self, context):
|
||||
pass
|
Loading…
Reference in New Issue