Skip to content

Commit

Permalink
Version 1.8.0 - adds Context Objects
Browse files Browse the repository at this point in the history
  • Loading branch information
EdLeafe committed May 6, 2014
1 parent 0b02cbd commit defad06
Show file tree
Hide file tree
Showing 233 changed files with 9,906 additions and 1,818 deletions.
96 changes: 72 additions & 24 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
# Release Notes for pyrax

###2014.05.06 - Version 1.8.0
- Identity
- Added **Context Objects** as a way to encapsulate an authenticated
session.
- Context objects remove the limitation in pyrax of only working with a
single authenticated session at a time.
- Improves the ability to work with multiple providers at once, or across
multiple regions for the same provider.
- More information in the **context_objects.md** document in the docs/
folder.

- Cloud Files
- Fixed missing URL quoting for bulk deletes. GitHub #350
- Multiple improvements to sync_folder_to_container in GitHub #355:
- Added the ability to specify a prefix to be added to the object name
during checking and uploading during a sync
- Sped up sync_folder_to_container by having it pull down a list of
objects all at once to use to compare against instead of checking once
for each file.
- Added verbose logging to sync_folder_to_container (Originally requested
in GitHub #250)

- General
- Fixed issue where one bad section in the configuration file caused threw
an exception that terminated your app. GitHub #346
- Removed the need to specify a tenant_id when authenticating with a token.
GitHub #345

- Block Storage
- Added missing update methods to Cloud Block Storage.

- Documentation
- Updated the queues docs to include listing of queues. GitHub #353


###2014.04.07 - Version 1.7.3
- Identity
- Updated the identity module and tests to work with the new http library.
Expand Down Expand Up @@ -77,7 +112,8 @@
###2014.02.03 - Version 1.6.3
- Cloud Monitoring:
- Added back missing error info. GitHub #285
- Added support for Overviews and Changelogs from Cloud Monitoring. GitHub #267
- Added support for Overviews and Changelogs from Cloud Monitoring. GitHub
#267
- Autoscale:
- Corrected how networks are created when none are specified. GitHub #262
- Added load balancers to sample code for creating a scaling group.
Expand All @@ -87,12 +123,16 @@
- Cloud Files:
- Add `use_servicenet` setting for Cloud Files. GitHub #273
- Fixed bug in passing TTL to `delete_in_seconds()`. GitHub #281
- Added a fix for GETting 0-byte content with Dynamic Large Objects (multipart files). GitHub #258
- Include container name in `X-Object-Manifest` header when creating DLO. GitHub #261
- Use `X-Object-Manifest` instead of `X-Object-Meta-Manifest` when creating DLO. GitHub #260
- Added a fix for GETting 0-byte content with Dynamic Large Objects
(multipart files). GitHub #258
- Include container name in `X-Object-Manifest` header when creating DLO.
GitHub #261
- Use `X-Object-Manifest` instead of `X-Object-Meta-Manifest` when creating
DLO. GitHub #260
- Cloud Load Balancers:
- Added `httpsRedirect` param for Cloud Load Balancers. GitHub #277
- Adding an entry for the `id` attribute to the Node's `to_dict()` method. GitHub #276
- Adding an entry for the `id` attribute to the Node's `to_dict()` method.
GitHub #276
- Cloud DNS:
- Handle empty bodies in GET responses from the Cloud DNS API. GitHub #280
- Cloud Servers:
Expand Down Expand Up @@ -273,7 +313,8 @@
- Fixed a bug that prevented region from being properly set. Issue #86.

###2013.06.04 - Version 1.4.4
- Fixed a bug when using environment variables to set the identity_type. Issue #82.
- Fixed a bug when using environment variables to set the identity_type. Issue
#82.

###2013.06.03 - Version 1.4.3
- Added support for having objects automatically deleted from Cloud Files after
Expand All @@ -288,22 +329,23 @@

###2013.05.29 - Version 1.4.0
- Added support for **all** OpenStack clouds. Previous versions only supported
Rackspace authentication methods.
Rackspace authentication methods.
- Configuration files now support multiple cloud environments in the same file.
You can switch between environments by calling `pyrax.set_environment("env")`,
where `env` is the name of the desired environment.
You can switch between environments by calling
`pyrax.set_environment("env")`, where `env` is the name of the desired
environment.
- Configuration settings can now be stored in environment variables. These all
begin with `CLOUD_`; a full list can be found in the [main pyrax
documentation](https://github.com/rackspace/pyrax/tree/master/docs/pyrax_doc.md).
begin with `CLOUD_`; a full list can be found in the [main pyrax
documentation](https://github.com/rackspace/pyrax/tree/master/docs/pyrax_doc.md).
- Available regions are now available in the `pyrax.regions` attribute after
authentication.
authentication.
- Services that are available for the current cloud provider are now available
in the `pyrax.services` attribute.
in the `pyrax.services` attribute.
- Fixed an issue in Cloud Databases in which the `volume` attribute was
sometimes a dict and sometimes an instance of `CloudDatabaseVolume`. Now it
will always be an instance.
sometimes a dict and sometimes an instance of `CloudDatabaseVolume`. Now it
will always be an instance.
- Added a smoke test script to the integrated tests. It currently covers the
compute, networking, database, and object_store services.
compute, networking, database, and object_store services.
- Removed unnecessary hack for compute URIs.
- Cleaned up some naming and formatting inconsistencies.

Expand Down Expand Up @@ -412,7 +454,7 @@ container class.
'DRAINING' condition (GitHub #6). Modified the rax_identity to accept
UTC dates returned from the LON datacenter (GitHub #5). Fixed an
issue that prevented HTTP debugging from turning off in swiftclient.


###2013.01.15 - Version 1.2.4
- Added support for keychain storage of credentials for authentication.
Expand All @@ -422,7 +464,8 @@ issue that prevented HTTP debugging from turning off in swiftclient.
- Added the 'halfClosed' parameter to the create() method of load balancers.

###2013.01.03 - Version 1.2.2
- Fixed an issue that was causing calls to cloudservers to needlessly re-authenticate.
- Fixed an issue that was causing calls to cloudservers to needlessly
re-authenticate.

###2012.12.27 - Version 1.2.1
- Removed old class docs that were no longer needed in this release.
Expand All @@ -437,7 +480,7 @@ issue that prevented HTTP debugging from turning off in swiftclient.
- Added a requirement for python-novaclient>=2.10.0.

###2012.12.18 - Version 1.1.6b
- Removed the code that controlled when pyrax connected to services.
- Removed the code that controlled when pyrax connected to services.
- Changed the User-agent format to match the other SDKs.

###2012.12.17 - Version 1.1.5b
Expand All @@ -447,23 +490,28 @@ issue that prevented HTTP debugging from turning off in swiftclient.
###2012.12.13 - Version 1.1.4b
- Added the ability to connect to the internal URL for Cloud Files.
- Added limit and marker to the base client/manager classes.
- Added the cloudfiles Container and StorageObject classes to the pyrax namespace.
- Added the cloudfiles Container and StorageObject classes to the pyrax
namespace.

###2012.12.10 - Version 1.1.2b
- Added a test that was missing in the previous release.

###2012.12.07 - Version 1.1.1b
- Added the ability for developers to customize the User-agent string for their applications.
- Added the ability for developers to customize the User-agent string for their
applications.

###2012.11.26 - Version 1.1.1b
- Added Cloud Block Storage support.
- Added the refactored code for Cloud Load Balancers that removes the dependency on the python-cloudlb library.
- Added the refactored code for Cloud Load Balancers that removes the
dependency on the python-cloudlb library.

###2012.11.24 - Version 1.0.4b
- Maintenance fix release.

###2012.11.20
- Improved the handling of CDN calls so they don't fail as often, and are more resilient when they do.
- Improved the handling of CDN calls so they don't fail as often, and are more
resilient when they do.

###2012.11.06
- Release of the initial beta for pyrax. Supports Cloud Servers, Cloud Files, and Cloud Load Balancers.
- Release of the initial beta for pyrax. Supports Cloud Servers, Cloud Files,
and Cloud Load Balancers.
133 changes: 133 additions & 0 deletions docs/context_objects.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Context Objects

Context objects represent a single authenticated session. You can work with as many context objects as you like at the same time without worrying about logging in or out of each one to work with the other. Earlier versions of pyrax (before 1.8.0) only allowed you to work with one authenticated session at a time.

This ability is useful if you ever need to work with multiple projects (accounts) at the same time, or with multiple users within the same project.

## Creating a Context Object

To create a context object, you call:

ctx = pyrax.create_context({id_type})

where `id_type` is either "keystone" or "rackspace". If you've defined the identity type you wish to use in either your `~/.pyrax.cfg` file, or in environment variables, you can omit the id_type from the call:

ctx = pyrax.create_context()

If you have multiple **[environments](https://github.com/rackspace/pyrax/blob/master/docs/getting_started.md#configuration-environments)** defined, you may specify the environment to use when creating the context by specifying that name in the `env` parameter:

ctx = pyrax.create_context(env="{my_special_environment}")

If you don't specify an environment, the current environment is used. You may also populate the context object with login credential information, as well as the `verify_ssl` setting. The full call with all available parameters is:

ctx = pyrax.create_context(id_type=None, env=None, username=None,
password=None, tenant_id=None, tenant_name=None, api_key=None,
verify_ssl=None)

At this point you have an unauthenticated context. You must authenticate before you can do anything useful with a context object. To authenticate you need to provide your credentials if you haven't already when you created the object. You can either set them individually:

ctx.username = {your_user_name}
ctx.password = {your_password}

...or you can set them together:

ctx.set_credentials({your_user_name}, {your_password})

...or if you have them stored in a file (see the information on **[credential files](https://github.com/rackspace/pyrax/blob/master/docs/getting_started.md#authenticating)** for how to set one up), you can call:

ctx.set_credential_file({path/to/your/file})

After you have set your credentials, you call:

ctx.authenticate()

This submits your credentials, and assuming that they are valid, get back a Service Catalog that contains all of the services and regions that the authenticated user is authorized to use.

If you have your password stored in your system's keychain, you can set your credentials and authenticate with a single call:

ctx.keyring_auth({username})


## Working With Context Objects

Once you have an authenticated context object, you can work with the various services (e.g., object storage, compute, databases) for each region that your provider offers. Examples of regions for Rackspace are **"DFW"**, **"LON"**, **"SYD"**, while HP offers regions such as **"region-a.geo-1"** and **"region-b.geo-1"**.

Many OpenStack installations only have a single region. In those cases it might seem a little annoying to have to include that.

### Service Names

The various services are known by several types of names: descriptive names, project code names, and vendor product names. For example, the **compute** service is known within OpenStack as project **nova**, at Rackspace as the **Cloud Servers** product, and at HP as the **Cloud Compute** product. The descriptive name is the one that is used in these docs, but it is common for developers to use the other variations. The older versions of pyrax (before 1.8.0) primarily used the Rackspace-branded name for the service.

Pyrax accepts any of these different names as aliases for the services. Here is a partial list of these aliases for many of the current services:

Code Name | Service Name
---- | ----
nova | compute
cloudservers | compute
swift | object_store
cloudfiles | object_store
cloud_loadbalancers | load_balancer
trove | database
cloud_databases | database
cinder | volume
cloud_blockstorage | volume
designate | dns
cloud_dns | dns
neutron | network
cloud_networks | network
glance | image
images | image
marconi | queues
queues | queues
cloud_monitoring | monitor
autoscale | autoscale

### Getting a Client

The simplest way to get a client is to call:

client = ctx.get_client({service}, {region})

For example, if you want a client to interact with your servers in the ORD region of Rackspace, you call:

srvr_ord = ctx.get_client("compute", "ORD")
servers = srvr_ord.list()

The following two statements behave identically, as pyrax maps the code names to the actual service names:

srvr_ord = ctx.get_client("nova", "ORD")
srvr_ord = ctx.get_client("cloudservers", "ORD")

Once you have the client, you use it as you would use clients in prior versions of pyrax. As an example, once you have `srvr_ord` defined above, to get a list of your servers in that region, you call:

servers = srvr_ord.list()

#### Private (Internal) Clients

Some services offer internal URLs; these are typically used for communication between resources within the same datacenter. If you are working within a datacenter, these are typically more efficient and reduce or eliminate bandwidth charges with many commercial providers. A typical use case is storing objects in swift from a compute resource in the same datacenter.

To get a client that works with the internal URL, add the parameter `public=False` to the `get_client()` call:

storage_ord = ctx.get_client("object_store", "ORD", public=False)

If there is no internal URL defined for the service, a **`NoEndpointForService`** exception is raised.

## Shortcuts

Context objects provide convenient ways to access the clients in order to make working with pyrax simpler. You can use standard dot notation to define your clients:

srvr_ord = ctx.compute.ORD.client
# - or -
srvr_ord = ctx.ORD.compute.client

The ordering of service.region and region.service isn't important; either one resolves to the client for that service/region combination.

Another use of this notation is to get an object with all the services in a given region:

syd_svcs = ctx.SYD
server_clt = syd_svcs.compute.client
db_clt = syd_svcs.database.client

Note that the context object _must_ be authenticated before you attempt to access it using dot notation as described here. If the context has not been authenticated, a **`NotAuthenticated`** exception is raised. Also, regions containing periods in their name will not work as shortcuts, since those periods are interpreted by Python as object dot notation. If you're working with a region such as "**region-a.geo-1**", which is one of HP Cloud's regions, you will have to use standard dict syntax to access it:

compute_client = ctx.compute["region-a.geo-1"].client
Loading

0 comments on commit defad06

Please sign in to comment.