Difference between revisions of "PythonOpenStackSDK/ClassDesignDiscussion"
(→Introduction) |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | == | + | = 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 == |
+ | The internal design section of this document should cover aspects of the SDK that the typical user will not need to know. Developers and advanced users may find this information useful. | ||
− | === | + | === Authenticator === |
− | + | The '''Authenticator''' class is responsible for providing a valid authentication token and an appropriate endpoint for a service type. The authenticator can use a '''Transport''' to get a valid token if needed. | |
− | === | + | === Connection === |
− | The | + | The internal design of the OpenStack Python SDK is based on the [http://en.wikipedia.org/wiki/OSI_model OSI Model] where the application is the resource object. The objects are described in more detail below. |
+ | [[File:OpenStack_Python_SDK_Stack.png|none|center|OpenStack Python SDK Stack]] | ||
==== Resource ==== | ==== 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. | + | 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. Well known attributes of a resource should be accessible through properties of the class. |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | ==== Presentation ==== | |
+ | The job of the presentation layer is encoding and decoding of messages in the desired format. The default format is json and that is the only type currently supported, but it would be easy to add support for xml or text/plain. The '''Presentation''' class also manages the 'Accept' and 'Content-Type' headers to indicate the type of encoding. The presentation layer expects to communicate with a session layer. | ||
− | + | ==== Session ==== | |
+ | The session layer is responsible for maintaining an authorized session using the '''Authenticator'''. The authenticator is expected to provide a valid authentication token and an endpoint. The session layer manages the 'X-Auth-Token' header and sends requests over a transport layer. The session layer also makes sure the request is routed to the appropriate endpoint. | ||
− | + | ==== Transport ==== | |
+ | The '''Transport''' class is a wrapper for the requests.Session class and adds some common OpenStack functionality. The transport manages SSL certificate verification, the 'User-Agent' header and HTTP redirects. The transport also will allow logging of requests. |
Latest revision as of 14:37, 30 April 2014
Contents
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
The internal design section of this document should cover aspects of the SDK that the typical user will not need to know. Developers and advanced users may find this information useful.
Authenticator
The Authenticator class is responsible for providing a valid authentication token and an appropriate endpoint for a service type. The authenticator can use a Transport to get a valid token if needed.
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.
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. Well known attributes of a resource should be accessible through properties of the class.
Presentation
The job of the presentation layer is encoding and decoding of messages in the desired format. The default format is json and that is the only type currently supported, but it would be easy to add support for xml or text/plain. The Presentation class also manages the 'Accept' and 'Content-Type' headers to indicate the type of encoding. The presentation layer expects to communicate with a session layer.
Session
The session layer is responsible for maintaining an authorized session using the Authenticator. The authenticator is expected to provide a valid authentication token and an endpoint. The session layer manages the 'X-Auth-Token' header and sends requests over a transport layer. The session layer also makes sure the request is routed to the appropriate endpoint.
Transport
The Transport class is a wrapper for the requests.Session class and adds some common OpenStack functionality. The transport manages SSL certificate verification, the 'User-Agent' header and HTTP redirects. The transport also will allow logging of requests.