openstack_lease_it apps

openstack_lease_it is the core django module of Openstack lease it!. It provide some core functions like

  • settings
  • configuration file loading
  • homemade decorators
  • core template for web interface

openstack_lease_it.config

This module manage configuration file.

  • /etc/openstack-lease-it/config.ini
  • $HOME/.lease-it.ini

This module also provide GLOBAL_CONFIG variable used to share configuration across module / django apps.

openstack_lease_it.config.BASE_CONFIG_DIR = '/etc/openstack-lease-it'

To avoid some typo mistake, we use BASE_CONFIG_DIR to define the base directory for configuration files

openstack_lease_it.config.CONFIG_FILES = ('/etc/openstack-lease-it/config.ini', '/home/docs/.lease-it.ini')

The list of configuration file we will parse to load openstack-lease-it configuration

openstack_lease_it.config.DJANGO_OPTIONS = {'DJANGO_LOGDIR': 'log_dir', 'DJANGO_LOGLEVEL': 'log_level', 'DJANGO_SECRET_KEY': 'secret_key', 'DJANGO_DEBUG': 'debug'}
  • DJANGO_SECRET_KEY: The secret key used by django (file option: secret_key)
  • DJANGO_DEBUG: The DEBUG value for django (file option: debug)
  • DJANGO_LOGDIR: Directory where log file will be write (file option: log_dir)
  • DJANGO_LOGLEVEL: The log level used for django (file option: log_level)
openstack_lease_it.config.GLOBAL_CONFIG = {'BACKEND_PLUGIN': 'Openstack', 'OS_PROJECT_DOMAIN_NAME': 'default', 'NOTIFICATION_LEASE_CONTENT': '/etc/openstack-lease-it/lease-notification.txt', 'OS_USERNAME': 'admin', 'NOTIFICATION_DOMAIN': '', 'OS_IDENTITY_API_VERSION': '3', 'DJANGO_LOGDIR': '/var/log/openstack-lease-it/', 'MEMCACHED_PORT': '11211', 'OS_USER_DOMAIN_NAME': 'default', 'OS_TENANT_NAME': 'admin', 'NOTIFICATION_DELETE_CONTENT': '/etc/openstack-lease-it/delete-notification.txt', 'OS_AUTH_URL': 'https://keystone.example.com', 'DJANGO_DEBUG': 'False', 'OS_PROJECT_NAME': 'admin', 'MEMCACHED_HOST': '127.0.0.1', 'OS_PASSWORD': 'admin_password', 'DJANGO_LOGLEVEL': 'INFO', 'DJANGO_SECRET_KEY': 'Must_be_defined', 'NOTIFICATION_DEBUG': 'False'}

We use the global variable GLOBAL_CONFIG to share openstack-lease-it configuration to all user. Some value have default value.

openstack_lease_it.config.MEMCACHED_OPTIONS = {'MEMCACHED_HOST': 'host', 'MEMCACHED_PORT': 'port'}
  • MEMCACHED_HOST: hostname of memcached server (file option: host)
  • MEMCACHED_PORT: port of memcached server (file option: port)
openstack_lease_it.config.NOTIFICATION_OPTIONS = {'NOTIFICATION_LEASE_CONTENT': 'lease_content', 'NOTIFICATION_SMTP': 'smtp', 'NOTIFICATION_USERNAME': 'username', 'NOTIFICATION_LINK': 'link', 'NOTIFICATION_SSL': 'ssl', 'NOTIFICATION_EMAIL_HEADER': 'email_header', 'NOTIFICATION_DEBUG': 'debug', 'NOTIFICATION_DOMAIN': 'default_domain', 'NOTIFICATION_DELETE_CONTENT': 'delete_content', 'NOTIFICATION_PASSWORD': 'password', 'NOTIFICATION_SUBJECT': 'subject'}
  • NOTIFICATION_SSL: enable / disable ssl for smtp connection (file option: ssl)
  • NOTIFICATION_SMTP: hostname of smtp server (file option: smtp)
  • NOTIFICATION_USERNAME: username for smtp connection (file option: username)
  • NOTIFICATION_PASSWORD: password for smtp connection (file option: password)
  • NOTIFICATION_EMAIL_HEADER: email sender (file option: email_header)
  • NOTIFICATION_SUBJECT: subject of the mail (file option: subject)
  • NOTIFICATION_LINK: url of lease-it server (file option: link)
  • NOTIFICATION_DEBUG: enable/disable user notification (file option: debug)
  • NOTIFICATION_DOMAIN: default domain if email field not match email regexp (file option: default_domain)
  • NOTIFICATION_DELETE_CONTENT: filename for mail content template (file option: delete_content)
  • NOTIFICATION_LEASE_CONTENT: filename for mail content template (file option: lease_content)
openstack_lease_it.config.OPENSTACK_OPTIONS = {'OS_AUTH_URL': 'OS_AUTH_URL', 'OS_USER_DOMAIN_NAME': 'OS_USER_DOMAIN_NAME', 'OS_USERNAME': 'OS_USERNAME', 'OS_PROJECT_NAME': 'OS_PROJECT_NAME', 'OS_IDENTITY_API_VERSION': 'OS_IDENTITY_API_VERSION', 'OS_PASSWORD': 'OS_PASSWORD', 'OS_PROJECT_DOMAIN_NAME': 'OS_PROJECT_DOMAIN_NAME', 'OS_CACERT': 'OS_CACERT', 'OS_TENANT_NAME': 'OS_TENANT_NAME'}
  • OS_USERNAME: Openstack admin username (file option: OS_USERNAME)
  • OS_PASSWORD: Openstack admin password (file option: OS_PASSWORD)
  • OS_TENANT_NAME: Openstack admin project name (file option: OS_TENANT_NAME)
  • OS_PROJECT_NAME: Openstack admin project name (file option: OS_PROJECT_NAME)
  • OS_AUTH_URL: Cloud keystone URL (file option: OS_AUTH_URL)
  • OS_CACERT: CA certificate filename (file option: OS_CACERT)
  • OS_IDENTITY_API_VERSION: Keystone version (file option: OS_IDENTITY_API_VERSION)
  • OS_PROJECT_DOMAIN_NAME: project domain name (file option: OS_PROJECT_DOMAIN_NAME)
  • OS_USER_DOMAIN_NAME: user domain name (file option: OS_USER_DOMAIN_NAME)
openstack_lease_it.config.PLUGINS_OPTIONS = {'BACKEND_PLUGIN': 'backend'}
  • BACKEND_PLUGIN: Backend we will use (file option: backend)
openstack_lease_it.config.SECTIONS = {'openstack': {'OS_AUTH_URL': 'OS_AUTH_URL', 'OS_USER_DOMAIN_NAME': 'OS_USER_DOMAIN_NAME', 'OS_USERNAME': 'OS_USERNAME', 'OS_PROJECT_NAME': 'OS_PROJECT_NAME', 'OS_IDENTITY_API_VERSION': 'OS_IDENTITY_API_VERSION', 'OS_PASSWORD': 'OS_PASSWORD', 'OS_PROJECT_DOMAIN_NAME': 'OS_PROJECT_DOMAIN_NAME', 'OS_CACERT': 'OS_CACERT', 'OS_TENANT_NAME': 'OS_TENANT_NAME'}, 'plugins': {'BACKEND_PLUGIN': 'backend'}, 'memcached': {'MEMCACHED_HOST': 'host', 'MEMCACHED_PORT': 'port'}, 'notification': {'NOTIFICATION_LEASE_CONTENT': 'lease_content', 'NOTIFICATION_SMTP': 'smtp', 'NOTIFICATION_USERNAME': 'username', 'NOTIFICATION_LINK': 'link', 'NOTIFICATION_SSL': 'ssl', 'NOTIFICATION_EMAIL_HEADER': 'email_header', 'NOTIFICATION_DEBUG': 'debug', 'NOTIFICATION_DOMAIN': 'default_domain', 'NOTIFICATION_DELETE_CONTENT': 'delete_content', 'NOTIFICATION_PASSWORD': 'password', 'NOTIFICATION_SUBJECT': 'subject'}, 'django': {'DJANGO_LOGDIR': 'log_dir', 'DJANGO_LOGLEVEL': 'log_level', 'DJANGO_SECRET_KEY': 'secret_key', 'DJANGO_DEBUG': 'debug'}}
  • django: section [django]
  • openstack: section [openstack]
  • memcached: section [memcached]
  • plugins: section [plugins]
  • notification: section [notification]
openstack_lease_it.config.load_config()[source]

Define default configuration, NOT all value have a default

Returns:void
openstack_lease_it.config.load_config_option(config, section)[source]

This function overwrite the current global_config[name] value with option

Parameters:
  • config – Configuration file we read
  • section – The section of configuration file we compute
Returns:

void

openstack_lease_it.decorators

This module define a list of homemade decorators

openstack_lease_it.decorators.superuser_required(view)[source]

If superuser access is required for a specific view, we use @superuser_required decorator

Parameters:view – As parameter, we have the view function
Returns:function

openstack_lease_it.views

View module manage interaction between user and openstack-lease-it. It provide HTTP interface based on REST good practice.

openstack_lease_it.view only provide core view

openstack_lease_it.views.login(request)[source]

Default login view when we not use openstack_auth module for authentication

Parameters:request – web request
Returns:HTML rendering
openstack_lease_it.views.logout(request)[source]

Default page to logout, we redirect to /

Parameters:request – web request
Returns:HTML rendering