3149d560c1
We will lose commits history for some reason, so dump the commits history as the following: db927106e7362f25384b1e7113d92538ba100f38 Remove residual oerplib dependency 42d8a04a8c66299c4c4c58643c89f043ee3b3f13 Fix import error 202937f0d8b4f3dd5f18e989a6e2dfb3a633fa8c Switch oerplib to odoorpc 2e307f84e5f8e93da67fd4c32683c246237c864d Add update-quote function 0c9d8c29ae112f9758347eba153e1fb5fed8b482 Set the correct sales team df26990838c0d7b0c6721825989706d07747e92a Support traffic billing for odoo script 2c75433a29fd5c42a2a29b41617b5fa4e42103b4 Add retry support and audit 97aadd2179496255c06f5c1c2a9368500ea74588 packaging: python-distil depends on client 021ebf0e21a6e42ed853b507fb4f16daaad14b49 Bump changelog to 0.5.10 604b906afac25c9c64862799a0d12565db2064a5 Fix network service tranform issue 956c8368435bd9ff3bba45bdde18fb72102a9d5c Skip traffic data a404539dd7d0fa2e19fd2f5536bbd0c18b3bc468 Prep for Odoo migration f10743440375cdc5512d0c4fff8b239cbdf42e0d Fix changes for Debian packaging b76536576e63848aeaa29326a0bac2cf8092e935 Bump version number and add myself to uploaders 7af68dcc4b521e5851a5f18cc647f4312bfd7fa4 fixing an error if counter volume is None f7ec36305e174cd3b1c77cf96fd9025e7774c420 Fix the multithread issue of strptime 1b16e9bfb4d5e97bd071569d3bca864d6b236cca add debian packaging 9149898015c8d4f859b316a85608bea905a3ca62 Support dynamic source 4dd95ba8be2d8d8a58bb0d6a0ba80cadfb54dd75 dropping near zero entries 766bee76234ffcf71cd0cdd13e1e3f677389390e Merge multi region in odoo-glue eddc940dbe9cdbcdf9109e3553ffe65ad80c1496 Make it free for one network and one router 2bb70fe2ecddde3b5db1fa64fc1416bc8835ee93 Don't read rates file everytime accf74e36519a116acf909cab85cd070dba998a0 version bump 7035605a9ff1e42a1120ee438dfe6de413bf2b76 fetch resource metadata in bulk when handling get_usage/get_rated. 5c6f7c0831b9560d85ce33e690c6d299470b7de8 version bump to 0.5.2 5a6233e18aa0e79bf6504f8fbe9bd04d7b4afa39 update rates 6f985422ea42f7ac545ed66e62a18760f14e3913 update odoo glue scripts for distilclient-0.5.1 api break 33c54fe6fc892d4b5621170f5e31ee9df63ed287 Tweak distilclient packaging to not require custom PYTHONPATH dc22431354ff96b02fb4def6b010575cc1f1be72 get rid of product-name-in-line-description kludge 10925492548183749cac77202d71e38291bb5440 setting up memcache 1e106cf1e012102a3cd49af543401826e67eb6a9 version bump to 0.5.0 ac29b39c629b466dcf2e04655b0491d5eb00040b Second uptime transformer for instance metric 10e37ad6b4c222efbfe0f88261ecd4fb89df93e4 adding another state to billable states 0e647ead7f6a990d279211caf2993f963372032d client: Rename some functions for clarity 7280ed585b0524c4376ef89116210f7c68ae94e4 Enable the tox for Distil 6daafca0a9f0b2a8688b9906fbea320eb4d40b2f Removing sales-order functionality from the api c12a41d5b67eb8b95abcfbc2d9eeb96cc56e8b2c version bump to 0.4.3 af86e1af31efb14ff6dac39f0c3b642fd4a4e0c4 distil: Region awareness for nova and cinder lookups bd71c7106093d2a178417f042201e8ee68ac9929 odoo: Add glue script to set current prices in distil 5a8b1596f4f08c2ea060d0da9dac844d6ae8039d odoo: Make region-aware 540eb5234f139bf9c51eb60571a81bda25cd9dd7 Import odoo-glue tree into odoo/ 8ed7c74f91d2ffd6c0b1ac50274e238f9e020502 Minor fix to tenant_validation fed3c8d4d86e09750ac3fa324bded977abe698f5 Require admin or owner bffebdf974f7e1aad210ff99040424a8f2da19f2 adding missing package depends for cinderclient 6198f1ec1fdbe0390a43571320159317e7dffa27 add toplevel Change-Id: I81581ca2aaee006daad2c1071068c651865ebb32 |
||
---|---|---|
bin | ||
client | ||
debian | ||
distil | ||
examples | ||
odoo | ||
.gitignore | ||
.gitreview | ||
client.mk | ||
Makefile | ||
README.md | ||
requirements.txt | ||
setup.cfg | ||
setup.py | ||
test-requirements.txt | ||
tox.ini |
Distil
What
Distil is a web app to provide easy interactions with ERP systems, by exposing a configurable set of collection tools and transformers to make usable billing data out of Ceilometer entries.
Distil provides a rest api to integrate with arbitrary ERP systems, and returns sales orders as json. What the ranges are, and how Ceilometer data is aggregated is intended to be configurable, and defined in the configuration file.
The Distil data store will prevent overlapping bills for a given tenant and resource ever being stored, while still allowing for regeneration of a given sales order.
Requirements:
See: requirements.txt
Configuration
Configuring Distil is handled through its primary configuration file, which defaults to: /etc/distil/conf.yaml
A base configuration is included, but must be modified appropriately. It can be located at: /examples/conf.yaml
Collection
Under collection > meter_mappings in the configs is how we define the transformers being used, and the meters mapped to them. This is the main functionality of Distil, and works as a way to make usable piece of usage data out of ceilometer samples.
We are also able to configure metadata fetching from the samples via collection > metadata_def, with the ability to pull from multiple metadata fields as the same data can be in different field names based on sample origin.
Transformers
Active transformers are currently hard coded as a dict of names to classes, but adding additional transformers is a straightforward process assuming new transformers follow the same input/output conventions of the existing ones. Once listed under the active transformers dict, they can be used and referenced in the config.
Setup
Provided all the requirements are met, a database must be created, and then setup with artifice/initdb.py
The web app itself consists of running bin/web.py with specified config, at which point you will have the app running locally at: http://0.0.0.0:8000/
Setup with Openstack environment
As mentioned, Distil relies entirely on the Ceilometer project for its metering and measurement collection.
It needs to be given admin access, and provided with the keystone endpoint in the config.
Currently it also relies on the "state" metric existing in Ceilometer, but that will be patched out later. As well as a few other pollster we've made for it.
Setup in Production
Puppet install to setup as mod_wsgi app. More details to come.
Using Distil
Distil comes with a command-line tool to provide some simple commands. These are mainly commands as accessible via the web api, and they can be used from command-line, or by importing the client module and using it in python.
IMPORTANT: Distil assumes all incoming datetimes are in UTC, conversion from local timezone must occur before passing to the api.
Web Api
The web app is a rest style api for starting usage collection, and for generating sales orders, drafts, and regenerating sales orders.
Commands
-
/collect_usage
- runs usage collection on all tenants present in Keystone
-
/sales_order
- generate a sales order for a given tenant from the last generated sales order, or the first ever usage entry.
- tenant - tenant id for a given tenant, required.
- end - end date for the sales order (yyyy-mm-dd), defaults to 00:00:00 UTC for the current date.
- generate a sales order for a given tenant from the last generated sales order, or the first ever usage entry.
-
/sales_draft
- same as generating a sales order, but does not create the sales order in the database.
- tenant - tenant id for a given tenant, required.
- end - end date for the sales order (yyyy-mm-dd or yyyy-mm-ddThh-mm-ss), defaults to now in UTC.
- same as generating a sales order, but does not create the sales order in the database.
-
/sales_historic
- regenerate a sales order for a tenant that intersects with the given date
- tenant - tenant id for a given tenant, required.
- date - target date (yyyy-mm-dd).
- regenerate a sales order for a tenant that intersects with the given date
-
/sales_range
- get all sales orders that intersect with the given range
- tenant - tenant id for a given tenant, required.
- start - start of the range (yyyy-mm-dd).
- end - end of the range (yyyy-mm-dd), defaults to now in UTC.
- get all sales orders that intersect with the given range
Client/Command-line
The client is a simple object that once given a target endpoint for the web api, provides functions that match the web api.
The command-line tool is the same, and has relatively comprehensive help text from the command-line.
Running Tests
The tests are currently expected to run with Nosetests, against a pre-provisioned database.
Future things
Eventually we also want Distil to:
- Authenticate via Keystone
- Have a public endpoint on keystone, with commands limited by user role and tenant.
- Have separate usage collection from the web app layer and a scheduler to handle it.
Things we may eventually want include:
- Alarms built on top of our hourly usage collection.
- Horizon page that builds graphs based on billing data, both past(sales order), and present (sales draft).