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
This commit is contained in:
parent
141b307f68
commit
e7fb57fee6
|
@ -0,0 +1,13 @@
|
|||
Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
|
||||
|
||||
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.
|
56
README.md
56
README.md
|
@ -1,7 +1,55 @@
|
|||
# pf9-mors
|
||||
Mors is the Roman God of death. Mors helps us implement leases.
|
||||
# Mors - OpenStack Lease Manager
|
||||
|
||||
The functionality is described here in details:
|
||||
https://platform9.atlassian.net/wiki/pages/viewpage.action?pageId=58490897
|
||||
![Mors](https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRIzc5fgaiZfJnbym_ZEx4CsZJ7qIiYjcrxth5hi80Q0IhfnxOg)
|
||||
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](https://github.com/jordansissel/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
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ sleep_seconds=60
|
|||
paste-ini=/etc/pf9/pf9-mors-api-paste.ini
|
||||
log_file=/var/log/pf9/pf9-mors.log
|
||||
repo=/opt/pf9/pf9-mors/lib/python2.7/site-packages/mors_repo
|
||||
|
||||
[nova]
|
||||
user_name=
|
||||
password=
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
"""
|
||||
Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
|
||||
|
||||
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.
|
||||
"""
|
|
@ -1,5 +1,18 @@
|
|||
# Copyright (c) 2016 Platform9 Systems Inc.
|
||||
# All Rights reserved
|
||||
"""
|
||||
Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
|
||||
|
||||
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.
|
||||
"""
|
||||
|
||||
from flask import request, jsonify
|
||||
import functools, os
|
||||
|
|
|
@ -1,4 +1,18 @@
|
|||
# Copyright Platform9 Systems Inc. 2016
|
||||
"""
|
||||
Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
|
||||
|
||||
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.
|
||||
"""
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
|
|
|
@ -1,5 +1,18 @@
|
|||
# Copyright 2016 Platform9 Systems Inc.
|
||||
"""
|
||||
Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
|
||||
|
||||
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.
|
||||
"""
|
||||
from nova_lease_handler import NovaLeaseHandler
|
||||
from fake_lease_handler import FakeLeaseHandler
|
||||
import constants
|
||||
|
|
|
@ -1,4 +1,18 @@
|
|||
# Copyright Platform9 Systems Inc. 2016
|
||||
"""
|
||||
Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
|
||||
|
||||
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.
|
||||
"""
|
||||
|
||||
SUCCESS_OK = 0
|
||||
ERR_NOT_FOUND = 1
|
||||
|
|
|
@ -1,4 +1,18 @@
|
|||
# Copyright Platform9 Systems Inc. 2016
|
||||
"""
|
||||
Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
|
||||
|
||||
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 constants
|
||||
import logging
|
||||
from datetime import datetime
|
||||
|
|
|
@ -1,4 +1,19 @@
|
|||
# Copyright 2016 Platform9 Systems Inc.
|
||||
"""
|
||||
Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
|
||||
|
||||
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.
|
||||
"""
|
||||
|
||||
from novaclient import client
|
||||
import logging
|
||||
import novaclient
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
# Copyright (c) 2016 Platform9 Systems Inc.
|
||||
# All Rights reserved
|
||||
"""
|
||||
Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
|
||||
|
||||
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.
|
||||
"""
|
||||
from flask import Flask, request, jsonify
|
||||
from lease_manager import LeaseManager
|
||||
from context_util import enforce, get_context, error_handler
|
||||
|
|
|
@ -1,5 +1,18 @@
|
|||
# Copyright Platform9 Systems Inc. 2016
|
||||
"""
|
||||
Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
|
||||
|
||||
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.
|
||||
"""
|
||||
from sqlalchemy.pool import QueuePool
|
||||
from sqlalchemy import create_engine, text
|
||||
from sqlalchemy import Table, Column, Integer, String, MetaData, DateTime
|
||||
|
|
|
@ -1,6 +1,20 @@
|
|||
#!/opt/pf9/pf9-mors/bin/python
|
||||
# Copyright (c) 2016 Platform9 Systems Inc.
|
||||
# All Rights reserved
|
||||
"""
|
||||
Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
|
||||
|
||||
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 argparse, logging
|
||||
import ConfigParser
|
||||
from migrate.versioning.api import upgrade, create, version_control
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
"""
|
||||
Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
|
||||
|
||||
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.
|
||||
"""
|
|
@ -1,4 +1,19 @@
|
|||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
|
||||
|
||||
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.
|
||||
"""
|
||||
from migrate.versioning.shell import main
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
17
pf9_mors.py
17
pf9_mors.py
|
@ -1,6 +1,19 @@
|
|||
#!/opt/pf9/pf9-mors/bin/python
|
||||
# Copyright (c) 2016 Platform9 Systems Inc.
|
||||
# All Rights reserved
|
||||
"""
|
||||
Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
|
||||
|
||||
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.
|
||||
"""
|
||||
|
||||
from paste.deploy import loadapp
|
||||
from eventlet import wsgi
|
||||
|
|
18
setup.py
18
setup.py
|
@ -1,12 +1,26 @@
|
|||
#!/usr/bin/env python
|
||||
"""
|
||||
Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
|
||||
|
||||
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.
|
||||
"""
|
||||
from setuptools import setup
|
||||
|
||||
setup(name='pf9-mors',
|
||||
version='0.1',
|
||||
description='Platform9 Mors (lease manager)',
|
||||
author='Roopak Parikh',
|
||||
author_email='rparikh@platform9.net',
|
||||
author='Platform9',
|
||||
author_email='opensource@platform9.com',
|
||||
url='https://github.com/platform9/pf9-mors',
|
||||
packages=['mors',
|
||||
'mors/leasehandler',
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
# Copyright (c) 2016 Platform9 Systems Inc.
|
||||
# All Rights reserved
|
||||
"""
|
||||
Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
|
||||
|
||||
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.
|
||||
"""
|
||||
def run_tests():
|
||||
from proboscis import TestProgram
|
||||
import test_api, test_persistence
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
# Copyright (c) 2016 Platform9 Systems Inc.
|
||||
# All Rights reserved
|
||||
"""
|
||||
Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
|
||||
|
||||
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.
|
||||
"""
|
||||
from migrate.versioning.api import upgrade, create, version_control
|
||||
import ConfigParser, os
|
||||
import requests
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
"""
|
||||
Copyright 2016 Platform9 Systems Inc.(http://www.platform9.com)
|
||||
|
||||
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.
|
||||
"""
|
||||
from proboscis import test
|
||||
from mors.persistence import DbPersistence
|
||||
import uuid
|
||||
|
|
Loading…
Reference in New Issue