diff --git a/doc/source/user/configuration.rst b/doc/source/user/configuration.rst index d9ae49a..221018b 100644 --- a/doc/source/user/configuration.rst +++ b/doc/source/user/configuration.rst @@ -15,6 +15,9 @@ Moreover, the following options are available: * ``ooi_listen_port``: Port ooi will bind to. Defaults to ``8787``. * ``ooi_workers``: Number of workers to spawn, by default it is set to the number of CPUs in the node. + * ``neutron_ooi_endpoint``: Neutron endpoint, configures the network + management by using neutron. If this is not set, the system will use + nova-network. Paste Configuration ******************* @@ -37,7 +40,6 @@ First it is needed to add the OCCI filter like this:: [filter:occi] paste.filter_factory = ooi.wsgi:OCCIMiddleware.factory openstack_version = /v2 - neutron_ooi_endpoint = http://127.0.0.1:9696/v2.0 ``openstack_version`` can be configured to any of the supported OpenStack API versions, as indicated in Table :ref:`api-versions`. If it is not configured, @@ -54,14 +56,6 @@ by default it will take the ``/v2.1`` value. v2.1 ``/v2.1`` ``[composite:openstack_compute_api_v21]`` ===================== ===================== ============================================= -OpenStack has two components to support network management. On one side, nova-network -provides a simple network management which creates, lists, shows information for, and deletes networks. -Admin permissions are required to create and delete networks. On the other side, the neutron component -allows to manage and configure advanced network features. OOI implements the OCCI interface to simple -network management by using either nova-network or neutron. -``neutron_ooi_endpoint`` configures the neutron endpoint. It is an optional parameter that configures -the network management by using neutron. If this is not set, the system will use nova-network. - The next step is to create a ``composite`` section for the OCCI interface. It is needed to duplicate the :ref:`corresponding OpenStack API ``composite``` section, renaming it to ``occi_api_v11``. Once duplicated, the ``occi`` middleware needs @@ -85,10 +79,21 @@ The last step regarding the API configuration is to add it to create the Finally, you need to enable it in the OpenStack nova configuration, so that it is loaded properly. Add ``ooi`` to the ``enabled_apis`` option in the configuration file and adapt the port if needed, via the ``ooi_listen_port`` -(by default it listens in the ``8787`` port):: +(by default it listens in the ``8787`` port). On the other hand, network management +by using neutron can be configure via the ``neutron_ooi_endpoint`` option +(if it is not set, the system will use nova-network):: enabled_apis=ec2,osapi_compute,metadata,ooi ooi_listen_port=8787 + neutron_ooi_endpoint=http://127.0.0.1:9696/v2.0 + +OpenStack has two components to support network management. On one side, nova-network +provides a simple network management which creates, lists, shows information for, and deletes networks. +Admin permissions are required to create and delete networks. On the other side, the neutron component +allows to manage and configure advanced network features. OOI implements the OCCI interface to simple +network management by using either nova-network or neutron. +``neutron_ooi_endpoint`` configures the neutron endpoint. It is an optional parameter that configures +the network management by using neutron. If this is not set, the system will use nova-network. If everything is OK, after rebooting the ``nova-api`` service you should be able to access your OCCI endpoint at:: diff --git a/etc/api-paste-juno.ini.sample b/etc/api-paste-juno.ini.sample index b5da281..0ac1530 100644 --- a/etc/api-paste-juno.ini.sample +++ b/etc/api-paste-juno.ini.sample @@ -9,7 +9,6 @@ use = call:nova.api.openstack.urlmap:urlmap_factory [filter:occi] paste.filter_factory = ooi.wsgi:OCCIMiddleware.factory openstack_version = /v2.0 -neutron_ooi_endpoint = http://127.0.0.1:9696/v2.0 [composite:occi_api_11] use = call:nova.api.auth:pipeline_factory diff --git a/etc/api-paste-kilo.ini.sample b/etc/api-paste-kilo.ini.sample index 11f9d82..b397939 100644 --- a/etc/api-paste-kilo.ini.sample +++ b/etc/api-paste-kilo.ini.sample @@ -9,7 +9,6 @@ use = call:nova.api.openstack.urlmap:urlmap_factory [filter:occi] paste.filter_factory = ooi.wsgi:OCCIMiddleware.factory openstack_version = /v2.1 -neutron_ooi_endpoint = http://127.0.0.1:9696/v2.0 [composite:occi_api_11] use = call:nova.api.auth:pipeline_factory_v21 diff --git a/etc/api-paste-liberty.ini.sample b/etc/api-paste-liberty.ini.sample index 57bb85b..a9b82c3 100644 --- a/etc/api-paste-liberty.ini.sample +++ b/etc/api-paste-liberty.ini.sample @@ -9,7 +9,6 @@ use = call:nova.api.openstack.urlmap:urlmap_factory [filter:occi] paste.filter_factory = ooi.wsgi:OCCIMiddleware.factory openstack_version = /v2.1 -neutron_ooi_endpoint = http://127.0.0.1:9696/v2.0 [composite:occi_api_11] use = call:nova.api.auth:pipeline_factory_v21 diff --git a/etc/ooi.conf.sample b/etc/ooi.conf.sample index 07d426f..785e94a 100644 --- a/etc/ooi.conf.sample +++ b/etc/ooi.conf.sample @@ -13,3 +13,7 @@ # Number of workers for OCCI (ooi) API service. The default will be equal to # the number of CPUs available. (integer value) #ooi_workers = + +# Neutron endpoint which configures the network management by using neutron. +# If this is not set, the system will use nova-network. +neutron_ooi_endpoint = \ No newline at end of file diff --git a/ooi/exception.py b/ooi/exception.py index f6eaf2d..284852d 100644 --- a/ooi/exception.py +++ b/ooi/exception.py @@ -16,10 +16,18 @@ import webob.exc +import warnings + from ooi.log import log as logging LOG = logging.getLogger(__name__) +warnings.simplefilter("default", DeprecationWarning) + + +def raise_deprecation_message(message): + warnings.warn(message, DeprecationWarning, stacklevel=2) + class ConvertedException(webob.exc.WSGIHTTPException): def __init__(self, code=0, title="", explanation=""): diff --git a/ooi/tests/middleware/test_functional_network.py b/ooi/tests/middleware/test_functional_network.py index 9bbabe3..b26bfc9 100644 --- a/ooi/tests/middleware/test_functional_network.py +++ b/ooi/tests/middleware/test_functional_network.py @@ -18,7 +18,9 @@ import mock import uuid +import warnings +from oslo_config import cfg import webob from ooi.api import helpers @@ -36,10 +38,16 @@ class TestFunctionalNeutron(test_middleware.TestMiddleware): self.schema = 'http://schemas.ogf.org/occi/infrastructure#network' self.accept = self.content_type = None self.application_url = fakes.application_url - self.neutron_endpoint = "foo" - self.app = wsgi.OCCIMiddleware( - None, - neutron_ooi_endpoint=self.neutron_endpoint) + neutron_ooi_endpoint = "foo" + + def mock_endpoint(self, bar): + if bar == "neutron_ooi_endpoint": + return neutron_ooi_endpoint + + with mock.patch.object(cfg.ConfigOpts, "__getattr__", + side_effect=mock_endpoint, + autospec=True): + self.app = wsgi.OCCIMiddleware(None) def assertExpectedResult(self, expected, result): expected = ["%s: %s" % e for e in expected] @@ -47,6 +55,21 @@ class TestFunctionalNeutron(test_middleware.TestMiddleware): results = str(result.text).splitlines() self.assertItemsEqual(expected, results) + def test_deprecated_configuration(self): + with warnings.catch_warnings(record=True) as w: + neutron_endopoint = "/foo" + warnings.simplefilter("always", DeprecationWarning) + wsgi.OCCIMiddleware(None, + neutron_ooi_endpoint=neutron_endopoint) + expected_message = ( + "Configuration of neutron_ooi_endpoint" + " in api-paste.ini file is deprecated," + " include it in nova.conf") + self.assertEqual(1, len(w)) + self.assertIs(DeprecationWarning, + w[-1].category) + self.assertEqual(expected_message, w[-1].message.message) + @mock.patch.object(helpers.BaseHelper, "_get_req") def test_list_networks_empty(self, m): tenant = fakes.tenants["bar"] @@ -208,9 +231,7 @@ class TestFunctionalNova(test_middleware.TestMiddleware): self.schema = 'http://schemas.ogf.org/occi/infrastructure#network' self.accept = self.content_type = None self.application_url = fakes.application_url - self.app = wsgi.OCCIMiddleware( - None, - None) + self.app = wsgi.OCCIMiddleware(None) def assertExpectedResult(self, expected, result): expected = ["%s: %s" % e for e in expected] diff --git a/ooi/wsgi/__init__.py b/ooi/wsgi/__init__.py index c220e3f..8aae506 100644 --- a/ooi/wsgi/__init__.py +++ b/ooi/wsgi/__init__.py @@ -41,15 +41,15 @@ occi_opts = [ config.cfg.StrOpt('ooi_listen', default="0.0.0.0", help='The IP address on which the OCCI (ooi) API ' - 'will listen.'), + 'will listen.'), config.cfg.IntOpt('ooi_listen_port', default=8787, help='The port on which the OCCI (ooi) API ' - 'will listen.'), + 'will listen.'), config.cfg.IntOpt('ooi_workers', help='Number of workers for OCCI (ooi) API service. ' - 'The default will be equal to the number of CPUs ' - 'available.'), + 'The default will be equal to the number of CPUs ' + 'available.'), # NEUTRON config.cfg.StrOpt('neutron_ooi_endpoint', default=None, @@ -114,9 +114,19 @@ class OCCIMiddleware(object): neutron_ooi_endpoint=None): self.application = application self.openstack_version = openstack_version - self.neutron_ooi_endpoint = neutron_ooi_endpoint - self.resources = {} + if CONF.neutron_ooi_endpoint: + self.neutron_ooi_endpoint = CONF.neutron_ooi_endpoint + elif neutron_ooi_endpoint: + exception.raise_deprecation_message( + "Configuration of neutron_ooi_endpoint" + " in api-paste.ini file is deprecated," + " include it in nova.conf") + self.neutron_ooi_endpoint = neutron_ooi_endpoint + else: + self.neutron_ooi_endpoint = None + + self.resources = {} self.mapper = routes.Mapper() self._setup_routes() @@ -251,7 +261,7 @@ class OCCIMiddleware(object): match = re.search(r"\bOCCI/\d\.\d\b", req.user_agent) if match and self.occi_string != match.group(): return Fault(webob.exc.HTTPNotImplemented( - explanation="%s not supported" % match.group())) + explanation="%s not supported" % match.group())) match = self.mapper.match(req.path_info, req.environ) if not match: @@ -456,12 +466,12 @@ class ResourceExceptionHandler(object): if isinstance(ex_value, exception.OCCIException): raise Fault(exception.ConvertedException( - code=ex_value.code, - explanation=ex_value.format_message())) + code=ex_value.code, + explanation=ex_value.format_message())) elif isinstance(ex_value, exception.NotImplemented): raise Fault(exception.ConvertedException( - code=ex_value.code, - explanation=ex_value.format_message())) + code=ex_value.code, + explanation=ex_value.format_message())) elif isinstance(ex_value, TypeError): exc_info = (ex_type, ex_value, ex_traceback) LOG.error('Exception handling resource: %s', ex_value,