Repository URL to install this package:
|
Version:
5.2.1.1.dev1 ▾
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright (c) 2013 TrilioData, Inc.
# All Rights Reserved.
from cinderclient import exceptions
from barbicanclient import client as bc
from keystoneauth1 import session
from keystoneclient.auth import identity
from keystoneclient import exceptions as ks_exceptions
from oslo_log import log as logging
from workloadmgr import exception
from oslo_config import cfg
from workloadmgr.common.i18n import _
from workloadmgr.common.i18n import _LI
from workloadmgr.common.clients import client_plugin
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
CLIENT_NAME = 'barbican'
class BarbicanClientPlugin(client_plugin.ClientPlugin):
#TODO: Add Retry for barbican clients.
exceptions_module = exceptions
def _create(self):
con = self.context
endpoint_type = self._get_client_option(CLIENT_NAME, 'endpoint_type')
service_type = 'key-manager'
try:
management_url = self.url_for(service_type=service_type,
endpoint_type=endpoint_type)
except Exception as ex:
LOG.exception(ex)
raise ks_exceptions.EndpointNotFound(
"Could not find {0} in service catalog. Please make sure {0} is installed.".format(CLIENT_NAME)
)
args = {
'project_id': con.tenant_id,
'endpoint': management_url,
'auth': con.auth_plugin,
'verify': CONF.clients.get('cafile', False),
}
client_version = 'v1'
client = bc.Client(client_version, **args)
client.client.management_url = management_url
return client
def is_not_found(self, ex):
return isinstance(ex, exceptions.NotFound)
def is_over_limit(self, ex):
return isinstance(ex, exceptions.OverLimit)
def is_conflict(self, ex):
return (isinstance(ex, exceptions.ClientException) and
ex.code == 409)