Examples for migration from keystoneclient

Changes to be done based on migration performed in Nova

Implements bp documentation

Change-Id: I7f6c1592673e7279e6c9a1729b502ff1cdbe2f0d
This commit is contained in:
Alexander Makarov 2016-03-25 19:59:22 +03:00
parent 80b58cc2f2
commit 3b8a0c0c26

View File

@ -53,3 +53,51 @@ and just the property accessors are available.
The creation function has also changed. The
:py:meth:`keystoneclient.access.AccessInfo.factory` method has been removed
and replaced with the :py:func:`keystoneauth1.access.create`.
Step-by-step migration example
------------------------------
Add ``keystoneauth1`` to requirements.txt
In the code do the following change::
-from keystoneclient import auth
+from keystoneauth1 import plugin
consequently::
-auth.BaseAuthPlugin
+plugin.BaseAuthPlugin
To import service catalog::
-from keystoneclient import service_catalog
+from keystoneauth1.access import service_catalog
To get url using service catalog *endpoint_type* parameter was changed to
*interface*::
-service_catalog.ServiceCatalogV2(sc).service_catalog.url_for(..., endpoint_type=interface)
+service_catalog.ServiceCatalogV2(sc).service_catalog.url_for(..., interface=interface)
Obtaining the session::
-from keystoneclient import session
+from keystoneauth1 import loading as ks_loading
+from keystoneauth1 import session
-_SESSION = session.Session.load_from_conf_options(
-auth_plugin = auth.load_from_conf_options(conf, NEUTRON_GROUP)
+_SESSION = ks_loading.load_session_from_conf_options(
+auth_plugin = ks_loading.load_auth_from_conf_options(conf, NEUTRON_GROUP)
Mocking session for test purposes::
-@mock.patch('keystoneclient.session.Session')
+@mock.patch('keystoneauth1.session.Session')
Token fixture imports haven't change much::
-from keystoneclient.fixture import V2Token
+from keystoneauth1.fixture import V2Token