summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoopak Parikh <roopak@gmail.com>2016-08-02 11:21:31 -0700
committerRoopak Parikh <roopak@gmail.com>2016-08-02 11:48:25 -0700
commit3eb6c954248428e46e31c2dc6930da86229ef356 (patch)
treec446d441a951e888f0779e7dd236c97daacf9bc5
parente7fb57fee676ab6616e6226087967b6f791f9212 (diff)
Adding support for sphinx docs and tox supportatherton
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
-rw-r--r--CONTRIBUTING.rst17
-rw-r--r--README.rst79
-rwxr-xr-xdoc/source/conf.py75
-rw-r--r--doc/source/contributing.rst4
-rw-r--r--doc/source/index.rst25
-rw-r--r--doc/source/installation.rst38
-rw-r--r--doc/source/readme.rst1
-rw-r--r--doc/source/usage.rst5
-rw-r--r--mors/mors_manage.py (renamed from mors_manage.py)0
-rw-r--r--mors/pf9_mors.py (renamed from pf9_mors.py)0
-rw-r--r--setup.cfg29
-rw-r--r--setup.py4
-rw-r--r--test/run_tests.py3
-rw-r--r--test/test_api.py17
-rw-r--r--tox.ini9
15 files changed, 294 insertions, 12 deletions
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
new file mode 100644
index 0000000..a816872
--- /dev/null
+++ b/CONTRIBUTING.rst
@@ -0,0 +1,17 @@
1If you would like to contribute to the development of OpenStack, you must
2follow the steps in this page:
3
4 http://docs.openstack.org/infra/manual/developers.html
5
6If you already have a good understanding of how the system works and your
7OpenStack accounts are set up, you can skip to the development workflow
8section of this documentation to learn how changes to OpenStack should be
9submitted for review via the Gerrit tool:
10
11 http://docs.openstack.org/infra/manual/developers.html#development-workflow
12
13Pull requests submitted through GitHub will be ignored.
14
15Bugs should be filed on Launchpad, not GitHub:
16
17 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 @@
1Mors - OpenStack Lease Manager
2==============================
3
4|Mors| https://en.wikipedia.org/wiki/Mors\_(mythology) is a simple lease
5manager for OpenStack objects like Instances.
6
7Mors is a useful tool for OpenStack based cloud used for dev, test or
8lab setups. Typical usage in these scenarios include automatically or
9manual creation of Instances for demo, test or experiments. In most
10cases these Instances are forgotten and never deleted eating up valuable
11resources.
12
13Mors is a simple service that helps enforce a policy per Tenant or
14Instance and automatically delete Instances after a specified duration.
15
16Details
17-------
18
19Mors works by specification of lease policy in a hierarchical fashion,
20first at a Tenant level and further at individual Instance level.
21
22Tenant Lease Policy
23~~~~~~~~~~~~~~~~~~~
24
25Mors lease policy can be enabled or disabled at Tenant level. If Mors
26policy is disabled (default for each tenant) no lease policies apply to
27the instances within that tenant.
28
29At Tenant level, policy is specified in terms of *duration* . Once Mors
30policy is enabled, any Instance will be deleted after
31``instance.created_time + tenant.lease duration = instance_expiration``
32
33Roles
34^^^^^
35
36Tenant leases can be viewed by user with ‘member’ role and modified by
37users with ‘admin’ role
38
39Instance Lease Policy
40~~~~~~~~~~~~~~~~~~~~~
41
42By default Instance leases are governed by the policies at Instance’s
43Tenant level. As mentioned earlier:
44``instance.created_time + tenant.lease duration = instance_expiration``
45
46A member of tenant can change the Instance expiry at any time, but it
47can never be later than now + tenant.lease duration
48
49``max instance lease <= now + tenant.lease duration``
50
51A user can always come back at a later point of time and renew the
52release again.
53
54Roles
55^^^^^
56
57Instance leases can be modified by both ‘member’ and ‘admin’ roles.
58
59Build & Installation
60--------------------
61
62Support subdirectory contains Makefile to build a RPM, apart from python
632.7, virtualenv it needs `fpm`_, *fpm* is a simple package build utility
64that can build both RPM and deb packages. RPM itself is a thin wrapper
65on top of the virtualenv.
66
67Configuration files are expected to be in /etc/pf9 directory. These are
68usual OpenStack style config files: \* pf9-mors.ini: configure the nova
69section with the user/password that can be used by mors to perform
70delete operations on nova instances. The user needs to be an
71administrator. \* pf9-mors-api-paste.ini: configure the keystone
72middleware with keystone auth tokens.
73
74The packages comes with an init script that works on RHEL 7 compatible
75systems
76
77.. _fpm: https://github.com/jordansissel/fpm
78
79.. |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 @@
1# -*- coding: utf-8 -*-
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
11# implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import os
16import sys
17
18sys.path.insert(0, os.path.abspath('../..'))
19# -- General configuration ----------------------------------------------------
20
21# Add any Sphinx extension module names here, as strings. They can be
22# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
23extensions = [
24 'sphinx.ext.autodoc',
25 #'sphinx.ext.intersphinx',
26 'oslosphinx'
27]
28
29# autodoc generation is a bit aggressive and a nuisance when doing heavy
30# text edit cycles.
31# execute "export SPHINX_DEBUG=1" in your terminal to disable
32
33# The suffix of source filenames.
34source_suffix = '.rst'
35
36# The master toctree document.
37master_doc = 'index'
38
39# General information about the project.
40project = u'mors'
41copyright = u'2016, OpenStack Foundation'
42
43# If true, '()' will be appended to :func: etc. cross-reference text.
44add_function_parentheses = True
45
46# If true, the current module name will be prepended to all description
47# unit titles (such as .. function::).
48add_module_names = True
49
50# The name of the Pygments (syntax highlighting) style to use.
51pygments_style = 'sphinx'
52
53# -- Options for HTML output --------------------------------------------------
54
55# The theme to use for HTML and HTML Help pages. Major themes that come with
56# Sphinx are currently 'default' and 'sphinxdoc'.
57# html_theme_path = ["."]
58# html_theme = '_theme'
59# html_static_path = ['static']
60
61# Output file base name for HTML help builder.
62htmlhelp_basename = '%sdoc' % project
63
64# Grouping the document tree into LaTeX files. List of tuples
65# (source start file, target name, title, author, documentclass
66# [howto/manual]).
67latex_documents = [
68 ('index',
69 '%s.tex' % project,
70 u'%s Documentation' % project,
71 u'OpenStack Foundation', 'manual'),
72]
73
74# Example configuration for intersphinx: refer to the Python standard library.
75#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 @@
1============
2Contributing
3============
4.. 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 @@
1.. mors documentation master file, created by
2 sphinx-quickstart on Tue Jul 9 22:26:36 2013.
3 You can adapt this file completely to your liking, but it should at least
4 contain the root `toctree` directive.
5
6Welcome to mors's documentation!
7========================================================
8
9Contents:
10
11.. toctree::
12 :maxdepth: 2
13
14 readme
15 installation
16 usage
17 contributing
18
19Indices and tables
20==================
21
22* :ref:`genindex`
23* :ref:`modindex`
24* :ref:`search`
25
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 @@
1============
2Installation
3============
4
5From PyPi
6~~~~~~~~~~~~~~~~~~~~~
7At the command line::
8
9 $ pip install mors
10
11Or, if you have virtualenvwrapper installed::
12
13 $ mkvirtualenv mors
14 $ pip install mors
15
16
17RPM BUILD
18~~~~~~~~~~~~~~~~~~~~~
19
20Mors comes with an RPM installation and associated init.d scripts. Run the makefile under 'support' directory
21and it will produce RPM under the build directory.
22
23Support subdirectory contains Makefile to build a RPM, apart from python
242.7, virtualenv it needs `fpm`_, *fpm* is a simple package build utility
25that can build both RPM and deb packages. RPM itself is a thin wrapper
26on top of the virtualenv.
27
28Configuration files are expected to be in /etc/pf9 directory. These are
29usual OpenStack style config files: \* pf9-mors.ini: configure the nova
30section with the user/password that can be used by mors to perform
31delete operations on nova instances. The user needs to be an
32administrator. \* pf9-mors-api-paste.ini: configure the keystone
33middleware with keystone auth tokens.
34
35The packages comes with an init script that works on RHEL 7 compatible
36systems
37
38.. _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 @@
1========
2Usage
3========
4
5Refer 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
index d0bf6a9..d0bf6a9 100644
--- a/mors_manage.py
+++ b/mors/mors_manage.py
diff --git a/pf9_mors.py b/mors/pf9_mors.py
index eb5b9a4..eb5b9a4 100644
--- a/pf9_mors.py
+++ b/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 @@
1[metadata]
2name = mors
3summary = OpenStack project for lease management of Instance and other OpenStack objects
4description-file =
5 README.rst
6author = OpenStack
7author-email = openstack-dev@lists.openstack.org
8home-page = http://www.openstack.org/
9classifier =
10 Environment :: OpenStack
11 Intended Audience :: Information Technology
12 Intended Audience :: System Administrators
13 License :: OSI Approved :: Apache Software License
14 Operating System :: POSIX :: Linux
15 Programming Language :: Python
16 Programming Language :: Python :: 2.7
17
18[files]
19packages =
20 mors
21
22[build_sphinx]
23source-dir = doc/source
24build-dir = doc/build
25all_files = 1
26
27[upload_sphinx]
28upload-dir = doc/build/html
29
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.
16""" 16"""
17from setuptools import setup 17from setuptools import setup
18 18
19setup(name='pf9-mors', 19setup(name='mors',
20 version='0.1', 20 version='0.1',
21 description='Platform9 Mors (lease manager)', 21 description='Platform9 Mors (lease manager)',
22 author='Platform9', 22 author='Platform9',
@@ -46,5 +46,5 @@ setup(name='pf9-mors',
46 'nose', 46 'nose',
47 'proboscis' 47 'proboscis'
48 ], 48 ],
49 scripts=['pf9_mors.py', 'mors_manage.py'] 49 scripts=['mors/pf9_mors.py', 'mors/mors_manage.py']
50 ) 50 )
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.
15""" 15"""
16def run_tests(): 16def run_tests():
17 from proboscis import TestProgram 17 from proboscis import TestProgram
18
18 import test_api, test_persistence 19 import test_api, test_persistence
19 20
20 # Run Proboscis and exit. 21 # Run Proboscis and exit.
21 print "Starting tests ---"
22 TestProgram().run_and_exit() 22 TestProgram().run_and_exit()
23 print "Tests done ---"
24 23
25if __name__ == '__main__': 24if __name__ == '__main__':
26 print "Run tests" 25 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.
13See the License for the specific language governing permissions and 13See the License for the specific language governing permissions and
14limitations under the License. 14limitations under the License.
15""" 15"""
16from migrate.versioning.api import upgrade, create, version_control 16import ConfigParser
17import ConfigParser, os 17import os
18import requests 18import sys;
19
19import eventlet 20import eventlet
20from pf9_mors import start_server 21import requests
22from migrate.versioning.api import upgrade, version_control
23
24print sys.path
25from mors.pf9_mors import start_server
21from mors.mors_wsgi import DATE_FORMAT 26from mors.mors_wsgi import DATE_FORMAT
22import logging, sys 27import logging, sys
23from datetime import datetime, timedelta 28from datetime import datetime, timedelta
24from proboscis.asserts import assert_equal 29from proboscis.asserts import assert_equal
25from proboscis.asserts import assert_false
26from proboscis.asserts import assert_raises
27from proboscis.asserts import assert_true
28from proboscis import SkipTest
29from proboscis import test 30from proboscis import test
30import shutil 31import shutil
31from mors.leasehandler.fake_lease_handler import FakeLeaseHandler 32from 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 @@
1[tox]
2envlist = py27
3
4[testenv:py27]
5deps =
6 nose
7 proboscis
8commands =
9 python test/run_tests.py