Skip to content

Commit a2a0adb

Browse files
committed
slightly rework docs
- add DeH user guides - fix wrong menu structure - other minor fixes
1 parent 60466c0 commit a2a0adb

16 files changed

Lines changed: 388 additions & 126 deletions

File tree

doc/source/cli/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
OpenStackClient CLI Usage
2+
=========================
3+
14
.. toctree::
5+
:maxdepth: 2
26

37
anti_ddos.rst
48
auto_scaling.rst

doc/source/contributor/index.rst

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
Contributing to the OpenStack SDK
2-
=================================
1+
Contributing to the OTC Extensions
2+
==================================
33

44
This section of documentation pertains to those who wish to contribute to the
5-
development of this SDK. If you're looking for documentation on how to use
5+
development of this project. If you're looking for documentation on how to use
66
the SDK to build applications, please see the `user <../user>`_ section.
77

8-
About the Project
9-
-----------------
10-
11-
The OpenStack SDK is a OpenStack project aimed at providing a complete
12-
software development kit for the programs which make up the OpenStack
13-
community. It is a set of Python-based libraries, documentation, examples,
14-
and tools released under the Apache 2 license.
158

169
Contribution Mechanics
1710
----------------------
@@ -24,22 +17,15 @@ Contribution Mechanics
2417
Contacting the Developers
2518
-------------------------
2619

27-
IRC
28-
***
20+
GitHub
21+
******
2922

30-
The developers of this project are available in the
31-
`#openstack-sdks <http://webchat.freenode.net?channels=%23openstack-sdks>`_
32-
channel on Freenode. This channel includes conversation on SDKs and tools
33-
within the general OpenStack community, including OpenStackClient as well
34-
as occasional talk about SDKs created for languages outside of Python.
23+
Currently no official communication other than GitHub is available
3524

3625
Email
3726
*****
3827

39-
The `openstack-dev <mailto:openstack-dev@openstack.org?subject=[sdk]%20Question%20about%20openstacksdk>`_
40-
mailing list fields questions of all types on OpenStack. Using the
41-
``[sdk]`` filter to begin your email subject will ensure
42-
that the message gets to SDK developers.
28+
???
4329

4430
Coding Standards
4531
----------------

doc/source/user/connection.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ Connection
66
-----------
77
.. autofunction:: openstack.connection.from_config
88

9+
Registering OTC extensions
10+
==========================
11+
12+
.. autofunction:: otcextensions.sdk.register_otc_extensions
13+
914
Connection Object
1015
-----------------
1116

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Connect OTC
2+
===========
3+
4+
In order to work with an OpenStack cloud you first need to create a
5+
:class:`~openstack.connection.Connection` to it using your credentials. A
6+
:class:`~openstack.connection.Connection` can be
7+
created in 3 ways, using the class itself, :ref:`config-clouds-yaml`, or
8+
:ref:`config-environment-variables`. It is recommended to always use
9+
:ref:`config-clouds-yaml` as the same config can be used across tools and
10+
languages.
11+
12+
Create Connection
13+
-----------------
14+
15+
To create a :class:`~openstack.connection.Connection` instance, use the
16+
:func:`~openstack.connect` factory function.
17+
18+
As a next step inject the OTC extensions into the retrieved connection
19+
20+
.. code-block:: python
21+
22+
# An 'otc' is a cloud connection with name 'otc' configured in the clouds.yaml
23+
conn = openstack.connect(cloud='otc')
24+
25+
# Register OTC Extensions
26+
sdk.register_otc_extensions(conn)
27+
28+
Full example at `connect_otc.py <examples/connect_otc.py>`_
29+
30+
.. note:: To enable logging, see the :doc:`logging` user guide.
31+
32+
Next
33+
----
34+
Now that you can create a connection, continue with the :ref:`user_guides`
35+
to work with an OpenStack service.
36+
37+
.. TODO(shade) Update the text here and consolidate with the old
38+
os-client-config docs so that we have a single and consistent explanation
39+
of the envvars cloud, etc.

doc/source/user/guides/deh.rst

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
Using OTC DeH
2+
=============
3+
4+
Before working with the Dedicated Host service, you'll need to create a
5+
connection to your OTC cloud account by following the :doc:`connect_otc` user
6+
guide. This will provide you with the ``conn`` variable used in the examples
7+
below.
8+
9+
.. contents:: Table of Contents
10+
:local:
11+
12+
The primary resource of the DeH service is the **host**.
13+
14+
CRUD operations
15+
~~~~~~~~~~~~~~~
16+
17+
List Hosts
18+
----------
19+
20+
A **host** is a dedicated host, where virtual machines would be running.
21+
22+
.. literalinclude:: ../examples/deh/list.py
23+
:pyobject: list_hosts
24+
25+
Full example: `deh host list`_
26+
27+
List Hosts Types
28+
----------------
29+
30+
In order to allocate a host, it's type need to be chosen first. Types might
31+
differ per availability zone, therefore it is required to specify in which
32+
AZ to look for types
33+
34+
.. literalinclude:: ../examples/deh/list_types.py
35+
:pyobject: list_host_types
36+
37+
Full example: `deh host list type`_
38+
39+
List Host servers
40+
-----------------
41+
42+
Each DeH Host is intended to run virtual instances. Only querying list of
43+
servers is supported
44+
45+
.. literalinclude:: ../examples/deh/list_servers.py
46+
:pyobject: list_host_servers
47+
48+
Full example: `deh host list server`_
49+
50+
Provisioning operations
51+
~~~~~~~~~~~~~~~~~~~~~~~
52+
53+
Provisioning actions are the main way to manipulate the hosts.
54+
55+
Allocating a DeH Host Instance
56+
------------------------------
57+
58+
A host can be allocated with a following snip.
59+
60+
.. literalinclude:: ../examples/deh/create.py
61+
:pyobject: create_host
62+
63+
Allocating a DeH Host supports setting `quantity` parameter to allocate multiple
64+
hosts in a one call. Due to that the IDs of allocated hosts are being returned
65+
as part of the "virtual" resource in a `dedicated_host_ids` attribute
66+
67+
Full example: `deh host create`_
68+
69+
70+
.. _deh host list: http://github.com/opentelekomcloud/python-otcextensions/tree/master/examples/deh/list.py
71+
.. _deh host list type: http://github.com/opentelekomcloud/python-otcextensions/tree/master/examples/deh/list_types.py
72+
.. _deh host create: http://github.com/opentelekomcloud/python-otcextensions/tree/master/examples/deh/create.py
73+
.. _deh host list server: http://github.com/opentelekomcloud/python-otcextensions/tree/master/examples/deh/list_servers.py

doc/source/user/guides/logging.rst

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
=======
2+
Logging
3+
=======
4+
5+
.. note:: TODO(shade) This document is written from a shade POV. It needs to
6+
be combined with the existing logging guide, but also the logging
7+
systems need to be rationalized.
8+
9+
`openstacksdk` uses `Python Logging`_. As `openstacksdk` is a library, it does
10+
not configure logging handlers automatically, expecting instead for that to be
11+
the purview of the consuming application.
12+
13+
Simple Usage
14+
------------
15+
16+
For consumers who just want to get a basic logging setup without thinking
17+
about it too deeply, there is a helper method. If used, it should be called
18+
before any other openstacksdk functionality.
19+
20+
.. autofunction:: openstack.enable_logging
21+
22+
.. code-block:: python
23+
24+
import openstack
25+
openstack.enable_logging()
26+
27+
The ``stream`` parameter controls the stream where log message are written to.
28+
It defaults to `sys.stdout` which will result in log messages being written
29+
to STDOUT. It can be set to another output stream, or to ``None`` to disable
30+
logging to the console.
31+
32+
The ``path`` parameter sets up logging to log to a file. By default, if
33+
``path`` is given and ``stream`` is not, logging will only go to ``path``.
34+
35+
You can combine the ``path`` and ``stream`` parameters to log to both places
36+
simultaneously.
37+
38+
To log messages to a file called ``openstack.log`` and the console on
39+
``stdout``:
40+
41+
.. code-block:: python
42+
43+
import sys
44+
import openstack
45+
46+
openstack.enable_logging(
47+
debug=True, path='openstack.log', stream=sys.stdout)
48+
49+
50+
`openstack.enable_logging` also sets up a few other loggers and
51+
squelches some warnings or log messages that are otherwise uninteresting or
52+
unactionable by an openstacksdk user.
53+
54+
Advanced Usage
55+
--------------
56+
57+
`openstacksdk` logs to a set of different named loggers.
58+
59+
Most of the logging is set up to log to the root ``openstack`` logger.
60+
There are additional sub-loggers that are used at times, primarily so that a
61+
user can decide to turn on or off a specific type of logging. They are listed
62+
below.
63+
64+
openstack.config
65+
Issues pertaining to configuration are logged to the ``openstack.config``
66+
logger.
67+
68+
openstack.task_manager
69+
`openstacksdk` uses a Task Manager to perform remote calls. The
70+
``openstack.task_manager`` logger emits messages at the start and end
71+
of each Task announcing what it is going to run and then what it ran and
72+
how long it took. Logging ``openstack.task_manager`` is a good way to
73+
get a trace of external actions `openstacksdk` is taking without full
74+
`HTTP Tracing`_.
75+
76+
openstack.iterate_timeout
77+
When `openstacksdk` needs to poll a resource, it does so in a loop that waits
78+
between iterations and ultimately times out. The
79+
``openstack.iterate_timeout`` logger emits messages for each iteration
80+
indicating it is waiting and for how long. These can be useful to see for
81+
long running tasks so that one can know things are not stuck, but can also
82+
be noisy.
83+
84+
openstack.fnmatch
85+
`openstacksdk` will try to use `fnmatch`_ on given `name_or_id` arguments.
86+
It's a best effort attempt, so pattern misses are logged to
87+
``openstack.fnmatch``. A user may not be intending to use an fnmatch
88+
pattern - such as if they are trying to find an image named
89+
``Fedora 24 [official]``, so these messages are logged separately.
90+
91+
.. _fnmatch: https://pymotw.com/2/fnmatch/
92+
93+
HTTP Tracing
94+
------------
95+
96+
HTTP Interactions are handled by `keystoneauth`_. If you want to enable HTTP
97+
tracing while using openstacksdk and are not using `openstack.enable_logging`,
98+
set the log level of the ``keystoneauth`` logger to ``DEBUG``.
99+
100+
For more information see https://docs.openstack.org/keystoneauth/latest/using-sessions.html#logging
101+
102+
.. _keystoneauth: https://docs.openstack.org/keystoneauth/latest/
103+
104+
Python Logging
105+
--------------
106+
107+
Python logging is a standard feature of Python and is documented fully in the
108+
Python Documentation, which varies by version of Python.
109+
110+
For more information on Python Logging for Python v2, see
111+
https://docs.python.org/2/library/logging.html.
112+
113+
For more information on Python Logging for Python v3, see
114+
https://docs.python.org/3/library/logging.html.

doc/source/user/index.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,14 @@ approach, this is where you'll want to begin.
2626
.. toctree::
2727
:maxdepth: 1
2828

29+
Plain-simple connect to OTC <guides/connect_otc>
2930
Configuration <config/index>
30-
Connect to an OpenStack Cloud <https://docs.openstack.org/python-openstacksdk/latest/user/guides/connect>
3131
Connect to an OpenStack Cloud Using a Config File <https://docs.openstack.org/python-openstacksdk/latest/user/guides/connect_from_config>
32-
Microversions <microversions>
3332
Using Cloud Abstration Layer <https://docs.openstack.org/python-openstacksdk/latest/user/usage>
34-
Logging <https://docs.openstack.org/python-openstacksdk/latest/user/guides/logging>
33+
Logging <guides/logging>
3534
Microversions <https://docs.openstack.org/python-openstacksdk/latest/user/microversions>
3635
Block Storage <https://docs.openstack.org/python-openstacksdk/latest/user/guides/block_storage>
3736
Compute <https://docs.openstack.org/python-openstacksdk/latest/user/guides/compute>
38-
Database <https://docs.openstack.org/python-openstacksdk/latest/user/guides/database>
3937
Identity <https://docs.openstack.org/python-openstacksdk/latest/user/guides/identity>
4038
Image <https://docs.openstack.org/python-openstacksdk/latest/user/guides/image>
4139
Key Manager <https://docs.openstack.org/python-openstacksdk/latest/user/guides/key_manager>
@@ -47,6 +45,7 @@ approach, this is where you'll want to begin.
4745
OBS <guides/obs>
4846
AutoScaling <guides/auto_scaling>
4947
Volume Backup <guides/volume_backup>
48+
Dedicated Host <guides/deh>
5049

5150
API Documentation
5251
-----------------

0 commit comments

Comments
 (0)