Merge "ksa auth conf and client for Cyborg access"
This commit is contained in:
commit
35240b0d8c
0
nova/accelerator/__init__.py
Normal file
0
nova/accelerator/__init__.py
Normal file
32
nova/accelerator/cyborg.py
Normal file
32
nova/accelerator/cyborg.py
Normal file
@ -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)
|
@ -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)
|
||||
|
43
nova/conf/cyborg.py
Normal file
43
nova/conf/cyborg.py
Normal file
@ -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))
|
||||
}
|
@ -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 = []
|
||||
|
0
nova/tests/unit/accelerator/__init__.py
Normal file
0
nova/tests/unit/accelerator/__init__.py
Normal file
42
nova/tests/unit/accelerator/test_cyborg.py
Normal file
42
nova/tests/unit/accelerator/test_cyborg.py
Normal file
@ -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)
|
Loading…
Reference in New Issue
Block a user