diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 0000000..a816872 --- /dev/null +++ b/CONTRIBUTING.rst @@ -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 diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..d8d4ed1 --- /dev/null +++ b/README.rst @@ -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 \ No newline at end of file diff --git a/doc/source/conf.py b/doc/source/conf.py new file mode 100755 index 0000000..a2481a5 --- /dev/null +++ b/doc/source/conf.py @@ -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} diff --git a/doc/source/contributing.rst b/doc/source/contributing.rst new file mode 100644 index 0000000..1728a61 --- /dev/null +++ b/doc/source/contributing.rst @@ -0,0 +1,4 @@ +============ +Contributing +============ +.. include:: ../../CONTRIBUTING.rst diff --git a/doc/source/index.rst b/doc/source/index.rst new file mode 100644 index 0000000..bb4a3ca --- /dev/null +++ b/doc/source/index.rst @@ -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` + diff --git a/doc/source/installation.rst b/doc/source/installation.rst new file mode 100644 index 0000000..a68636f --- /dev/null +++ b/doc/source/installation.rst @@ -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 diff --git a/doc/source/readme.rst b/doc/source/readme.rst new file mode 100644 index 0000000..a6210d3 --- /dev/null +++ b/doc/source/readme.rst @@ -0,0 +1 @@ +.. include:: ../../README.rst diff --git a/doc/source/usage.rst b/doc/source/usage.rst new file mode 100644 index 0000000..c660c81 --- /dev/null +++ b/doc/source/usage.rst @@ -0,0 +1,5 @@ +======== +Usage +======== + +Refer to README for details on the policies and how the API is structured. \ No newline at end of file diff --git a/mors_manage.py b/mors/mors_manage.py similarity index 100% rename from mors_manage.py rename to mors/mors_manage.py diff --git a/pf9_mors.py b/mors/pf9_mors.py similarity index 100% rename from pf9_mors.py rename to mors/pf9_mors.py diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..7ab3e54 --- /dev/null +++ b/setup.cfg @@ -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 + diff --git a/setup.py b/setup.py index afcd524..b0b440f 100644 --- a/setup.py +++ b/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'] ) diff --git a/test/run_tests.py b/test/run_tests.py index 0ce0947..48c0709 100644 --- a/test/run_tests.py +++ b/test/run_tests.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" diff --git a/test/test_api.py b/test/test_api.py index 0b643fd..6776b51 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -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 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..999a6b8 --- /dev/null +++ b/tox.ini @@ -0,0 +1,9 @@ +[tox] +envlist = py27 + +[testenv:py27] +deps = + nose + proboscis +commands = + python test/run_tests.py