Jump to: navigation, search

PythonOpenStackSDK/ClassDesignDiscussion

Design

The intention of this document is to give a high level picture of the design of the OpenStack Python SDK. This document should cover how the SDK appears from the user perspective and important details of the internal design that the average user should not need to worry about.

User Interface Design

=Internal Design

Authenticator

Connection

The internal design of the OpenStack Python SDK is based on the OSI Model where the application is the resource object. The objects are described in more detail below.

OpenStack Python SDK Stack

Resource

The Resource class represents a resource in the cloud, such as a compute instance, a stored object, a network, etc. Rather than have fixed attributes, its attributes should be populated with the information returned from the API. Every resource should have an id attribute; in the cases where there is not a native id, such as a stored object in Swift, an 'id' property should be created to return the unique identifier for the resource, such as a name.

Transport

For each service there is a single Client class that contains the interface that the application developer will work with. Any functionality in the SDK should be available as a method in the Client class. Each Client instance has a reference to an instance of its Manager class. There is no logic in the Client class except to pass the request to its manager, and return the result from the manager to the application.

General Design Principles

  • Whenever possible, equivalent parameters should be accepted. E.g., when acting on a resource, the user should be able to either supply the ID of that resource, or an instance on the Resource class corresponding to that resource.
  • While the Client class is the interface to the developer using this SDK in their applications, there is one exception for convenience: Resource objects may be interacted with directly where appropriate. In general any time you have a method that looks like:
   client.some_method(resource)

you should be able to work directly with the resource:

   resource.some_method()

For example, if you have a reference server to a compute resource, wish to delete a compute resource, you could call either compute_client.delete(server), or server.delete(), and they would both result in the same action.