Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

cinder_modwsgi.py cinder flags no longer exists #968

Open
muraiki opened this issue Jul 23, 2014 · 2 comments
Open

cinder_modwsgi.py cinder flags no longer exists #968

muraiki opened this issue Jul 23, 2014 · 2 comments

Comments

@muraiki
Copy link

muraiki commented Jul 23, 2014

In cinder_modwsgi.py, cinder.flags is used to handle arguments but flags no longer exists; as such, the supplied cinder_modwsgi.py file will not work for Cinder on the Icehouse release.

It seems that flags has been removed in favor of using oslo.config. However, as the transition to using oslo.config is not complete, cinder.common.config is actually a wrapper around oslo.config that tries to emulate gflags. More information can be found in cinder/common/config.py and this commit.

In the meantime I've tried using this as a wsgi script:

import sys
from cinder.openstack.common import log as logging
from cinder.common import config
from paste import deploy

config_files = ['/etc/cinder/api-paste.ini', '/etc/cinder/cinder.conf']

# The following won't work yet because Cinder doesn't actually have full
# oslo.conf support but rather has a wrapper that emulates flags
# config.parse_args([], default_config_files=config_files)

LOG = logging.getLogger(__name__)
logging.setup("cinder")

paste_conf = '/etc/cinder/api-paste.ini'

application = deploy.loadapp('config:%s' % paste_conf, name="osapi_volume")

However, it results in the following stack trace:

2014-07-22 20:14:33.978 29996 CRITICAL cinder [-] AssertionError
2014-07-22 20:14:33.978 29996 TRACE cinder Traceback (most recent call last):
2014-07-22 20:14:33.978 29996 TRACE cinder   File "cinder-muraiki.wsgi", line 14, in <module>
2014-07-22 20:14:33.978 29996 TRACE cinder     application = deploy.loadapp('config:%s' % conf, name=name)
2014-07-22 20:14:33.978 29996 TRACE cinder   File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", l
ine 247, in loadapp
2014-07-22 20:14:33.978 29996 TRACE cinder     return loadobj(APP, uri, name=name, **kw)
2014-07-22 20:14:33.978 29996 TRACE cinder   File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", l
ine 272, in loadobj
2014-07-22 20:14:33.978 29996 TRACE cinder     return context.create()
2014-07-22 20:14:33.978 29996 TRACE cinder   File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", l
ine 710, in create
2014-07-22 20:14:33.978 29996 TRACE cinder     return self.object_type.invoke(self)
2014-07-22 20:14:33.978 29996 TRACE cinder   File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", l
ine 144, in invoke
2014-07-22 20:14:33.978 29996 TRACE cinder     **context.local_conf)
2014-07-22 20:14:33.978 29996 TRACE cinder   File "/usr/lib/python2.7/dist-packages/paste/deploy/util.py", line 
55, in fix_call
2014-07-22 20:14:33.978 29996 TRACE cinder     val = callable(*args, **kw)
2014-07-22 20:14:33.978 29996 TRACE cinder   File "/opt/stack/cinder/cinder/api/__init__.py", line 30, in root_a
pp_factory
2014-07-22 20:14:33.978 29996 TRACE cinder     return paste.urlmap.urlmap_factory(loader, global_conf, **local_c
onf)
2014-07-22 20:14:33.978 29996 TRACE cinder   File "/usr/lib/python2.7/dist-packages/paste/urlmap.py", line 28, i
n urlmap_factory
2014-07-22 20:14:33.978 29996 TRACE cinder     app = loader.get_app(app_name, global_conf=global_conf)
2014-07-22 20:14:33.978 29996 TRACE cinder   File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", l
ine 350, in get_app
2014-07-22 20:14:33.978 29996 TRACE cinder     name=name, global_conf=global_conf).create()
2014-07-22 20:14:33.978 29996 TRACE cinder   File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", l
ine 710, in create
2014-07-22 20:14:33.978 29996 TRACE cinder     return self.object_type.invoke(self)
2014-07-22 20:14:33.978 29996 TRACE cinder   File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", l
ine 144, in invoke
2014-07-22 20:14:33.978 29996 TRACE cinder     **context.local_conf)
2014-07-22 20:14:33.978 29996 TRACE cinder   File "/usr/lib/python2.7/dist-packages/paste/deploy/util.py", line 
55, in fix_call
2014-07-22 20:14:33.978 29996 TRACE cinder     val = callable(*args, **kw)
2014-07-22 20:14:33.978 29996 TRACE cinder   File "/opt/stack/cinder/cinder/api/middleware/auth.py", line 55, in
 pipeline_factory
2014-07-22 20:14:33.978 29996 TRACE cinder     app = loader.get_app(pipeline[-1])
2014-07-22 20:14:33.978 29996 TRACE cinder   File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", l
ine 350, in get_app
2014-07-22 20:14:33.978 29996 TRACE cinder     name=name, global_conf=global_conf).create()
2014-07-22 20:14:33.978 29996 TRACE cinder   File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", l
ine 710, in create
2014-07-22 20:14:33.978 29996 TRACE cinder     return self.object_type.invoke(self)
2014-07-22 20:14:33.978 29996 TRACE cinder   File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", l
ine 146, in invoke
2014-07-22 20:14:33.978 29996 TRACE cinder     return fix_call(context.object, context.global_conf, **context.lo
cal_conf)
2014-07-22 20:14:33.978 29996 TRACE cinder   File "/usr/lib/python2.7/dist-packages/paste/deploy/util.py", line 
55, in fix_call
2014-07-22 20:14:33.978 29996 TRACE cinder     val = callable(*args, **kw)
2014-07-22 20:14:33.978 29996 TRACE cinder   File "/opt/stack/cinder/cinder/api/openstack/__init__.py", line 71,
 in factory
2014-07-22 20:14:33.978 29996 TRACE cinder     return cls()
2014-07-22 20:14:33.978 29996 TRACE cinder   File "/opt/stack/cinder/cinder/api/openstack/__init__.py", line 82,
 in __init__
2014-07-22 20:14:33.978 29996 TRACE cinder     self._setup_routes(mapper, ext_mgr)
2014-07-22 20:14:33.978 29996 TRACE cinder   File "/opt/stack/cinder/cinder/api/v2/router.py", line 49, in _setu
p_routes
2014-07-22 20:14:33.978 29996 TRACE cinder     self.resources['volumes'] = volumes.create_resource(ext_mgr)
2014-07-22 20:14:33.978 29996 TRACE cinder   File "/opt/stack/cinder/cinder/api/v2/volumes.py", line 420, in cre
ate_resource
2014-07-22 20:14:33.978 29996 TRACE cinder     return wsgi.Resource(VolumeController(ext_mgr))
2014-07-22 20:14:33.978 29996 TRACE cinder   File "/opt/stack/cinder/cinder/api/v2/volumes.py", line 157, in __i
nit__
2014-07-22 20:14:33.978 29996 TRACE cinder     self.volume_api = cinder_volume.API()
2014-07-22 20:14:33.978 29996 TRACE cinder   File "/opt/stack/cinder/cinder/volume/api.py", line 106, in __init_
_
2014-07-22 20:14:33.978 29996 TRACE cinder     self.scheduler_rpcapi = scheduler_rpcapi.SchedulerAPI()
2014-07-22 20:14:33.978 29996 TRACE cinder   File "/opt/stack/cinder/cinder/scheduler/rpcapi.py", line 49, in __
init__
2014-07-22 20:14:33.978 29996 TRACE cinder     self.client = rpc.get_client(target, version_cap='1.5')
2014-07-22 20:14:33.978 29996 TRACE cinder   File "/opt/stack/cinder/cinder/rpc.py", line 130, in get_client
2014-07-22 20:14:33.978 29996 TRACE cinder     assert TRANSPORT is not None
2014-07-22 20:14:33.978 29996 TRACE cinder AssertionError
2014-07-22 20:14:33.978 29996 TRACE cinder

This is probably happening because the defaults from config.py are being used. As such, the question is how do we get our settings from /etc/cinder/cinder.conf into Cinder?

I'm not terribly familiar with Cinder and Oslo, nor am I using Chef, but this is one of the few (albeit not currently working) examples of using Cinder with mod_wsgi I could find. Thank you!

@muraiki
Copy link
Author

muraiki commented Jul 23, 2014

DuncanT- from #openstack-cinder wrote up this wsgi script, which seems to work ok.

import sys
from cinder.openstack.common import log as logging
from paste import deploy
from cinder.common import config
from oslo.config import cfg
from cinder.openstack.common import gettextutils
from cinder import version
from cinder import rpc

gettextutils.install('cinder')

CONF=cfg.CONF
CONF("", project='cinder', version=version.version_string())
logging.setup("cinder")

rpc.init(CONF)

conf = '/etc/cinder/api-paste.ini'
name = "osapi_volume"

application = deploy.loadapp('config:%s' % conf, name=name)

@SqiSch
Copy link

SqiSch commented Aug 26, 2015

Update of a apache cinder-api wsgi usable in the kilo release:

import sys
from oslo_log import log as logging

from paste import deploy
from cinder.common import config
from oslo.config import cfg
from cinder.openstack.common import gettextutils
from cinder import version
from cinder import rpc

gettextutils.install('cinder')

CONF=cfg.CONF
CONF("", project='cinder', version=version.version_string())
logging.setup(CONF, "cinder")

rpc.init(CONF)

conf = '/etc/cinder/api-paste.ini'
name = "osapi_volume"

application = deploy.loadapp('config:%s' % conf, name=name)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants