summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nova/accelerator/__init__.py0
-rw-r--r--nova/accelerator/cyborg.py32
-rw-r--r--nova/conf/__init__.py2
-rw-r--r--nova/conf/cyborg.py43
-rw-r--r--nova/context.py3
-rw-r--r--nova/tests/unit/accelerator/__init__.py0
-rw-r--r--nova/tests/unit/accelerator/test_cyborg.py42
7 files changed, 121 insertions, 1 deletions
diff --git a/nova/accelerator/__init__.py b/nova/accelerator/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/nova/accelerator/__init__.py
diff --git a/nova/accelerator/cyborg.py b/nova/accelerator/cyborg.py
new file mode 100644
index 0000000000..dca3688665
--- /dev/null
+++ b/nova/accelerator/cyborg.py
@@ -0,0 +1,32 @@
+# Copyright 2019 Intel
+#
+# 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_log import log as logging
+
+from nova import service_auth
+from nova import utils
+
+
+LOG = logging.getLogger(__name__)
+
+
+def get_client(context):
+ return _CyborgClient(context)
+
+
+class _CyborgClient(object):
+
+ def __init__(self, context):
+ auth = service_auth.get_auth_plugin(context)
+ self._client = utils.get_ksa_adapter('accelerator', ksa_auth=auth)
diff --git a/nova/conf/__init__.py b/nova/conf/__init__.py
index fb6752c8e2..a2be1c01ea 100644
--- a/nova/conf/__init__.py
+++ b/nova/conf/__init__.py
@@ -29,6 +29,7 @@ from nova.conf import conductor
from nova.conf import configdrive
from nova.conf import console
from nova.conf import consoleauth
+from nova.conf import cyborg
from nova.conf import database
from nova.conf import devices
from nova.conf import ephemeral_storage
@@ -80,6 +81,7 @@ conductor.register_opts(CONF)
configdrive.register_opts(CONF)
console.register_opts(CONF)
consoleauth.register_opts(CONF)
+cyborg.register_opts(CONF)
database.register_opts(CONF)
devices.register_opts(CONF)
ephemeral_storage.register_opts(CONF)
diff --git a/nova/conf/cyborg.py b/nova/conf/cyborg.py
new file mode 100644
index 0000000000..f6b4665324
--- /dev/null
+++ b/nova/conf/cyborg.py
@@ -0,0 +1,43 @@
+# Copyright 2019 OpenStack Foundation
+#
+# 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 keystoneauth1 import loading as ks_loading
+from oslo_config import cfg
+
+from nova.conf import utils as confutils
+
+
+DEFAULT_SERVICE_TYPE = 'accelerator'
+CYBORG_GROUP = 'cyborg'
+
+cyborg_group = cfg.OptGroup(
+ CYBORG_GROUP,
+ title='Cyborg Options',
+ help="""
+Configuration options for Cyborg (accelerator as a service).
+""")
+
+
+def register_opts(conf):
+ conf.register_group(cyborg_group)
+ confutils.register_ksa_opts(conf, cyborg_group, DEFAULT_SERVICE_TYPE,
+ include_auth=False)
+
+
+def list_opts():
+ return {
+ cyborg_group: (
+ ks_loading.get_session_conf_options() +
+ confutils.get_ksa_adapter_opts(DEFAULT_SERVICE_TYPE))
+ }
diff --git a/nova/context.py b/nova/context.py
index 76c0086f63..90aaa14a39 100644
--- a/nova/context.py
+++ b/nova/context.py
@@ -118,7 +118,8 @@ class RequestContext(context.RequestContext):
# Only include required parts of service_catalog
self.service_catalog = [s for s in service_catalog
if s.get('type') in ('image', 'block-storage', 'volumev3',
- 'key-manager', 'placement', 'network')]
+ 'key-manager', 'placement', 'network',
+ 'accelerator')]
else:
# if list is empty or none
self.service_catalog = []
diff --git a/nova/tests/unit/accelerator/__init__.py b/nova/tests/unit/accelerator/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/nova/tests/unit/accelerator/__init__.py
diff --git a/nova/tests/unit/accelerator/test_cyborg.py b/nova/tests/unit/accelerator/test_cyborg.py
new file mode 100644
index 0000000000..9290991524
--- /dev/null
+++ b/nova/tests/unit/accelerator/test_cyborg.py
@@ -0,0 +1,42 @@
+# Copyright 2019 OpenStack Foundation
+#
+# 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 nova.accelerator import cyborg
+from nova import context
+from nova import test
+
+
+class CyborgTestCase(test.NoDBTestCase):
+ def setUp(self):
+ super(CyborgTestCase, self).setUp()
+ self.context = context.get_admin_context()
+ self.client = cyborg.get_client(self.context)
+
+ def test_get_client(self):
+ # Set up some ksa conf options
+ region = 'MyRegion'
+ endpoint = 'http://example.com:1234'
+ self.flags(group='cyborg',
+ region_name=region,
+ endpoint_override=endpoint)
+ ctxt = context.get_admin_context()
+ client = cyborg.get_client(ctxt)
+
+ # Dig into the ksa adapter a bit to ensure the conf options got through
+ # We don't bother with a thorough test of get_ksa_adapter - that's done
+ # elsewhere - this is just sanity-checking that we spelled things right
+ # in the conf setup.
+ self.assertEqual('accelerator', client._client.service_type)
+ self.assertEqual(region, client._client.region_name)
+ self.assertEqual(endpoint, client._client.endpoint_override)