Browse Source

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
Roopak Parikh 2 years ago
parent
commit
e7fb57fee6

+ 13
- 0
LICENSE.md View File

@@ -0,0 +1,13 @@
1
+Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
2
+
3
+Licensed under the Apache License, Version 2.0 (the "License");
4
+you may not use this file except in compliance with the License.
5
+You may obtain a copy of the License at
6
+
7
+    http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+Unless required by applicable law or agreed to in writing, software
10
+distributed under the License is distributed on an "AS IS" BASIS,
11
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+See the License for the specific language governing permissions and
13
+limitations under the License.

+ 52
- 4
README.md View File

@@ -1,7 +1,55 @@
1
-# pf9-mors
2
-Mors is the Roman God of death. Mors helps us implement leases.
1
+# Mors - OpenStack Lease Manager
3 2
 
4
-The functionality is described here in details:
5
-https://platform9.atlassian.net/wiki/pages/viewpage.action?pageId=58490897
3
+![Mors](https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRIzc5fgaiZfJnbym_ZEx4CsZJ7qIiYjcrxth5hi80Q0IhfnxOg)
4
+https://en.wikipedia.org/wiki/Mors_(mythology) 
5
+is a simple lease manager for OpenStack objects like Instances.
6 6
 
7
+Mors is a useful tool for OpenStack based cloud used for dev, test or lab setups.
8
+Typical usage in these scenarios include automatically or manual creation of Instances for demo, test or experiments.
9
+In most cases these Instances are forgotten and never deleted eating up valuable resources.
10
+
11
+Mors is a simple service that helps enforce a policy per Tenant or Instance and automatically delete Instances after
12
+a specified duration.
13
+
14
+
15
+## Details
16
+
17
+Mors works by specification of lease policy in a hierarchical fashion, first at a Tenant level and further at
18
+individual Instance level.
19
+
20
+### Tenant Lease Policy
21
+
22
+Mors lease policy can be enabled or disabled at Tenant level. If Mors policy is disabled (default for each tenant)
23
+no lease policies apply to the instances within that tenant.
24
+
25
+At Tenant level, policy is specified in terms of _duration_ . Once Mors policy is enabled, any Instance will be deleted
26
+after `instance.created_time + tenant.lease duration = instance_expiration`
27
+
28
+#### Roles
29
+Tenant leases can be viewed by user with 'member' role and modified by users with 'admin' role
30
+
31
+### Instance Lease Policy
32
+
33
+By 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
+
36
+A 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
+ 
40
+A user can always come back at a later point of time and renew the release again.
41
+
42
+#### Roles
43
+Instance leases can be modified by both 'member' and 'admin' roles.
44
+
45
+## Build & Installation
46
+Support subdirectory contains Makefile to build a RPM, apart from python 2.7, virtualenv it needs [fpm](https://github.com/jordansissel/fpm), _fpm_
47
+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.
48
+
49
+Configuration 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
+
54
+The packages comes with an init script that works on RHEL 7 compatible systems
7 55
 

+ 1
- 0
etc/pf9/pf9-mors.ini View File

@@ -7,6 +7,7 @@ sleep_seconds=60
7 7
 paste-ini=/etc/pf9/pf9-mors-api-paste.ini
8 8
 log_file=/var/log/pf9/pf9-mors.log
9 9
 repo=/opt/pf9/pf9-mors/lib/python2.7/site-packages/mors_repo
10
+
10 11
 [nova]
11 12
 user_name=
12 13
 password=

+ 15
- 0
mors/__init__.py View File

@@ -0,0 +1,15 @@
1
+"""
2
+Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
3
+
4
+Licensed under the Apache License, Version 2.0 (the "License");
5
+you may not use this file except in compliance with the License.
6
+You may obtain a copy of the License at
7
+
8
+    http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+Unless required by applicable law or agreed to in writing, software
11
+distributed under the License is distributed on an "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+See the License for the specific language governing permissions and
14
+limitations under the License.
15
+"""

+ 15
- 2
mors/context_util.py View File

@@ -1,5 +1,18 @@
1
-# Copyright (c) 2016 Platform9 Systems Inc.
2
-# All Rights reserved
1
+"""
2
+Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
3
+
4
+Licensed under the Apache License, Version 2.0 (the "License");
5
+you may not use this file except in compliance with the License.
6
+You may obtain a copy of the License at
7
+
8
+    http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+Unless required by applicable law or agreed to in writing, software
11
+distributed under the License is distributed on an "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+See the License for the specific language governing permissions and
14
+limitations under the License.
15
+"""
3 16
 
4 17
 from flask import request, jsonify
5 18
 import functools, os

+ 15
- 1
mors/lease_manager.py View File

@@ -1,4 +1,18 @@
1
-# Copyright Platform9 Systems Inc. 2016
1
+"""
2
+Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
3
+
4
+Licensed under the Apache License, Version 2.0 (the "License");
5
+you may not use this file except in compliance with the License.
6
+You may obtain a copy of the License at
7
+
8
+    http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+Unless required by applicable law or agreed to in writing, software
11
+distributed under the License is distributed on an "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+See the License for the specific language governing permissions and
14
+limitations under the License.
15
+"""
2 16
 
3 17
 from datetime import datetime, timedelta
4 18
 

+ 14
- 1
mors/leasehandler/__init__.py View File

@@ -1,5 +1,18 @@
1
-# Copyright 2016 Platform9 Systems Inc.
1
+"""
2
+Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
2 3
 
4
+Licensed under the Apache License, Version 2.0 (the "License");
5
+you may not use this file except in compliance with the License.
6
+You may obtain a copy of the License at
7
+
8
+    http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+Unless required by applicable law or agreed to in writing, software
11
+distributed under the License is distributed on an "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+See the License for the specific language governing permissions and
14
+limitations under the License.
15
+"""
3 16
 from nova_lease_handler import NovaLeaseHandler
4 17
 from fake_lease_handler import FakeLeaseHandler
5 18
 import constants

+ 15
- 1
mors/leasehandler/constants.py View File

@@ -1,4 +1,18 @@
1
-# Copyright Platform9 Systems Inc. 2016
1
+"""
2
+Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
3
+
4
+Licensed under the Apache License, Version 2.0 (the "License");
5
+you may not use this file except in compliance with the License.
6
+You may obtain a copy of the License at
7
+
8
+    http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+Unless required by applicable law or agreed to in writing, software
11
+distributed under the License is distributed on an "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+See the License for the specific language governing permissions and
14
+limitations under the License.
15
+"""
2 16
 
3 17
 SUCCESS_OK = 0
4 18
 ERR_NOT_FOUND = 1

+ 15
- 1
mors/leasehandler/fake_lease_handler.py View File

@@ -1,4 +1,18 @@
1
-# Copyright Platform9 Systems Inc. 2016
1
+"""
2
+Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
3
+
4
+Licensed under the Apache License, Version 2.0 (the "License");
5
+you may not use this file except in compliance with the License.
6
+You may obtain a copy of the License at
7
+
8
+    http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+Unless required by applicable law or agreed to in writing, software
11
+distributed under the License is distributed on an "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+See the License for the specific language governing permissions and
14
+limitations under the License.
15
+"""
2 16
 import constants
3 17
 import logging
4 18
 from datetime import datetime

+ 16
- 1
mors/leasehandler/nova_lease_handler.py View File

@@ -1,4 +1,19 @@
1
-# Copyright 2016 Platform9 Systems Inc.
1
+"""
2
+Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
3
+
4
+Licensed under the Apache License, Version 2.0 (the "License");
5
+you may not use this file except in compliance with the License.
6
+You may obtain a copy of the License at
7
+
8
+    http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+Unless required by applicable law or agreed to in writing, software
11
+distributed under the License is distributed on an "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+See the License for the specific language governing permissions and
14
+limitations under the License.
15
+"""
16
+
2 17
 from novaclient import client
3 18
 import logging
4 19
 import novaclient

+ 14
- 2
mors/mors_wsgi.py View File

@@ -1,6 +1,18 @@
1
-# Copyright (c) 2016 Platform9 Systems Inc.
2
-# All Rights reserved
1
+"""
2
+Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
3 3
 
4
+Licensed under the Apache License, Version 2.0 (the "License");
5
+you may not use this file except in compliance with the License.
6
+You may obtain a copy of the License at
7
+
8
+    http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+Unless required by applicable law or agreed to in writing, software
11
+distributed under the License is distributed on an "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+See the License for the specific language governing permissions and
14
+limitations under the License.
15
+"""
4 16
 from flask import Flask, request, jsonify
5 17
 from lease_manager import LeaseManager
6 18
 from context_util import enforce, get_context, error_handler

+ 14
- 1
mors/persistence.py View File

@@ -1,5 +1,18 @@
1
-# Copyright Platform9 Systems Inc. 2016
1
+"""
2
+Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
2 3
 
4
+Licensed under the Apache License, Version 2.0 (the "License");
5
+you may not use this file except in compliance with the License.
6
+You may obtain a copy of the License at
7
+
8
+    http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+Unless required by applicable law or agreed to in writing, software
11
+distributed under the License is distributed on an "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+See the License for the specific language governing permissions and
14
+limitations under the License.
15
+"""
3 16
 from sqlalchemy.pool import QueuePool
4 17
 from sqlalchemy import create_engine, text
5 18
 from sqlalchemy import Table, Column, Integer, String, MetaData, DateTime

+ 16
- 2
mors_manage.py View File

@@ -1,6 +1,20 @@
1 1
 #!/opt/pf9/pf9-mors/bin/python
2
-# Copyright (c) 2016 Platform9 Systems Inc.
3
-# All Rights reserved
2
+"""
3
+Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
4
+
5
+Licensed under the Apache License, Version 2.0 (the "License");
6
+you may not use this file except in compliance with the License.
7
+You may obtain a copy of the License at
8
+
9
+    http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+Unless required by applicable law or agreed to in writing, software
12
+distributed under the License is distributed on an "AS IS" BASIS,
13
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+See the License for the specific language governing permissions and
15
+limitations under the License.
16
+"""
17
+
4 18
 import argparse, logging
5 19
 import ConfigParser
6 20
 from migrate.versioning.api import upgrade, create, version_control

+ 15
- 0
mors_repo/__init__.py View File

@@ -0,0 +1,15 @@
1
+"""
2
+Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
3
+
4
+Licensed under the Apache License, Version 2.0 (the "License");
5
+you may not use this file except in compliance with the License.
6
+You may obtain a copy of the License at
7
+
8
+    http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+Unless required by applicable law or agreed to in writing, software
11
+distributed under the License is distributed on an "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+See the License for the specific language governing permissions and
14
+limitations under the License.
15
+"""

+ 15
- 0
mors_repo/manage.py View File

@@ -1,4 +1,19 @@
1 1
 #!/usr/bin/env python
2
+"""
3
+Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
4
+
5
+Licensed under the Apache License, Version 2.0 (the "License");
6
+you may not use this file except in compliance with the License.
7
+You may obtain a copy of the License at
8
+
9
+    http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+Unless required by applicable law or agreed to in writing, software
12
+distributed under the License is distributed on an "AS IS" BASIS,
13
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+See the License for the specific language governing permissions and
15
+limitations under the License.
16
+"""
2 17
 from migrate.versioning.shell import main
3 18
 
4 19
 if __name__ == '__main__':

+ 15
- 2
pf9_mors.py View File

@@ -1,6 +1,19 @@
1 1
 #!/opt/pf9/pf9-mors/bin/python
2
-# Copyright (c) 2016 Platform9 Systems Inc.
3
-# All Rights reserved
2
+"""
3
+Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
4
+
5
+Licensed under the Apache License, Version 2.0 (the "License");
6
+you may not use this file except in compliance with the License.
7
+You may obtain a copy of the License at
8
+
9
+    http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+Unless required by applicable law or agreed to in writing, software
12
+distributed under the License is distributed on an "AS IS" BASIS,
13
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+See the License for the specific language governing permissions and
15
+limitations under the License.
16
+"""
4 17
 
5 18
 from paste.deploy import loadapp
6 19
 from eventlet import wsgi

+ 16
- 2
setup.py View File

@@ -1,12 +1,26 @@
1 1
 #!/usr/bin/env python
2
+"""
3
+Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
2 4
 
5
+Licensed under the Apache License, Version 2.0 (the "License");
6
+you may not use this file except in compliance with the License.
7
+You may obtain a copy of the License at
8
+
9
+    http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+Unless required by applicable law or agreed to in writing, software
12
+distributed under the License is distributed on an "AS IS" BASIS,
13
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+See the License for the specific language governing permissions and
15
+limitations under the License.
16
+"""
3 17
 from setuptools import setup
4 18
 
5 19
 setup(name='pf9-mors',
6 20
       version='0.1',
7 21
       description='Platform9 Mors (lease manager)',
8
-      author='Roopak Parikh',
9
-      author_email='rparikh@platform9.net',
22
+      author='Platform9',
23
+      author_email='opensource@platform9.com',
10 24
       url='https://github.com/platform9/pf9-mors',
11 25
       packages=['mors',
12 26
                 'mors/leasehandler',

+ 14
- 2
test/run_tests.py View File

@@ -1,6 +1,18 @@
1
-# Copyright (c) 2016 Platform9 Systems Inc.
2
-# All Rights reserved
1
+"""
2
+Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
3 3
 
4
+Licensed under the Apache License, Version 2.0 (the "License");
5
+you may not use this file except in compliance with the License.
6
+You may obtain a copy of the License at
7
+
8
+    http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+Unless required by applicable law or agreed to in writing, software
11
+distributed under the License is distributed on an "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+See the License for the specific language governing permissions and
14
+limitations under the License.
15
+"""
4 16
 def run_tests():
5 17
     from proboscis import TestProgram
6 18
     import test_api, test_persistence

+ 14
- 2
test/test_api.py View File

@@ -1,6 +1,18 @@
1
-# Copyright (c) 2016 Platform9 Systems Inc.
2
-# All Rights reserved
1
+"""
2
+Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
3 3
 
4
+Licensed under the Apache License, Version 2.0 (the "License");
5
+you may not use this file except in compliance with the License.
6
+You may obtain a copy of the License at
7
+
8
+    http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+Unless required by applicable law or agreed to in writing, software
11
+distributed under the License is distributed on an "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+See the License for the specific language governing permissions and
14
+limitations under the License.
15
+"""
4 16
 from migrate.versioning.api import upgrade, create, version_control
5 17
 import ConfigParser, os
6 18
 import requests

+ 15
- 0
test/test_persistence.py View File

@@ -1,3 +1,18 @@
1
+"""
2
+Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
3
+
4
+Licensed under the Apache License, Version 2.0 (the "License");
5
+you may not use this file except in compliance with the License.
6
+You may obtain a copy of the License at
7
+
8
+    http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+Unless required by applicable law or agreed to in writing, software
11
+distributed under the License is distributed on an "AS IS" BASIS,
12
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+See the License for the specific language governing permissions and
14
+limitations under the License.
15
+"""
1 16
 from proboscis import test
2 17
 from mors.persistence import DbPersistence
3 18
 import uuid

Loading…
Cancel
Save