586d9afdab1ddb25f9d07da8c7f14ba46b88b29a
When a Resource has an alternate_id but not a primary id, its usage is a bit inconsistent. While we make things work internally, such as when you do a Resource.get call where we find the alternate_id, you still can't just call foo.id and get a valid ID back. The Keypair resource in compute is one of these examples, and its functional tests are currently failing because they depend on passing in "sot.id". While they could be engineered around that, it's certainly a valid usecase to support, and this change enables it. It does so by implementing __getattribute__ on the Resource class and then special-casing a request for the "id" name. First we try to get the primary "id" directly, and if nothing happens there then we try to get an alternate_id. Additionally, this changes the special case in the Resource.create method that was handling any create call with an existing ID as requiring that it go through the PUT branch when id exists. Relying on the id value itself being set for determining that branching is problematic in that these alternate_id resources would then trigger that path, sending creates which must happen by POST into the PUT branch just because their alternate_id becomes additionally known as the canonical id. Instead, we now have put_create as the special case, which is a fairly rare case as it stands. At least object_store will need to have its resources set with that flag once it is converted over, though there may be others as well. Change-Id: Ia1fd1782f4ad8fa856c16d75bba4d8931307a6e7
OpenStack Python SDK
The python-openstacksdk is a collection of libraries for
building applications to work with OpenStack clouds. The project aims to
provide a consistent and complete set of interactions with OpenStack's
many services, along with complete documentation, examples, and
tools.
This SDK is under active development, and in the interests of providing a high-quality interface, the APIs provided in this release may differ from those provided in future release.
Usage
The following example simply connects to an OpenStack cloud and lists the containers in the Object Store service.:
from openstack import connection
conn = connection.Connection(auth_url="http://openstack:5000/v3",
project_name="big_project",
username="SDK_user",
password="Super5ecretPassw0rd")
for container in conn.object_store.containers():
print(container.name)
Documentation
Documentation is available at http://developer.openstack.org/sdks/python/openstacksdk/
License
Apache 2.0
Description