diff options
Diffstat (limited to 'barbicanclient')
-rw-r--r-- | barbicanclient/barbican.py | 1 | ||||
-rw-r--r-- | barbicanclient/barbican_cli/v1/containers.py | 2 | ||||
-rw-r--r-- | barbicanclient/client.py | 118 | ||||
-rw-r--r-- | barbicanclient/v1/orders.py | 11 |
4 files changed, 66 insertions, 66 deletions
diff --git a/barbicanclient/barbican.py b/barbicanclient/barbican.py index dbaa3d3..0e58236 100644 --- a/barbicanclient/barbican.py +++ b/barbicanclient/barbican.py @@ -385,5 +385,6 @@ def main(argv=sys.argv[1:]): barbican_app = Barbican() return barbican_app.run(argv) + if __name__ == '__main__': # pragma: no cover sys.exit(main(sys.argv[1:])) diff --git a/barbicanclient/barbican_cli/v1/containers.py b/barbicanclient/barbican_cli/v1/containers.py index 1da349b..ccb541b 100644 --- a/barbicanclient/barbican_cli/v1/containers.py +++ b/barbicanclient/barbican_cli/v1/containers.py @@ -135,5 +135,5 @@ class CreateContainer(show.ShowOne): raise ValueError("Must supply at least one secret.") return dict( (s.split('=')[0], s.split('=')[1]) - for s in secrets if s.count('=') is 1 + for s in secrets if s.count('=') == 1 ) diff --git a/barbicanclient/client.py b/barbicanclient/client.py index f1910e7..dc91003 100644 --- a/barbicanclient/client.py +++ b/barbicanclient/client.py @@ -120,65 +120,65 @@ class _HTTPClient(adapter.Adapter): def Client(version=None, session=None, *args, **kwargs): - """Barbican client used to interact with barbican service. - - :param version: The API version to use. - :param session: An instance of keystoneauth1.session.Session that - can be either authenticated, or not authenticated. When using - a non-authenticated Session, you must provide some additional - parameters. When no session is provided it will default to a - non-authenticated Session. - :param endpoint: Barbican endpoint url. Required when a session is not - given, or when using a non-authenticated session. - When using an authenticated session, the client will attempt - to get an endpoint from the session. - :param project_id: The project ID used for context in Barbican. - Required when a session is not given, or when using a - non-authenticated session. - When using an authenticated session, the project ID will be - provided by the authentication mechanism. - :param verify: When a session is not given, the client will create - a non-authenticated session. This parameter is passed to the - session that is created. If set to False, it allows - barbicanclient to perform "insecure" TLS (https) requests. - The server's certificate will not be verified against any - certificate authorities. - WARNING: This option should be used with caution. - :param service_type: Used as an endpoint filter when using an - authenticated keystone session. Defaults to 'key-manager'. - :param service_name: Used as an endpoint filter when using an - authenticated keystone session. - :param interface: Used as an endpoint filter when using an - authenticated keystone session. Defaults to 'public'. - :param region_name: Used as an endpoint filter when using an - authenticated keystone session. - """ - LOG.debug("Creating Client object") - - if not session: - session = ks_session.Session(verify=kwargs.pop('verify', True)) - - if session.auth is None and kwargs.get('auth') is None: - if not kwargs.get('endpoint'): - raise ValueError('Barbican endpoint url must be provided when ' - 'not using auth in the Keystone Session.') - - if kwargs.get('project_id') is None: - raise ValueError('Project ID must be provided when not using ' - 'auth in the Keystone Session') - if not version: - version = _DEFAULT_API_VERSION - - try: - client_path = _SUPPORTED_API_VERSION_MAP[version] - client_class = importutils.import_class(client_path) - return client_class(session=session, *args, **kwargs) - except (KeyError, ValueError): - supported_versions = ', '.join(_SUPPORTED_API_VERSION_MAP.keys()) - msg = ("Invalid client version %(version)s; must be one of: " - "%(versions)s") % {'version': version, - 'versions': supported_versions} - raise exceptions.UnsupportedVersion(msg) + """Barbican client used to interact with barbican service. + + :param version: The API version to use. + :param session: An instance of keystoneauth1.session.Session that + can be either authenticated, or not authenticated. When using + a non-authenticated Session, you must provide some additional + parameters. When no session is provided it will default to a + non-authenticated Session. + :param endpoint: Barbican endpoint url. Required when a session is not + given, or when using a non-authenticated session. + When using an authenticated session, the client will attempt + to get an endpoint from the session. + :param project_id: The project ID used for context in Barbican. + Required when a session is not given, or when using a + non-authenticated session. + When using an authenticated session, the project ID will be + provided by the authentication mechanism. + :param verify: When a session is not given, the client will create + a non-authenticated session. This parameter is passed to the + session that is created. If set to False, it allows + barbicanclient to perform "insecure" TLS (https) requests. + The server's certificate will not be verified against any + certificate authorities. + WARNING: This option should be used with caution. + :param service_type: Used as an endpoint filter when using an + authenticated keystone session. Defaults to 'key-manager'. + :param service_name: Used as an endpoint filter when using an + authenticated keystone session. + :param interface: Used as an endpoint filter when using an + authenticated keystone session. Defaults to 'public'. + :param region_name: Used as an endpoint filter when using an + authenticated keystone session. + """ + LOG.debug("Creating Client object") + + if not session: + session = ks_session.Session(verify=kwargs.pop('verify', True)) + + if session.auth is None and kwargs.get('auth') is None: + if not kwargs.get('endpoint'): + raise ValueError('Barbican endpoint url must be provided when ' + 'not using auth in the Keystone Session.') + + if kwargs.get('project_id') is None: + raise ValueError('Project ID must be provided when not using ' + 'auth in the Keystone Session') + if not version: + version = _DEFAULT_API_VERSION + + try: + client_path = _SUPPORTED_API_VERSION_MAP[version] + client_class = importutils.import_class(client_path) + return client_class(session=session, *args, **kwargs) + except (KeyError, ValueError): + supported_versions = ', '.join(_SUPPORTED_API_VERSION_MAP.keys()) + msg = ("Invalid client version %(version)s; must be one of: " + "%(versions)s") % {'version': version, + 'versions': supported_versions} + raise exceptions.UnsupportedVersion(msg) def env(*vars, **kwargs): diff --git a/barbicanclient/v1/orders.py b/barbicanclient/v1/orders.py index 15eca81..aee762a 100644 --- a/barbicanclient/v1/orders.py +++ b/barbicanclient/v1/orders.py @@ -417,12 +417,11 @@ class OrderManager(base.BaseEntityManager): # validate key_order meta fields. if resp_type == 'key' and ( set(response['meta'].keys()) - set(KeyOrder._validMeta)): - invalidFields = ', '.join( - map(str, set( - response['meta'].keys()) - - set(KeyOrder._validMeta))) - raise TypeError( - 'Invalid KeyOrder meta field: [%s]' % invalidFields) + invalidFields = ', '.join( + map(str, set(response['meta'].keys()) - + set(KeyOrder._validMeta))) + raise TypeError( + 'Invalid KeyOrder meta field: [%s]' % invalidFields) response.update(response.pop('meta')) |