Skip to content

Commit 535f2f4

Browse files
committed
Merge shade and os-client-config into the tree
This sucks in the git history for both projects, then moves their files in place. It should not introduce any behavior changes to any of the existing openstacksdk code, nor to openstack.config and openstack.cloud - other than the name change. TODO(shade) comments have been left indicating places where further integration work should be done. It should not be assumed that these are the final places for either to live. This is just about getting them in-tree so we can work with them. The enforcer code for reasons surpassing understanding does not work with python setup.py build_sphinx but it does work with sphinx-build (what?) For now turn it off. We can turn it back on once the build sphinx job is migrated to the new PTI. Change-Id: I9523e4e281285360c61e9e0456a8e07b7ac1243c
2 parents bd60aa4 + a4ee1a3 commit 535f2f4

File tree

399 files changed

+53434
-157
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

399 files changed

+53434
-157
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ cover/*
2929
.tox
3030
nosetests.xml
3131
.testrepository
32+
.stestr
3233

3334
# Translations
3435
*.mo

.mailmap

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# Format is:
22
# <preferred e-mail> <other e-mail 1>
3-
# <preferred e-mail> <other e-mail 2>
3+
# <preferred e-mail> <other e-mail 2>
4+
5+
6+

.stestr.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[DEFAULT]
2+
test_path=./openstack/tests/unit
3+
top_dir=./

.testr.conf

Lines changed: 0 additions & 8 deletions
This file was deleted.

CONTRIBUTING.rst

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,45 @@
1-
If you would like to contribute to the development of OpenStack,
2-
you must follow the steps in this page:
1+
.. _contributing:
32

4-
https://docs.openstack.org/infra/manual/developers.html
3+
===================================
4+
Contributing to python-openstacksdk
5+
===================================
56

6-
Once those steps have been completed, changes to OpenStack
7-
should be submitted for review via the Gerrit tool, following
8-
the workflow documented at:
7+
If you're interested in contributing to the python-openstacksdk project,
8+
the following will help get you started.
99

10-
https://docs.openstack.org/infra/manual/developers.html#development-workflow
10+
Contributor License Agreement
11+
-----------------------------
1112

13+
.. index::
14+
single: license; agreement
15+
16+
In order to contribute to the python-openstacksdk project, you need to have
17+
signed OpenStack's contributor's agreement.
18+
19+
Please read `DeveloperWorkflow`_ before sending your first patch for review.
1220
Pull requests submitted through GitHub will be ignored.
1321

14-
Bugs should be filed on Launchpad, not GitHub:
22+
.. seealso::
23+
24+
* http://wiki.openstack.org/HowToContribute
25+
* http://wiki.openstack.org/CLA
26+
27+
.. _DeveloperWorkflow: http://docs.openstack.org/infra/manual/developers.html#development-workflow
28+
29+
Project Hosting Details
30+
-------------------------
31+
32+
Project Documentation
33+
http://docs.openstack.org/sdks/python/openstacksdk/
34+
35+
Bug tracker
36+
https://bugs.launchpad.net/python-openstacksdk
37+
38+
Mailing list (prefix subjects with ``[sdk]`` for faster responses)
39+
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
40+
41+
Code Hosting
42+
https://git.openstack.org/cgit/openstack/python-openstacksdk
1543

16-
https://bugs.launchpad.net/python-openstacksdk
44+
Code Review
45+
https://review.openstack.org/#/q/status:open+project:openstack/python-openstacksdk,n,z

HACKING.rst

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,49 @@
1-
python-openstacksdk Style Commandments
2-
======================================
1+
openstacksdk Style Commandments
2+
===============================
33

4-
Read the OpenStack Style Commandments https://docs.openstack.org/hacking/latest/
4+
Read the OpenStack Style Commandments
5+
http://docs.openstack.org/developer/hacking/
6+
7+
Indentation
8+
-----------
9+
10+
PEP-8 allows for 'visual' indentation. Do not use it. Visual indentation looks
11+
like this:
12+
13+
.. code-block:: python
14+
15+
return_value = self.some_method(arg1, arg1,
16+
arg3, arg4)
17+
18+
Visual indentation makes refactoring the code base unneccesarily hard.
19+
20+
Instead of visual indentation, use this:
21+
22+
.. code-block:: python
23+
24+
return_value = self.some_method(
25+
arg1, arg1, arg3, arg4)
26+
27+
That way, if some_method ever needs to be renamed, the only line that needs
28+
to be touched is the line with some_method. Additionaly, if you need to
29+
line break at the top of a block, please indent the continuation line
30+
an additional 4 spaces, like this:
31+
32+
.. code-block:: python
33+
34+
for val in self.some_method(
35+
arg1, arg1, arg3, arg4):
36+
self.do_something_awesome()
37+
38+
Neither of these are 'mandated' by PEP-8. However, they are prevailing styles
39+
within this code base.
40+
41+
Unit Tests
42+
----------
43+
44+
Unit tests should be virtually instant. If a unit test takes more than 1 second
45+
to run, it is a bad unit test. Honestly, 1 second is too slow.
46+
47+
All unit test classes should subclass `openstack.tests.unit.base.BaseTestCase`. The
48+
base TestCase class takes care of properly creating `OpenStackCloud` objects
49+
in a way that protects against local environment.

README.rst

Lines changed: 110 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,119 @@
1-
OpenStack Python SDK
2-
====================
1+
openstacksdk
2+
============
33

4-
The ``python-openstacksdk`` is a collection of libraries for building
5-
applications to work with OpenStack clouds. The project aims to provide
6-
a consistent and complete set of interactions with OpenStack's many
7-
services, along with complete documentation, examples, and tools.
4+
openstacksdk is a client library for for building applications to work
5+
with OpenStack clouds. The project aims to provide a consistent and
6+
complete set of interactions with OpenStack's many services, along with
7+
complete documentation, examples, and tools.
88

9-
This SDK is under active development, and in the interests of providing
10-
a high-quality interface, the APIs provided in this release may differ
11-
from those provided in future release.
9+
It also contains a simple interface layer. Clouds can do many things, but
10+
there are probably only about 10 of them that most people care about with any
11+
regularity. If you want to do complicated things, the per-service oriented
12+
portions of the SDK are for you. However, if what you want is to be able to
13+
write an application that talks to clouds no matter what crazy choices the
14+
deployer has made in an attempt to be more hipster than their self-entitled
15+
narcissist peers, then the ``openstack.cloud`` layer is for you.
1216

13-
Usage
14-
-----
17+
A Brief History
18+
---------------
1519

16-
The following example simply connects to an OpenStack cloud and lists
17-
the containers in the Object Store service.::
20+
openstacksdk started its life as three different libraries: shade,
21+
os-client-config and python-openstacksdk.
1822

19-
from openstack import connection
20-
conn = connection.Connection(auth_url="http://openstack:5000/v3",
21-
project_name="big_project",
22-
username="SDK_user",
23-
password="Super5ecretPassw0rd")
24-
for container in conn.object_store.containers():
25-
print(container.name)
23+
``shade`` started its life as some code inside of OpenStack Infra's nodepool
24+
project, and as some code inside of Ansible. Ansible had a bunch of different
25+
OpenStack related modules, and there was a ton of duplicated code. Eventually,
26+
between refactoring that duplication into an internal library, and adding logic
27+
and features that the OpenStack Infra team had developed to run client
28+
applications at scale, it turned out that we'd written nine-tenths of what we'd
29+
need to have a standalone library.
2630

27-
Documentation
28-
-------------
31+
``os-client-config`` was a library for collecting client configuration for
32+
using an OpenStack cloud in a consistent and comprehensive manner.
33+
In parallel, the python-openstacksdk team was working on a library to expose
34+
the OpenStack APIs to developers in a consistent and predictable manner. After
35+
a while it became clear that there was value in both a high-level layer that
36+
contains business logic, a lower-level SDK that exposes services and their
37+
resources as Python objects, and also to be able to make direct REST calls
38+
when needed with a properly configured Session or Adapter from python-requests.
39+
This led to the merger of the three projects.
2940

30-
Documentation is available at
31-
https://developer.openstack.org/sdks/python/openstacksdk/
41+
The contents of the shade library have been moved into ``openstack.cloud``
42+
and os-client-config has been moved in to ``openstack.config``. The next
43+
release of shade will be a thin compatibility layer that subclasses the objects
44+
from ``openstack.cloud`` and provides different argument defaults where needed
45+
for compat. Similarly the next release of os-client-config will be a compat
46+
layer shim around ``openstack.config``.
3247

33-
License
34-
-------
48+
openstack.config
49+
================
3550

36-
Apache 2.0
51+
``openstack.config`` will find cloud configuration for as few as 1 clouds and
52+
as many as you want to put in a config file. It will read environment variables
53+
and config files, and it also contains some vendor specific default values so
54+
that you don't have to know extra info to use OpenStack
55+
56+
* If you have a config file, you will get the clouds listed in it
57+
* If you have environment variables, you will get a cloud named `envvars`
58+
* If you have neither, you will get a cloud named `defaults` with base defaults
59+
60+
Sometimes an example is nice.
61+
62+
Create a ``clouds.yaml`` file:
63+
64+
.. code-block:: yaml
65+
66+
clouds:
67+
mordred:
68+
region_name: Dallas
69+
auth:
70+
username: 'mordred'
71+
password: XXXXXXX
72+
project_name: 'shade'
73+
auth_url: 'https://identity.example.com'
74+
75+
Please note: ``openstack.config`` will look for a file called ``clouds.yaml``
76+
in the following locations:
77+
78+
* Current Directory
79+
* ``~/.config/openstack``
80+
* ``/etc/openstack``
81+
82+
More information at https://developer.openstack.org/sdks/python/openstacksdk/users/config
83+
84+
openstack.cloud
85+
===============
86+
87+
Create a server using objects configured with the ``clouds.yaml`` file:
88+
89+
.. code-block:: python
90+
91+
import openstack.cloud
92+
93+
# Initialize and turn on debug logging
94+
openstack.cloud.simple_logging(debug=True)
95+
96+
# Initialize cloud
97+
# Cloud configs are read with openstack.config
98+
cloud = openstack.openstack_cloud(cloud='mordred')
99+
100+
# Upload an image to the cloud
101+
image = cloud.create_image(
102+
'ubuntu-trusty', filename='ubuntu-trusty.qcow2', wait=True)
103+
104+
# Find a flavor with at least 512M of RAM
105+
flavor = cloud.get_flavor_by_ram(512)
106+
107+
# Boot a server, wait for it to boot, and then do whatever is needed
108+
# to get a public ip for it.
109+
cloud.create_server(
110+
'my-server', image=image, flavor=flavor, wait=True, auto_ip=True)
111+
112+
Links
113+
=====
114+
115+
* `Issue Tracker <https://storyboard.openstack.org/#!/project/760>`_
116+
* `Code Review <https://review.openstack.org/#/q/status:open+project:openstack/python-openstacksdk,n,z>`_
117+
* `Documentation <https://developer.openstack.org/sdks/python/openstacksdk/>`_
118+
* `PyPI <https://pypi.python.org/pypi/python-openstacksdk/>`_
119+
* `Mailing list <http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev>`_

bindep.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This is a cross-platform list tracking distribution packages needed by tests;
2+
# see http://docs.openstack.org/infra/bindep/ for additional information.
3+
4+
build-essential [platform:dpkg]
5+
python-dev [platform:dpkg]
6+
python-devel [platform:rpm]
7+
libffi-dev [platform:dpkg]
8+
libffi-devel [platform:rpm]

devstack/plugin.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Install and configure **openstacksdk** library in devstack
2+
#
3+
# To enable openstacksdk in devstack add an entry to local.conf that looks like
4+
#
5+
# [[local|localrc]]
6+
# enable_plugin openstacksdk git://git.openstack.org/openstack/python-openstacksdk
7+
8+
function preinstall_openstacksdk {
9+
:
10+
}
11+
12+
function install_openstacksdk {
13+
if use_library_from_git "python-openstacksdk"; then
14+
# don't clone, it'll be done by the plugin install
15+
setup_dev_lib "python-openstacksdk"
16+
else
17+
pip_install "python-openstacksdk"
18+
fi
19+
}
20+
21+
function configure_openstacksdk {
22+
:
23+
}
24+
25+
function initialize_openstacksdk {
26+
:
27+
}
28+
29+
function unstack_openstacksdk {
30+
:
31+
}
32+
33+
function clean_openstacksdk {
34+
:
35+
}
36+
37+
# This is the main for plugin.sh
38+
if [[ "$1" == "stack" && "$2" == "pre-install" ]]; then
39+
preinstall_openstacksdk
40+
elif [[ "$1" == "stack" && "$2" == "install" ]]; then
41+
install_openstacksdk
42+
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
43+
configure_openstacksdk
44+
elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
45+
initialize_openstacksdk
46+
fi
47+
48+
if [[ "$1" == "unstack" ]]; then
49+
unstack_openstacksdk
50+
fi
51+
52+
if [[ "$1" == "clean" ]]; then
53+
clean_openstacksdk
54+
fi

0 commit comments

Comments
 (0)