Go to file
Steve Martinelli 63c1eaaacc no longer use oslo-incubator code
As part of the first community-wide goal [1], teams were asked
to remove the openstack/common package of their projects
if one existed. This was a byproduct of the old oslo-incubator
form of syncing common functionality.

- Most of the apiclient package was not actually used in code,
  only the exceptions and base were. So remove most of it.
- Copy the exceptions and base from apiclient to the common package
  in the top level location.
- Copy only the functions used from cliutils (env()) to the
  searchlightclient/common/utils.py module. Delete cliutils.
- Create an i18n module for translation, this creates a new
  requirement - oslo.i18n.
- General cleanup to other openstack/common references

[1] http://governance.openstack.org/goals/ocata/remove-incubated-oslo-code.html

Change-Id: I08286c8c3ebfb1f76430b86a224ce101da5594f9
2016-11-11 11:53:26 -05:00
2016-10-03 11:05:08 -05:00
2015-11-28 16:40:16 +08:00
2015-11-28 16:40:16 +08:00
2015-11-19 10:13:03 +00:00
2015-11-28 16:40:16 +08:00
2015-11-28 16:40:16 +08:00
2015-11-28 16:40:16 +08:00
2015-11-28 16:40:16 +08:00
2015-12-18 18:29:25 +08:00
2015-11-28 16:40:16 +08:00
2016-11-11 11:53:26 -05:00

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 Launchpad, where bugs can be filed. The code is hosted on Github. Patches must be submitted using Gerrit, not Github pull requests.

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

Contents:

Install the client from PyPI

The 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://github.com/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 py27 - traditional unit testing
Description
RETIRED, OpenStack Search (Searchlight) Client
Readme 1.5 MiB