Create host inventory services (api, conductor and agent) and
python-inventoryclient.
The inventory service collects the host resources and provides a
REST API and client to expose the host resources.
Create plugin for integration with system configuration (sysinv)
service.
This is the initial inventory service infratructure commit.
Puppet configuration, SM integration and host integration with
sysinv(systemconfig) changes are pending and planned to be
delivered in future commits.
Tests Performed:
Verify the changes are inert on config_controller installation
and provisioning.
Puppet and spec changes are required in order to create keystone,
database and activate inventory services.
Unit tests performed (when puppet configuration for keystone, database
is applied):
Trigger host configure_check, configure signals into
systemconfig(sysinv).
Verify python-inventoryclient and api service:
Disks and related storage resources are pending.
inventory host-cpu-list/show
inventory host-device-list/show/modify
inventory host-ethernetport-list/show
inventory host-lldp-neighbor-list
inventory host-lldp-agent-list/show
inventory host-memory-list/show
inventory host-node-list/show
inventory host-port-list/show
Tox Unit tests:
inventory: pep8
python-inventoryclient: py27, pep8, cover, pylint
Change-Id: I744ac0de098608c55b9356abf180cc36601cfb8d
Story: 2002950
Task: 22952
Signed-off-by: John Kung <john.kung@windriver.com>
91 lines
2.0 KiB
Python
91 lines
2.0 KiB
Python
#
|
|
# Copyright (c) 2018 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
from oslo_config import cfg
|
|
from oslo_log import log
|
|
from oslo_service import service
|
|
from oslo_service import wsgi
|
|
import pecan
|
|
|
|
from inventory.api import config
|
|
from inventory.api import middleware
|
|
from inventory.common.i18n import _
|
|
from inventory.common import policy
|
|
|
|
CONF = cfg.CONF
|
|
|
|
LOG = log.getLogger(__name__)
|
|
|
|
_launcher = None
|
|
_launcher_pxe = None
|
|
|
|
|
|
def get_pecan_config():
|
|
# Set up the pecan configuration
|
|
filename = config.__file__.replace('.pyc', '.py')
|
|
return pecan.configuration.conf_from_file(filename)
|
|
|
|
|
|
def setup_app(config=None):
|
|
policy.init_enforcer()
|
|
|
|
if not config:
|
|
config = get_pecan_config()
|
|
|
|
pecan.configuration.set_config(dict(config), overwrite=True)
|
|
app_conf = dict(config.app)
|
|
|
|
app = pecan.make_app(
|
|
app_conf.pop('root'),
|
|
debug=CONF.debug,
|
|
logging=getattr(config, 'logging', {}),
|
|
force_canonical=getattr(config.app, 'force_canonical', True),
|
|
guess_content_type_from_ext=False,
|
|
wrap_app=middleware.ParsableErrorMiddleware,
|
|
**app_conf
|
|
)
|
|
return app
|
|
|
|
|
|
def load_paste_app(app_name=None):
|
|
"""Loads a WSGI app from a paste config file."""
|
|
if app_name is None:
|
|
app_name = cfg.CONF.prog
|
|
|
|
loader = wsgi.Loader(cfg.CONF)
|
|
app = loader.load_app(app_name)
|
|
return app
|
|
|
|
|
|
def app_factory(global_config, **local_conf):
|
|
return setup_app()
|
|
|
|
|
|
def serve(api_service, conf, workers=1):
|
|
global _launcher
|
|
|
|
if _launcher:
|
|
raise RuntimeError(_('serve() _launcher can only be called once'))
|
|
|
|
_launcher = service.launch(conf, api_service, workers=workers)
|
|
|
|
|
|
def serve_pxe(api_service, conf, workers=1):
|
|
global _launcher_pxe
|
|
|
|
if _launcher_pxe:
|
|
raise RuntimeError(_('serve() _launcher_pxe can only be called once'))
|
|
|
|
_launcher_pxe = service.launch(conf, api_service, workers=workers)
|
|
|
|
|
|
def wait():
|
|
_launcher.wait()
|
|
|
|
|
|
def wait_pxe():
|
|
_launcher_pxe.wait()
|