UserPreference

UserPreference is the class that is used to define the various preferences for different services. The preferences that are currently supported are service name, region, version and visibility. The UserPreference and the Connection classes are the most important user facing classes.

Examples

The UserPreference class is constructed with no arguments.

Set Methods

The user preferences are set based on the service type. Service type would normally be something like ‘compute’, ‘identity’, ‘object-store’, etc.:

from openstack import user_preference
pref = user_preference.UserPreference()
pref.set_name('compute', 'matrix')
pref.set_region(pref.ALL, 'zion')
pref.set_version('identity', 'v3')
pref.set_visibility('object-store', 'internal')
for service in pref.get_services():
    print str(pref.get_preference(service.service_type))

The resulting preference print out would look something like:

service_type=compute,region=zion,service_name=matrix
service_type=network,region=zion
service_type=database,region=zion
service_type=image,region=zion
service_type=metering,region=zion
service_type=orchestration,region=zion
service_type=object-store,visibility=internal,region=zion
service_type=identity,region=zion,version=v3

UserPreference Object

class openstack.user_preference.UserPreference

User preference for each service.

Create a new UserPreference object with no preferences defined, but knowledge of the services. Services are identified by their service type, e.g.: ‘identity’, ‘compute’, etc.

ALL = '*'

Wildcard service identifier representing all services.

get_preference(service)

Get a service preference.

Parameters:service (str) – Desired service type.
get_services()

Get a list of all the known services.

set_name(service, name)

Set the desired name for the specified service.

Parameters:
  • service (str) – Service type.
  • name (str) – Desired service name.
set_region(service, region)

Set the desired region for the specified service.

Parameters:
  • service (str) – Service type.
  • region (str) – Desired service region.
set_version(service, version)

Set the desired version for the specified service.

Parameters:
  • service (str) – Service type.
  • version (str) – Desired service version.
set_visibility(service, visibility)

Set the desired visibility for the specified service.

Parameters:
  • service (str) – Service type.
  • visibility (str) – Desired service visibility.

Table Of Contents

Previous topic

Connection

Next topic

Object Store API

This Page