RETIRED, OpenStack Search (Searchlight) Client
Go to file
OpenStack Release Bot 75bb786669 Add Python3 wallaby unit tests
This is an automatically generated patch to ensure unit testing
is in place for all the of the tested runtimes for wallaby.

See also the PTI in governance [1].

[1]: https://governance.openstack.org/tc/reference/project-testing-interface.html

Change-Id: Ic7ac08fc4e54c815c0ccb3cc82b3bc999ea62a7f
2020-09-09 17:41:27 +00:00
doc Switch to newer openstackdocstheme and reno versions 2020-05-18 22:45:21 +02:00
releasenotes/notes [ussuri][goal] Drop python 2.7 support and testing 2020-01-22 02:36:31 +00:00
searchlightclient Remove six 2020-05-04 15:23:58 +08:00
tools Stop to use the __future__ module. 2020-06-02 20:51:32 +02:00
.gitignore Switch to stestr 2018-07-09 18:10:37 +07:00
.gitreview OpenDev Migration Patch 2019-04-19 19:34:24 +00:00
.stestr.conf Switch to stestr 2018-07-09 18:10:37 +07:00
.zuul.yaml Add Python3 wallaby unit tests 2020-09-09 17:41:27 +00:00
CONTRIBUTING.rst Update storyboard links 2019-03-18 12:22:55 +09:00
LICENSE Init searchlightclient base 2015-11-28 16:40:16 +08:00
README.rst [ussuri][goal] Drop python 2.7 support and testing 2020-01-22 02:36:31 +00:00
lower-constraints.txt [goal] Migrate testing to ubuntu focal 2020-08-05 01:41:57 +00:00
requirements.txt [goal] Migrate testing to ubuntu focal 2020-08-05 01:41:57 +00:00
setup.cfg Remove translation sections from setup.cfg 2020-05-14 20:16:09 +08:00
setup.py Cleanup py27 support 2020-04-04 17:13:18 +02:00
test-requirements.txt Fix hacking min version to 3.0.1 2020-05-12 21:06:00 -05:00
tox.ini Remove pypy job 2020-05-10 22:14:44 +08:00

README.rst

Team and repository tags

image

python-searchlightclient

OpenStack Indexing and Search API Client Library

This is a client library for Searchlight built on the Searchlight API. It provides a Python API (the searchlightclient module) and a command-line tool (searchlight).

The project is hosted on Storyboard, where bugs can be filed. The code is hosted on OpenStack git repository. Patches must be submitted using Gerrit, not git repo pull requests.

python-searchlightclient is licensed under the Apache License like the rest of OpenStack.

Contents:

Install the client from PyPI

The program python-searchlightclient package is published on PyPI and so can be installed using the pip tool, which will manage installing all python dependencies:

$ pip install python-searchlightclient

Note

The packages on PyPI may lag behind the git repo in functionality.

Setup the client from source

  • Clone repository for python-searchlightclient:

    $ git clone https://opendev.org/openstack/python-searchlightclient.git
    $ cd python-searchlightclient
  • Setup a virtualenv

Note

This is an optional step, but will allow Searchlightclient's dependencies to be installed in a contained environment that can be easily deleted if you choose to start over or uninstall Searchlightclient.

$ tox -evenv --notest

Activate the virtual environment whenever you want to work in it. All further commands in this section should be run with the venv active:

$ source .tox/venv/bin/activate

Note

When ALL steps are complete, deactivate the virtualenv: $ deactivate

  • Install Searchlightclient and its dependencies:

    (venv) $ python setup.py develop

Command-line API

Set Keystone environment variables to execute CLI commands against searchlight.

  • To execute CLI commands:

    $ export OS_USERNAME=<user>
    $ export OS_PASSWORD=<password>
    $ export OS_TENANT_NAME=<project>
    $ export OS_AUTH_URL='http://localhost:5000/v2.0/'

Note

With devstack you just need to $ source openrc <user> <project>. And you can work with a local installation by passing --os-token <TOKEN> and --os-url http://localhost:9393. You can also set up a Openstackclient config file to work with the CLI.

$ openstack
(openstack) search resource type list
+--------------------------+--------------------------+
| Name                     | Type                     |
+--------------------------+--------------------------+
| OS::Designate::RecordSet | OS::Designate::RecordSet |
| OS::Designate::Zone      | OS::Designate::Zone      |
| OS::Glance::Image        | OS::Glance::Image        |
| OS::Glance::Metadef      | OS::Glance::Metadef      |
| OS::Nova::Server         | OS::Nova::Server         |
+--------------------------+--------------------------+

Here are the full list of subcommands, Use -h to see options:

Subcommand Description
search facet list List Searchlight Facet
search resource type list List Searchlight Resource Type (Plugin)
search query Search Searchlight resource

Python API

To use with keystone as the authentication system:

>>> from keystoneclient.auth.identity import generic
>>> from keystoneclient import session
>>> from searchlightclient import client
>>> auth = generic.Password(auth_url=OS_AUTH_URL, username=OS_USERNAME, password=OS_PASSWORD, tenant_name=OS_TENANT_NAME)
>>> keystone_session = session.Session(auth=auth)
>>> sc = client.Client('1', session=keystone_session)
>>> sc.resource_types.list()
[...]

Testing

There are multiple test targets that can be run to validate the code.

  • tox -e pep8 - style guidelines enforcement
  • tox -e py36 - traditional unit testing with python 3.6
  • tox -e py37 - traditional unit testing with python 3.7