Adding support for sphinx docs and tox support
In order to add the project to OpenStack Jenkins, Zuul we need to enable the following: * Running the test through tox (added tox.ini) * Making sure the project can be packaged and uploaded into pypi (moved all python files to the mors package) * Adding support for Sphinx Docunentation Part of the changes were autogenerated using OpenStack cookiecutter project which creates a template
This commit is contained in:
parent
e7fb57fee6
commit
3eb6c95424
17
CONTRIBUTING.rst
Normal file
17
CONTRIBUTING.rst
Normal file
@ -0,0 +1,17 @@
|
||||
If you would like to contribute to the development of OpenStack, you must
|
||||
follow the steps in this page:
|
||||
|
||||
http://docs.openstack.org/infra/manual/developers.html
|
||||
|
||||
If you already have a good understanding of how the system works and your
|
||||
OpenStack accounts are set up, you can skip to the development workflow
|
||||
section of this documentation to learn how changes to OpenStack should be
|
||||
submitted for review via the Gerrit tool:
|
||||
|
||||
http://docs.openstack.org/infra/manual/developers.html#development-workflow
|
||||
|
||||
Pull requests submitted through GitHub will be ignored.
|
||||
|
||||
Bugs should be filed on Launchpad, not GitHub:
|
||||
|
||||
https://bugs.launchpad.net/mors
|
79
README.rst
Normal file
79
README.rst
Normal file
@ -0,0 +1,79 @@
|
||||
Mors - OpenStack Lease Manager
|
||||
==============================
|
||||
|
||||
|Mors| https://en.wikipedia.org/wiki/Mors\_(mythology) is a simple lease
|
||||
manager for OpenStack objects like Instances.
|
||||
|
||||
Mors is a useful tool for OpenStack based cloud used for dev, test or
|
||||
lab setups. Typical usage in these scenarios include automatically or
|
||||
manual creation of Instances for demo, test or experiments. In most
|
||||
cases these Instances are forgotten and never deleted eating up valuable
|
||||
resources.
|
||||
|
||||
Mors is a simple service that helps enforce a policy per Tenant or
|
||||
Instance and automatically delete Instances after a specified duration.
|
||||
|
||||
Details
|
||||
-------
|
||||
|
||||
Mors works by specification of lease policy in a hierarchical fashion,
|
||||
first at a Tenant level and further at individual Instance level.
|
||||
|
||||
Tenant Lease Policy
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Mors lease policy can be enabled or disabled at Tenant level. If Mors
|
||||
policy is disabled (default for each tenant) no lease policies apply to
|
||||
the instances within that tenant.
|
||||
|
||||
At Tenant level, policy is specified in terms of *duration* . Once Mors
|
||||
policy is enabled, any Instance will be deleted after
|
||||
``instance.created_time + tenant.lease duration = instance_expiration``
|
||||
|
||||
Roles
|
||||
^^^^^
|
||||
|
||||
Tenant leases can be viewed by user with ‘member’ role and modified by
|
||||
users with ‘admin’ role
|
||||
|
||||
Instance Lease Policy
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
By default Instance leases are governed by the policies at Instance’s
|
||||
Tenant level. As mentioned earlier:
|
||||
``instance.created_time + tenant.lease duration = instance_expiration``
|
||||
|
||||
A member of tenant can change the Instance expiry at any time, but it
|
||||
can never be later than now + tenant.lease duration
|
||||
|
||||
``max instance lease <= now + tenant.lease duration``
|
||||
|
||||
A user can always come back at a later point of time and renew the
|
||||
release again.
|
||||
|
||||
Roles
|
||||
^^^^^
|
||||
|
||||
Instance leases can be modified by both ‘member’ and ‘admin’ roles.
|
||||
|
||||
Build & Installation
|
||||
--------------------
|
||||
|
||||
Support subdirectory contains Makefile to build a RPM, apart from python
|
||||
2.7, virtualenv it needs `fpm`_, *fpm* is a simple package build utility
|
||||
that can build both RPM and deb packages. RPM itself is a thin wrapper
|
||||
on top of the virtualenv.
|
||||
|
||||
Configuration files are expected to be in /etc/pf9 directory. These are
|
||||
usual OpenStack style config files: \* pf9-mors.ini: configure the nova
|
||||
section with the user/password that can be used by mors to perform
|
||||
delete operations on nova instances. The user needs to be an
|
||||
administrator. \* pf9-mors-api-paste.ini: configure the keystone
|
||||
middleware with keystone auth tokens.
|
||||
|
||||
The packages comes with an init script that works on RHEL 7 compatible
|
||||
systems
|
||||
|
||||
.. _fpm: https://github.com/jordansissel/fpm
|
||||
|
||||
.. |Mors| image:: https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRIzc5fgaiZfJnbym_ZEx4CsZJ7qIiYjcrxth5hi80Q0IhfnxOg
|
75
doc/source/conf.py
Executable file
75
doc/source/conf.py
Executable file
@ -0,0 +1,75 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.abspath('../..'))
|
||||
# -- General configuration ----------------------------------------------------
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
#'sphinx.ext.intersphinx',
|
||||
'oslosphinx'
|
||||
]
|
||||
|
||||
# autodoc generation is a bit aggressive and a nuisance when doing heavy
|
||||
# text edit cycles.
|
||||
# execute "export SPHINX_DEBUG=1" in your terminal to disable
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'mors'
|
||||
copyright = u'2016, OpenStack Foundation'
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
add_module_names = True
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
# -- Options for HTML output --------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. Major themes that come with
|
||||
# Sphinx are currently 'default' and 'sphinxdoc'.
|
||||
# html_theme_path = ["."]
|
||||
# html_theme = '_theme'
|
||||
# html_static_path = ['static']
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = '%sdoc' % project
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass
|
||||
# [howto/manual]).
|
||||
latex_documents = [
|
||||
('index',
|
||||
'%s.tex' % project,
|
||||
u'%s Documentation' % project,
|
||||
u'OpenStack Foundation', 'manual'),
|
||||
]
|
||||
|
||||
# Example configuration for intersphinx: refer to the Python standard library.
|
||||
#intersphinx_mapping = {'http://docs.python.org/': None}
|
4
doc/source/contributing.rst
Normal file
4
doc/source/contributing.rst
Normal file
@ -0,0 +1,4 @@
|
||||
============
|
||||
Contributing
|
||||
============
|
||||
.. include:: ../../CONTRIBUTING.rst
|
25
doc/source/index.rst
Normal file
25
doc/source/index.rst
Normal file
@ -0,0 +1,25 @@
|
||||
.. mors documentation master file, created by
|
||||
sphinx-quickstart on Tue Jul 9 22:26:36 2013.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
Welcome to mors's documentation!
|
||||
========================================================
|
||||
|
||||
Contents:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
readme
|
||||
installation
|
||||
usage
|
||||
contributing
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
||||
|
38
doc/source/installation.rst
Normal file
38
doc/source/installation.rst
Normal file
@ -0,0 +1,38 @@
|
||||
============
|
||||
Installation
|
||||
============
|
||||
|
||||
From PyPi
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
At the command line::
|
||||
|
||||
$ pip install mors
|
||||
|
||||
Or, if you have virtualenvwrapper installed::
|
||||
|
||||
$ mkvirtualenv mors
|
||||
$ pip install mors
|
||||
|
||||
|
||||
RPM BUILD
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Mors comes with an RPM installation and associated init.d scripts. Run the makefile under 'support' directory
|
||||
and it will produce RPM under the build directory.
|
||||
|
||||
Support subdirectory contains Makefile to build a RPM, apart from python
|
||||
2.7, virtualenv it needs `fpm`_, *fpm* is a simple package build utility
|
||||
that can build both RPM and deb packages. RPM itself is a thin wrapper
|
||||
on top of the virtualenv.
|
||||
|
||||
Configuration files are expected to be in /etc/pf9 directory. These are
|
||||
usual OpenStack style config files: \* pf9-mors.ini: configure the nova
|
||||
section with the user/password that can be used by mors to perform
|
||||
delete operations on nova instances. The user needs to be an
|
||||
administrator. \* pf9-mors-api-paste.ini: configure the keystone
|
||||
middleware with keystone auth tokens.
|
||||
|
||||
The packages comes with an init script that works on RHEL 7 compatible
|
||||
systems
|
||||
|
||||
.. _fpm: https://github.com/jordansissel/fpm
|
1
doc/source/readme.rst
Normal file
1
doc/source/readme.rst
Normal file
@ -0,0 +1 @@
|
||||
.. include:: ../../README.rst
|
5
doc/source/usage.rst
Normal file
5
doc/source/usage.rst
Normal file
@ -0,0 +1,5 @@
|
||||
========
|
||||
Usage
|
||||
========
|
||||
|
||||
Refer to README for details on the policies and how the API is structured.
|
29
setup.cfg
Normal file
29
setup.cfg
Normal file
@ -0,0 +1,29 @@
|
||||
[metadata]
|
||||
name = mors
|
||||
summary = OpenStack project for lease management of Instance and other OpenStack objects
|
||||
description-file =
|
||||
README.rst
|
||||
author = OpenStack
|
||||
author-email = openstack-dev@lists.openstack.org
|
||||
home-page = http://www.openstack.org/
|
||||
classifier =
|
||||
Environment :: OpenStack
|
||||
Intended Audience :: Information Technology
|
||||
Intended Audience :: System Administrators
|
||||
License :: OSI Approved :: Apache Software License
|
||||
Operating System :: POSIX :: Linux
|
||||
Programming Language :: Python
|
||||
Programming Language :: Python :: 2.7
|
||||
|
||||
[files]
|
||||
packages =
|
||||
mors
|
||||
|
||||
[build_sphinx]
|
||||
source-dir = doc/source
|
||||
build-dir = doc/build
|
||||
all_files = 1
|
||||
|
||||
[upload_sphinx]
|
||||
upload-dir = doc/build/html
|
||||
|
4
setup.py
4
setup.py
@ -16,7 +16,7 @@ limitations under the License.
|
||||
"""
|
||||
from setuptools import setup
|
||||
|
||||
setup(name='pf9-mors',
|
||||
setup(name='mors',
|
||||
version='0.1',
|
||||
description='Platform9 Mors (lease manager)',
|
||||
author='Platform9',
|
||||
@ -46,5 +46,5 @@ setup(name='pf9-mors',
|
||||
'nose',
|
||||
'proboscis'
|
||||
],
|
||||
scripts=['pf9_mors.py', 'mors_manage.py']
|
||||
scripts=['mors/pf9_mors.py', 'mors/mors_manage.py']
|
||||
)
|
||||
|
@ -15,12 +15,11 @@ limitations under the License.
|
||||
"""
|
||||
def run_tests():
|
||||
from proboscis import TestProgram
|
||||
|
||||
import test_api, test_persistence
|
||||
|
||||
# Run Proboscis and exit.
|
||||
print "Starting tests ---"
|
||||
TestProgram().run_and_exit()
|
||||
print "Tests done ---"
|
||||
|
||||
if __name__ == '__main__':
|
||||
print "Run tests"
|
||||
|
@ -13,19 +13,20 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
from migrate.versioning.api import upgrade, create, version_control
|
||||
import ConfigParser, os
|
||||
import requests
|
||||
import ConfigParser
|
||||
import os
|
||||
import sys;
|
||||
|
||||
import eventlet
|
||||
from pf9_mors import start_server
|
||||
import requests
|
||||
from migrate.versioning.api import upgrade, version_control
|
||||
|
||||
print sys.path
|
||||
from mors.pf9_mors import start_server
|
||||
from mors.mors_wsgi import DATE_FORMAT
|
||||
import logging, sys
|
||||
from datetime import datetime, timedelta
|
||||
from proboscis.asserts import assert_equal
|
||||
from proboscis.asserts import assert_false
|
||||
from proboscis.asserts import assert_raises
|
||||
from proboscis.asserts import assert_true
|
||||
from proboscis import SkipTest
|
||||
from proboscis import test
|
||||
import shutil
|
||||
from mors.leasehandler.fake_lease_handler import FakeLeaseHandler
|
||||
|
Loading…
x
Reference in New Issue
Block a user