This is the first implementation of the barbicanclient plugin for the OpenStack CLI. Since we chose to use cliff in for the client, the integration with the OCC is quite seamless. Only change that needed to be done was that, since the OCC uses a ClientManager class to fetch the specific libraries for the components, we needed to simulate that in the barbicanclient. Currently, the plugin can be used if the barbican server is configured with keystone authentication. This is because currently there is no way for us to set the X-Project-Id header manually from the client (if the plugin is being used) but that functionality is out of the scope of this first implementation. Change-Id: I37fd158af24e785bc0b7125c6b4c1a9795927a10
44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
# 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.
|
|
|
|
import logging
|
|
|
|
from barbicanclient import client
|
|
|
|
LOG = logging.getLogger(__name__)
|
|
|
|
DEFAULT_API_VERSION = '1'
|
|
API_VERSION_OPTION = 'os_key_manager_api_version'
|
|
API_NAME = 'key_manager'
|
|
API_VERSIONS = {
|
|
'1': 'barbicanclient.client.Client',
|
|
}
|
|
|
|
|
|
def make_client(instance):
|
|
"""Returns a Barbican service client."""
|
|
return client.Client(session=instance.session,
|
|
region_name=instance._region_name)
|
|
|
|
|
|
def build_option_parser(parser):
|
|
"""Hook to add global options."""
|
|
parser.add_argument('--os-key-manager-api-version',
|
|
metavar='<key-manager-api-version>',
|
|
default=client.env(
|
|
'OS_KEY_MANAGER_API_VERSION',
|
|
default=DEFAULT_API_VERSION),
|
|
help=('Barbican API version, default=' +
|
|
DEFAULT_API_VERSION +
|
|
' (Env: OS_KEY_MANAGER_API_VERSION)'))
|
|
return parser
|