lease_it apps¶
lease_it.backend¶
lease_it.backendExceptions¶
This module contains all exception triggered by Backend
lease_it.backend.OpenstackConnection¶
This module manage interaction between application and OpenStack cloud infrastructure
-
class
lease_it.backend.OpenstackConnection.OpenstackConnection[source]¶ This class manage interface between OpenStack Cloud infrastructure and views.
-
flavors()[source]¶ Return a list of flavor and a detail about
- Their properties (CPU / Disk / RAM)
- The actual Cloud state (number of VM we can start, maximum VM we can start if empty)
Returns: dict()
-
instances(request, filtered=False)[source]¶ List all instances started on cluster and owned by user
Parameters: - request – Web request, used to retrieve user id
- filtered – True if we only return user_id instances
Returns: dict()
-
static
lease_instance(request, instance_id)[source]¶ If instance_id is owned by user_id, then update lease information, if not, raise PermissionDenied exception. A Openstack administrator can also update a lease for a user
Parameters: - instance_id – id of instance
- request – Web request
Returns: void
-
lease_it.backend.TestConnection¶
TestConnection is a fake backend to return some fake value for testing. It will return value in the same format that OpenstackConnection must do.
TestConnection inherits from OpenstackConnection and overwrite the private methods
- _instances()
- _flavors()
- _hypervisors()
- _domains()
- _users()
- _projects()
lease_it.client¶
instance-spy should be put on a crontab to check running instance, notify user if lease is close to expire and destroy instance when lease is over
lease_it.datastore¶
lease_it.datastore.Exceptions¶
This module contains all exception triggered by Backend
lease_it.datastore.ModelAccess¶
ModelAccess module is a interface between Django model and view
-
class
lease_it.datastore.ModelAccess.InstancesAccess[source]¶ ModelAccess is a class will abstract model access for application. It will get / save / ... informations in a format expected by views
-
static
delete(instance_id)[source]¶ Remove instance entry on database. If the VM is still running, the VM will be recreated on next spy instance running
Parameters: instance_id – instance to delete Returns: None
-
static
get(instance)[source]¶ Get or Create instance on model backend
Parameters: instance – instance to get Returns: Instance model
-
static
heartbeat(instance)[source]¶ get a instance and update the heartbeat value. This method is called by instance-spy when it find a instance running. Heartbeat can be use to retrieve old Virtual Machine
Parameters: instance – instance to update Returns: None
-
static
lease_it.notification¶
Mail notification system
-
class
lease_it.notification.MailNotification.MailNotification(users)[source]¶ A class to abstract e-mail notification
-
format_mail(user, notification_type, instances)[source]¶ Format the mail content :param user: user we currently notify :param notification_type: notification type (delete or notify) :param instances: list of instance for the user :return: string
-
lease_it.models¶
model for django database. Use for 2 differents cases:
- Cache some data to avoid useless overload on OpenStack infrastructure
- instances informations
- user informations
- ...
- Store data that is not available on OpenStack
- lease time
- ...
lease_it.views¶
Views module manage interface between user and openstack-lease-it.
lease_it.views provide interaction based on REST good practice.
-
lease_it.views.dashboard(request, *args, **kwargs)[source]¶ The default dashboard
Parameters: request – Web request Returns: HTML Rendering
-
lease_it.views.database(request, *args, **kwargs)[source]¶ This view is used to delete instance from database
Parameters: - request – Web request
- instance_id – instance id
Returns: JSonResponse w/ status of deletion
-
lease_it.views.databases(request, *args, **kwargs)[source]¶ View for all entries on database, used to delete old instances data
Parameters: request – Web request Returns: JSonResponse w/ list of database entries
-
lease_it.views.flavors(request, *args, **kwargs)[source]¶ View for flavors request
Parameters: request – Web request Returns: JsonResponse w/ list of flavor and details values
-
lease_it.views.instance(request, *args, **kwargs)[source]¶ This is view used to for a new lease on a specific instance (http://url/instances/instance_id) a PermissionDenied exception is raised decided by backend. Mainly if instance is not owned by user but see Backend comment.
Parameters: - request – Web request
- instance_id – retrieve from url
Returns: JsonResponse