Add deprecation warnings to profile

Profile is being replaced by CloudRegion. While compatibility remains
for the next release, it'll be gone by 1.0. Emit deprecation warnings
so that people can work on migrating.

Change-Id: Id58d563f7eaff48fc34b7bfa37851f3a1db8f25a
This commit is contained in:
Monty Taylor
2018-01-17 10:37:57 -06:00
parent d42e200b87
commit a292e47319
2 changed files with 25 additions and 38 deletions

View File

@@ -11,44 +11,8 @@
# under the License. # under the License.
""" """
:class:`~openstack.profile.Profile` is the class that is used to :class:`~openstack.profile.Profile` is deprecated. Code should use
define the various preferences for different services. The preferences that :class:`~openstack.config.cloud_region.CloudRegion` instead.
are currently supported are service name, region, version and interface.
The :class:`~openstack.profile.Profile` and the
:class:`~openstack.connection.Connection` classes are the most important
user facing classes.
Examples
--------
The :class:`~openstack.profile.Profile` class is constructed
with no arguments.
Set Methods
~~~~~~~~~~~
A user's preferences are set based on the service type. Service type would
normally be something like 'compute', 'identity', 'object-store', etc.::
from openstack import profile
prof = profile.Profile()
prof.set_name('compute', 'matrix')
prof.set_region(prof.ALL, 'zion')
prof.set_version('identity', 'v3')
prof.set_interface('object-store', 'internal')
for service in prof.get_services():
print(prof.get_filter(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,interface=internal,region=zion
service_type=identity,region=zion,version=v3
""" """
import copy import copy
@@ -70,6 +34,7 @@ from openstack.meter import meter_service
from openstack.network import network_service from openstack.network import network_service
from openstack.object_store import object_store_service from openstack.object_store import object_store_service
from openstack.orchestration import orchestration_service from openstack.orchestration import orchestration_service
from openstack import utils
from openstack.workflow import workflow_service from openstack.workflow import workflow_service
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
@@ -80,6 +45,8 @@ class Profile(object):
ALL = "*" ALL = "*"
"""Wildcard service identifier representing all services.""" """Wildcard service identifier representing all services."""
@utils.deprecated(deprecated_in="0.10.0", removed_in="1.0",
details="Use openstack.config instead")
def __init__(self, plugins=None): def __init__(self, plugins=None):
"""User preference for each service. """User preference for each service.
@@ -121,6 +88,8 @@ class Profile(object):
serv.interface = None serv.interface = None
self._services[serv.service_type] = serv self._services[serv.service_type] = serv
@utils.deprecated(deprecated_in="0.10.0", removed_in="1.0",
details="Use openstack.config instead")
def get_filter(self, service): def get_filter(self, service):
"""Get a service preference. """Get a service preference.
@@ -147,6 +116,8 @@ class Profile(object):
for service in self._get_services(service): for service in self._get_services(service):
setattr(self._get_filter(service), attr, value) setattr(self._get_filter(service), attr, value)
@utils.deprecated(deprecated_in="0.10.0", removed_in="1.0",
details="Use openstack.config instead")
def get_services(self): def get_services(self):
"""Get a list of all the known services.""" """Get a list of all the known services."""
services = [] services = []
@@ -154,6 +125,8 @@ class Profile(object):
services.append(service) services.append(service)
return services return services
@utils.deprecated(deprecated_in="0.10.0", removed_in="1.0",
details="Use openstack.config instead")
def set_name(self, service, name): def set_name(self, service, name):
"""Set the desired name for the specified service. """Set the desired name for the specified service.
@@ -162,6 +135,8 @@ class Profile(object):
""" """
self._setter(service, "service_name", name) self._setter(service, "service_name", name)
@utils.deprecated(deprecated_in="0.10.0", removed_in="1.0",
details="Use openstack.config instead")
def set_region(self, service, region): def set_region(self, service, region):
"""Set the desired region for the specified service. """Set the desired region for the specified service.
@@ -170,6 +145,8 @@ class Profile(object):
""" """
self._setter(service, "region", region) self._setter(service, "region", region)
@utils.deprecated(deprecated_in="0.10.0", removed_in="1.0",
details="Use openstack.config instead")
def set_version(self, service, version): def set_version(self, service, version):
"""Set the desired version for the specified service. """Set the desired version for the specified service.
@@ -178,6 +155,8 @@ class Profile(object):
""" """
self._get_filter(service).version = version self._get_filter(service).version = version
@utils.deprecated(deprecated_in="0.10.0", removed_in="1.0",
details="Use openstack.config instead")
def set_api_version(self, service, api_version): def set_api_version(self, service, api_version):
"""Set the desired API micro-version for the specified service. """Set the desired API micro-version for the specified service.
@@ -186,6 +165,8 @@ class Profile(object):
""" """
self._setter(service, "api_version", api_version) self._setter(service, "api_version", api_version)
@utils.deprecated(deprecated_in="0.10.0", removed_in="1.0",
details="Use openstack.config instead")
def set_interface(self, service, interface): def set_interface(self, service, interface):
"""Set the desired interface for the specified service. """Set the desired interface for the specified service.

View File

@@ -0,0 +1,6 @@
---
deprecations:
- |
``openstack.profile.Profile`` has been deprecated and will be removed
in the ``1.0`` release. Users should use the functions in
``openstack.config`` instead.