summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoopak Parikh <roopak@gmail.com>2016-07-08 11:50:34 -0700
committerRoopak Parikh <roopak@gmail.com>2016-07-08 12:06:42 -0700
commite7fb57fee676ab6616e6226087967b6f791f9212 (patch)
tree16cfb365256b4a4122b98c9192a964ca5792d9da
parent141b307f68bf645c712128cd18b151e7a4c0770a (diff)
Preparing for OpenSource of Mors
Added: - License.md with Apache 2 license - Added license header to all the python files - Added a better readme with an overview of functionality & installation
-rw-r--r--LICENSE.md13
-rw-r--r--README.md56
-rw-r--r--etc/pf9/pf9-mors.ini1
-rw-r--r--mors/__init__.py15
-rw-r--r--mors/context_util.py17
-rw-r--r--mors/lease_manager.py16
-rw-r--r--mors/leasehandler/__init__.py15
-rw-r--r--mors/leasehandler/constants.py16
-rw-r--r--mors/leasehandler/fake_lease_handler.py16
-rw-r--r--mors/leasehandler/nova_lease_handler.py17
-rw-r--r--mors/mors_wsgi.py16
-rw-r--r--mors/persistence.py15
-rw-r--r--mors_manage.py18
-rw-r--r--mors_repo/__init__.py15
-rw-r--r--mors_repo/manage.py15
-rw-r--r--pf9_mors.py17
-rw-r--r--setup.py18
-rw-r--r--test/run_tests.py16
-rw-r--r--test/test_api.py16
-rw-r--r--test/test_persistence.py15
20 files changed, 319 insertions, 24 deletions
diff --git a/LICENSE.md b/LICENSE.md
new file mode 100644
index 0000000..8909b43
--- /dev/null
+++ b/LICENSE.md
@@ -0,0 +1,13 @@
1Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License. \ No newline at end of file
diff --git a/README.md b/README.md
index 9df5164..0946275 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,55 @@
1# pf9-mors 1# Mors - OpenStack Lease Manager
2Mors is the Roman God of death. Mors helps us implement leases.
3 2
4The functionality is described here in details: 3![Mors](https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRIzc5fgaiZfJnbym_ZEx4CsZJ7qIiYjcrxth5hi80Q0IhfnxOg)
5https://platform9.atlassian.net/wiki/pages/viewpage.action?pageId=58490897 4https://en.wikipedia.org/wiki/Mors_(mythology)
5is a simple lease manager for OpenStack objects like Instances.
6 6
7Mors is a useful tool for OpenStack based cloud used for dev, test or lab setups.
8Typical usage in these scenarios include automatically or manual creation of Instances for demo, test or experiments.
9In most cases these Instances are forgotten and never deleted eating up valuable resources.
10
11Mors is a simple service that helps enforce a policy per Tenant or Instance and automatically delete Instances after
12a specified duration.
13
14
15## Details
16
17Mors works by specification of lease policy in a hierarchical fashion, first at a Tenant level and further at
18individual Instance level.
19
20### Tenant Lease Policy
21
22Mors lease policy can be enabled or disabled at Tenant level. If Mors policy is disabled (default for each tenant)
23no lease policies apply to the instances within that tenant.
24
25At Tenant level, policy is specified in terms of _duration_ . Once Mors policy is enabled, any Instance will be deleted
26after `instance.created_time + tenant.lease duration = instance_expiration`
27
28#### Roles
29Tenant leases can be viewed by user with 'member' role and modified by users with 'admin' role
30
31### Instance Lease Policy
32
33By default Instance leases are governed by the policies at Instance's Tenant level. As mentioned earlier:
34 `instance.created_time + tenant.lease duration = instance_expiration`
35
36A member of tenant can change the Instance expiry at any time, but it can never be later than now + tenant.lease duration
37
38 `max instance lease <= now + tenant.lease duration`
39
40A user can always come back at a later point of time and renew the release again.
41
42#### Roles
43Instance leases can be modified by both 'member' and 'admin' roles.
44
45## Build & Installation
46Support subdirectory contains Makefile to build a RPM, apart from python 2.7, virtualenv it needs [fpm](https://github.com/jordansissel/fpm), _fpm_
47is a simple package build utility that can build both RPM and deb packages. RPM itself is a thin wrapper on top of the virtualenv.
48
49Configuration files are expected to be in /etc/pf9 directory. These are usual OpenStack style config files:
50* pf9-mors.ini: configure the nova section with the user/password that can be used by mors to perform delete operations on nova instances.
51 The user needs to be an administrator.
52* pf9-mors-api-paste.ini: configure the keystone middleware with keystone auth tokens.
53
54The packages comes with an init script that works on RHEL 7 compatible systems
7 55
diff --git a/etc/pf9/pf9-mors.ini b/etc/pf9/pf9-mors.ini
index 18cf4b0..943a057 100644
--- a/etc/pf9/pf9-mors.ini
+++ b/etc/pf9/pf9-mors.ini
@@ -7,6 +7,7 @@ sleep_seconds=60
7paste-ini=/etc/pf9/pf9-mors-api-paste.ini 7paste-ini=/etc/pf9/pf9-mors-api-paste.ini
8log_file=/var/log/pf9/pf9-mors.log 8log_file=/var/log/pf9/pf9-mors.log
9repo=/opt/pf9/pf9-mors/lib/python2.7/site-packages/mors_repo 9repo=/opt/pf9/pf9-mors/lib/python2.7/site-packages/mors_repo
10
10[nova] 11[nova]
11user_name= 12user_name=
12password= 13password=
diff --git a/mors/__init__.py b/mors/__init__.py
index e69de29..a343161 100644
--- a/mors/__init__.py
+++ b/mors/__init__.py
@@ -0,0 +1,15 @@
1"""
2Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15""" \ No newline at end of file
diff --git a/mors/context_util.py b/mors/context_util.py
index 1a1e82f..6c3e8e3 100644
--- a/mors/context_util.py
+++ b/mors/context_util.py
@@ -1,5 +1,18 @@
1# Copyright (c) 2016 Platform9 Systems Inc. 1"""
2# All Rights reserved 2Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15"""
3 16
4from flask import request, jsonify 17from flask import request, jsonify
5import functools, os 18import functools, os
diff --git a/mors/lease_manager.py b/mors/lease_manager.py
index b52c60e..5153880 100644
--- a/mors/lease_manager.py
+++ b/mors/lease_manager.py
@@ -1,4 +1,18 @@
1# Copyright Platform9 Systems Inc. 2016 1"""
2Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15"""
2 16
3from datetime import datetime, timedelta 17from datetime import datetime, timedelta
4 18
diff --git a/mors/leasehandler/__init__.py b/mors/leasehandler/__init__.py
index e353ef6..2cb6657 100644
--- a/mors/leasehandler/__init__.py
+++ b/mors/leasehandler/__init__.py
@@ -1,5 +1,18 @@
1# Copyright 2016 Platform9 Systems Inc. 1"""
2Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
2 3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15"""
3from nova_lease_handler import NovaLeaseHandler 16from nova_lease_handler import NovaLeaseHandler
4from fake_lease_handler import FakeLeaseHandler 17from fake_lease_handler import FakeLeaseHandler
5import constants 18import constants
diff --git a/mors/leasehandler/constants.py b/mors/leasehandler/constants.py
index 85d0e24..7f1f943 100644
--- a/mors/leasehandler/constants.py
+++ b/mors/leasehandler/constants.py
@@ -1,4 +1,18 @@
1# Copyright Platform9 Systems Inc. 2016 1"""
2Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15"""
2 16
3SUCCESS_OK = 0 17SUCCESS_OK = 0
4ERR_NOT_FOUND = 1 18ERR_NOT_FOUND = 1
diff --git a/mors/leasehandler/fake_lease_handler.py b/mors/leasehandler/fake_lease_handler.py
index 2d69e12..4d04ccb 100644
--- a/mors/leasehandler/fake_lease_handler.py
+++ b/mors/leasehandler/fake_lease_handler.py
@@ -1,4 +1,18 @@
1# Copyright Platform9 Systems Inc. 2016 1"""
2Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15"""
2import constants 16import constants
3import logging 17import logging
4from datetime import datetime 18from datetime import datetime
diff --git a/mors/leasehandler/nova_lease_handler.py b/mors/leasehandler/nova_lease_handler.py
index 90e8a92..04324a8 100644
--- a/mors/leasehandler/nova_lease_handler.py
+++ b/mors/leasehandler/nova_lease_handler.py
@@ -1,4 +1,19 @@
1# Copyright 2016 Platform9 Systems Inc. 1"""
2Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15"""
16
2from novaclient import client 17from novaclient import client
3import logging 18import logging
4import novaclient 19import novaclient
diff --git a/mors/mors_wsgi.py b/mors/mors_wsgi.py
index 9ffe460..75bcd20 100644
--- a/mors/mors_wsgi.py
+++ b/mors/mors_wsgi.py
@@ -1,6 +1,18 @@
1# Copyright (c) 2016 Platform9 Systems Inc. 1"""
2# All Rights reserved 2Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
3 3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15"""
4from flask import Flask, request, jsonify 16from flask import Flask, request, jsonify
5from lease_manager import LeaseManager 17from lease_manager import LeaseManager
6from context_util import enforce, get_context, error_handler 18from context_util import enforce, get_context, error_handler
diff --git a/mors/persistence.py b/mors/persistence.py
index c439508..7677049 100644
--- a/mors/persistence.py
+++ b/mors/persistence.py
@@ -1,5 +1,18 @@
1# Copyright Platform9 Systems Inc. 2016 1"""
2Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
2 3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15"""
3from sqlalchemy.pool import QueuePool 16from sqlalchemy.pool import QueuePool
4from sqlalchemy import create_engine, text 17from sqlalchemy import create_engine, text
5from sqlalchemy import Table, Column, Integer, String, MetaData, DateTime 18from sqlalchemy import Table, Column, Integer, String, MetaData, DateTime
diff --git a/mors_manage.py b/mors_manage.py
index a6042bd..d0bf6a9 100644
--- a/mors_manage.py
+++ b/mors_manage.py
@@ -1,6 +1,20 @@
1#!/opt/pf9/pf9-mors/bin/python 1#!/opt/pf9/pf9-mors/bin/python
2# Copyright (c) 2016 Platform9 Systems Inc. 2"""
3# All Rights reserved 3Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
4
5Licensed under the Apache License, Version 2.0 (the "License");
6you may not use this file except in compliance with the License.
7You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11Unless required by applicable law or agreed to in writing, software
12distributed under the License is distributed on an "AS IS" BASIS,
13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14See the License for the specific language governing permissions and
15limitations under the License.
16"""
17
4import argparse, logging 18import argparse, logging
5import ConfigParser 19import ConfigParser
6from migrate.versioning.api import upgrade, create, version_control 20from migrate.versioning.api import upgrade, create, version_control
diff --git a/mors_repo/__init__.py b/mors_repo/__init__.py
index e69de29..a343161 100644
--- a/mors_repo/__init__.py
+++ b/mors_repo/__init__.py
@@ -0,0 +1,15 @@
1"""
2Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15""" \ No newline at end of file
diff --git a/mors_repo/manage.py b/mors_repo/manage.py
index 39fa389..a07ad60 100644
--- a/mors_repo/manage.py
+++ b/mors_repo/manage.py
@@ -1,4 +1,19 @@
1#!/usr/bin/env python 1#!/usr/bin/env python
2"""
3Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
4
5Licensed under the Apache License, Version 2.0 (the "License");
6you may not use this file except in compliance with the License.
7You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11Unless required by applicable law or agreed to in writing, software
12distributed under the License is distributed on an "AS IS" BASIS,
13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14See the License for the specific language governing permissions and
15limitations under the License.
16"""
2from migrate.versioning.shell import main 17from migrate.versioning.shell import main
3 18
4if __name__ == '__main__': 19if __name__ == '__main__':
diff --git a/pf9_mors.py b/pf9_mors.py
index 86331cd..eb5b9a4 100644
--- a/pf9_mors.py
+++ b/pf9_mors.py
@@ -1,6 +1,19 @@
1#!/opt/pf9/pf9-mors/bin/python 1#!/opt/pf9/pf9-mors/bin/python
2# Copyright (c) 2016 Platform9 Systems Inc. 2"""
3# All Rights reserved 3Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
4
5Licensed under the Apache License, Version 2.0 (the "License");
6you may not use this file except in compliance with the License.
7You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11Unless required by applicable law or agreed to in writing, software
12distributed under the License is distributed on an "AS IS" BASIS,
13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14See the License for the specific language governing permissions and
15limitations under the License.
16"""
4 17
5from paste.deploy import loadapp 18from paste.deploy import loadapp
6from eventlet import wsgi 19from eventlet import wsgi
diff --git a/setup.py b/setup.py
index f2b2c55..afcd524 100644
--- a/setup.py
+++ b/setup.py
@@ -1,12 +1,26 @@
1#!/usr/bin/env python 1#!/usr/bin/env python
2"""
3Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
2 4
5Licensed under the Apache License, Version 2.0 (the "License");
6you may not use this file except in compliance with the License.
7You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11Unless required by applicable law or agreed to in writing, software
12distributed under the License is distributed on an "AS IS" BASIS,
13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14See the License for the specific language governing permissions and
15limitations under the License.
16"""
3from setuptools import setup 17from setuptools import setup
4 18
5setup(name='pf9-mors', 19setup(name='pf9-mors',
6 version='0.1', 20 version='0.1',
7 description='Platform9 Mors (lease manager)', 21 description='Platform9 Mors (lease manager)',
8 author='Roopak Parikh', 22 author='Platform9',
9 author_email='rparikh@platform9.net', 23 author_email='opensource@platform9.com',
10 url='https://github.com/platform9/pf9-mors', 24 url='https://github.com/platform9/pf9-mors',
11 packages=['mors', 25 packages=['mors',
12 'mors/leasehandler', 26 'mors/leasehandler',
diff --git a/test/run_tests.py b/test/run_tests.py
index eeed199..0ce0947 100644
--- a/test/run_tests.py
+++ b/test/run_tests.py
@@ -1,6 +1,18 @@
1# Copyright (c) 2016 Platform9 Systems Inc. 1"""
2# All Rights reserved 2Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
3 3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15"""
4def run_tests(): 16def run_tests():
5 from proboscis import TestProgram 17 from proboscis import TestProgram
6 import test_api, test_persistence 18 import test_api, test_persistence
diff --git a/test/test_api.py b/test/test_api.py
index 076707f..0b643fd 100644
--- a/test/test_api.py
+++ b/test/test_api.py
@@ -1,6 +1,18 @@
1# Copyright (c) 2016 Platform9 Systems Inc. 1"""
2# All Rights reserved 2Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
3 3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15"""
4from migrate.versioning.api import upgrade, create, version_control 16from migrate.versioning.api import upgrade, create, version_control
5import ConfigParser, os 17import ConfigParser, os
6import requests 18import requests
diff --git a/test/test_persistence.py b/test/test_persistence.py
index e1de110..af584ff 100644
--- a/test/test_persistence.py
+++ b/test/test_persistence.py
@@ -1,3 +1,18 @@
1"""
2Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15"""
1from proboscis import test 16from proboscis import test
2from mors.persistence import DbPersistence 17from mors.persistence import DbPersistence
3import uuid 18import uuid