diff options
author | Roopak Parikh <roopak@gmail.com> | 2016-08-02 11:21:31 -0700 |
---|---|---|
committer | Roopak Parikh <roopak@gmail.com> | 2016-08-02 11:48:25 -0700 |
commit | 3eb6c954248428e46e31c2dc6930da86229ef356 (patch) | |
tree | c446d441a951e888f0779e7dd236c97daacf9bc5 | |
parent | e7fb57fee676ab6616e6226087967b6f791f9212 (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.rst | 17 | ||||
-rw-r--r-- | README.rst | 79 | ||||
-rwxr-xr-x | doc/source/conf.py | 75 | ||||
-rw-r--r-- | doc/source/contributing.rst | 4 | ||||
-rw-r--r-- | doc/source/index.rst | 25 | ||||
-rw-r--r-- | doc/source/installation.rst | 38 | ||||
-rw-r--r-- | doc/source/readme.rst | 1 | ||||
-rw-r--r-- | doc/source/usage.rst | 5 | ||||
-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.cfg | 29 | ||||
-rw-r--r-- | setup.py | 4 | ||||
-rw-r--r-- | test/run_tests.py | 3 | ||||
-rw-r--r-- | test/test_api.py | 17 | ||||
-rw-r--r-- | tox.ini | 9 |
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 @@ | |||
1 | If you would like to contribute to the development of OpenStack, you must | ||
2 | follow the steps in this page: | ||
3 | |||
4 | http://docs.openstack.org/infra/manual/developers.html | ||
5 | |||
6 | If you already have a good understanding of how the system works and your | ||
7 | OpenStack accounts are set up, you can skip to the development workflow | ||
8 | section of this documentation to learn how changes to OpenStack should be | ||
9 | submitted for review via the Gerrit tool: | ||
10 | |||
11 | http://docs.openstack.org/infra/manual/developers.html#development-workflow | ||
12 | |||
13 | Pull requests submitted through GitHub will be ignored. | ||
14 | |||
15 | Bugs 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 @@ | |||
1 | Mors - OpenStack Lease Manager | ||
2 | ============================== | ||
3 | |||
4 | |Mors| https://en.wikipedia.org/wiki/Mors\_(mythology) is a simple lease | ||
5 | manager for OpenStack objects like Instances. | ||
6 | |||
7 | Mors is a useful tool for OpenStack based cloud used for dev, test or | ||
8 | lab setups. Typical usage in these scenarios include automatically or | ||
9 | manual creation of Instances for demo, test or experiments. In most | ||
10 | cases these Instances are forgotten and never deleted eating up valuable | ||
11 | resources. | ||
12 | |||
13 | Mors is a simple service that helps enforce a policy per Tenant or | ||
14 | Instance and automatically delete Instances after a specified duration. | ||
15 | |||
16 | Details | ||
17 | ------- | ||
18 | |||
19 | Mors works by specification of lease policy in a hierarchical fashion, | ||
20 | first at a Tenant level and further at individual Instance level. | ||
21 | |||
22 | Tenant Lease Policy | ||
23 | ~~~~~~~~~~~~~~~~~~~ | ||
24 | |||
25 | Mors lease policy can be enabled or disabled at Tenant level. If Mors | ||
26 | policy is disabled (default for each tenant) no lease policies apply to | ||
27 | the instances within that tenant. | ||
28 | |||
29 | At Tenant level, policy is specified in terms of *duration* . Once Mors | ||
30 | policy is enabled, any Instance will be deleted after | ||
31 | ``instance.created_time + tenant.lease duration = instance_expiration`` | ||
32 | |||
33 | Roles | ||
34 | ^^^^^ | ||
35 | |||
36 | Tenant leases can be viewed by user with ‘member’ role and modified by | ||
37 | users with ‘admin’ role | ||
38 | |||
39 | Instance Lease Policy | ||
40 | ~~~~~~~~~~~~~~~~~~~~~ | ||
41 | |||
42 | By default Instance leases are governed by the policies at Instance’s | ||
43 | Tenant level. As mentioned earlier: | ||
44 | ``instance.created_time + tenant.lease duration = instance_expiration`` | ||
45 | |||
46 | A member of tenant can change the Instance expiry at any time, but it | ||
47 | can never be later than now + tenant.lease duration | ||
48 | |||
49 | ``max instance lease <= now + tenant.lease duration`` | ||
50 | |||
51 | A user can always come back at a later point of time and renew the | ||
52 | release again. | ||
53 | |||
54 | Roles | ||
55 | ^^^^^ | ||
56 | |||
57 | Instance leases can be modified by both ‘member’ and ‘admin’ roles. | ||
58 | |||
59 | Build & Installation | ||
60 | -------------------- | ||
61 | |||
62 | Support subdirectory contains Makefile to build a RPM, apart from python | ||
63 | 2.7, virtualenv it needs `fpm`_, *fpm* is a simple package build utility | ||
64 | that can build both RPM and deb packages. RPM itself is a thin wrapper | ||
65 | on top of the virtualenv. | ||
66 | |||
67 | Configuration files are expected to be in /etc/pf9 directory. These are | ||
68 | usual OpenStack style config files: \* pf9-mors.ini: configure the nova | ||
69 | section with the user/password that can be used by mors to perform | ||
70 | delete operations on nova instances. The user needs to be an | ||
71 | administrator. \* pf9-mors-api-paste.ini: configure the keystone | ||
72 | middleware with keystone auth tokens. | ||
73 | |||
74 | The packages comes with an init script that works on RHEL 7 compatible | ||
75 | systems | ||
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 | |||
15 | import os | ||
16 | import sys | ||
17 | |||
18 | sys.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. | ||
23 | extensions = [ | ||
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. | ||
34 | source_suffix = '.rst' | ||
35 | |||
36 | # The master toctree document. | ||
37 | master_doc = 'index' | ||
38 | |||
39 | # General information about the project. | ||
40 | project = u'mors' | ||
41 | copyright = u'2016, OpenStack Foundation' | ||
42 | |||
43 | # If true, '()' will be appended to :func: etc. cross-reference text. | ||
44 | add_function_parentheses = True | ||
45 | |||
46 | # If true, the current module name will be prepended to all description | ||
47 | # unit titles (such as .. function::). | ||
48 | add_module_names = True | ||
49 | |||
50 | # The name of the Pygments (syntax highlighting) style to use. | ||
51 | pygments_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. | ||
62 | htmlhelp_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]). | ||
67 | latex_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 | ============ | ||
2 | Contributing | ||
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 | |||
6 | Welcome to mors's documentation! | ||
7 | ======================================================== | ||
8 | |||
9 | Contents: | ||
10 | |||
11 | .. toctree:: | ||
12 | :maxdepth: 2 | ||
13 | |||
14 | readme | ||
15 | installation | ||
16 | usage | ||
17 | contributing | ||
18 | |||
19 | Indices 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 | ============ | ||
2 | Installation | ||
3 | ============ | ||
4 | |||
5 | From PyPi | ||
6 | ~~~~~~~~~~~~~~~~~~~~~ | ||
7 | At the command line:: | ||
8 | |||
9 | $ pip install mors | ||
10 | |||
11 | Or, if you have virtualenvwrapper installed:: | ||
12 | |||
13 | $ mkvirtualenv mors | ||
14 | $ pip install mors | ||
15 | |||
16 | |||
17 | RPM BUILD | ||
18 | ~~~~~~~~~~~~~~~~~~~~~ | ||
19 | |||
20 | Mors comes with an RPM installation and associated init.d scripts. Run the makefile under 'support' directory | ||
21 | and it will produce RPM under the build directory. | ||
22 | |||
23 | Support subdirectory contains Makefile to build a RPM, apart from python | ||
24 | 2.7, virtualenv it needs `fpm`_, *fpm* is a simple package build utility | ||
25 | that can build both RPM and deb packages. RPM itself is a thin wrapper | ||
26 | on top of the virtualenv. | ||
27 | |||
28 | Configuration files are expected to be in /etc/pf9 directory. These are | ||
29 | usual OpenStack style config files: \* pf9-mors.ini: configure the nova | ||
30 | section with the user/password that can be used by mors to perform | ||
31 | delete operations on nova instances. The user needs to be an | ||
32 | administrator. \* pf9-mors-api-paste.ini: configure the keystone | ||
33 | middleware with keystone auth tokens. | ||
34 | |||
35 | The packages comes with an init script that works on RHEL 7 compatible | ||
36 | systems | ||
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 | ======== | ||
2 | Usage | ||
3 | ======== | ||
4 | |||
5 | 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 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] | ||
2 | name = mors | ||
3 | summary = OpenStack project for lease management of Instance and other OpenStack objects | ||
4 | description-file = | ||
5 | README.rst | ||
6 | author = OpenStack | ||
7 | author-email = openstack-dev@lists.openstack.org | ||
8 | home-page = http://www.openstack.org/ | ||
9 | classifier = | ||
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] | ||
19 | packages = | ||
20 | mors | ||
21 | |||
22 | [build_sphinx] | ||
23 | source-dir = doc/source | ||
24 | build-dir = doc/build | ||
25 | all_files = 1 | ||
26 | |||
27 | [upload_sphinx] | ||
28 | upload-dir = doc/build/html | ||
29 | |||
@@ -16,7 +16,7 @@ limitations under the License. | |||
16 | """ | 16 | """ |
17 | from setuptools import setup | 17 | from setuptools import setup |
18 | 18 | ||
19 | setup(name='pf9-mors', | 19 | setup(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 | """ |
16 | def run_tests(): | 16 | def 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 | ||
25 | if __name__ == '__main__': | 24 | if __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. | |||
13 | See the License for the specific language governing permissions and | 13 | See the License for the specific language governing permissions and |
14 | limitations under the License. | 14 | limitations under the License. |
15 | """ | 15 | """ |
16 | from migrate.versioning.api import upgrade, create, version_control | 16 | import ConfigParser |
17 | import ConfigParser, os | 17 | import os |
18 | import requests | 18 | import sys; |
19 | |||
19 | import eventlet | 20 | import eventlet |
20 | from pf9_mors import start_server | 21 | import requests |
22 | from migrate.versioning.api import upgrade, version_control | ||
23 | |||
24 | print sys.path | ||
25 | from mors.pf9_mors import start_server | ||
21 | from mors.mors_wsgi import DATE_FORMAT | 26 | from mors.mors_wsgi import DATE_FORMAT |
22 | import logging, sys | 27 | import logging, sys |
23 | from datetime import datetime, timedelta | 28 | from datetime import datetime, timedelta |
24 | from proboscis.asserts import assert_equal | 29 | from proboscis.asserts import assert_equal |
25 | from proboscis.asserts import assert_false | ||
26 | from proboscis.asserts import assert_raises | ||
27 | from proboscis.asserts import assert_true | ||
28 | from proboscis import SkipTest | ||
29 | from proboscis import test | 30 | from proboscis import test |
30 | import shutil | 31 | import shutil |
31 | from mors.leasehandler.fake_lease_handler import FakeLeaseHandler | 32 | from mors.leasehandler.fake_lease_handler import FakeLeaseHandler |
@@ -0,0 +1,9 @@ | |||
1 | [tox] | ||
2 | envlist = py27 | ||
3 | |||
4 | [testenv:py27] | ||
5 | deps = | ||
6 | nose | ||
7 | proboscis | ||
8 | commands = | ||
9 | python test/run_tests.py | ||