Almanach stores the utilization of OpenStack resources (instances and volumes) for each tenant.
The main purpose of this software is to bill customers based on their usage of the cloud infrastructure.
Almanach is composed of two parts:
- Collector: Listen for OpenStack events and store the relevant information in the database.
- REST API: Expose the information collected to external systems.
- OpenStack infrastructure installed (Nova, Cinder...)
- MongoDB
- Python 2.7
Usage:
usage: almanach [-h] [--logging LOGGING] {api,collector} config_fileStart the API daemon:
almanach api /path/to/almanach.cfgStart the collector:
almanach collector /path/to/almanach.cfgCustom logging configuration:
almanach collector /path/to/almanach.cfg --logging /path/to/logging.cfgThe syntax of the logging configuration file is available in the official Python documentation.
The authentication mechanism use the HTTP header X-Auth-Token to send a token.
This token is validated through Keystone or with the config file (private secret key).
GET /volume_types HTTP/1.1
X-Auth-Token: secret
Content-Type: application/json
{}
If the token is not valid, you will receive a 401 Not Authorized response.
The private secret key authentication is the default method.
In your config file, you have to define your private key in the field auth_token:
[ALMANACH]
auth_token=my secret token
The token will be validated with Keystone.
To use this authentication backend you have to define the authentication strategy to keystone.
[ALMANACH]
auth_strategy=keystone
[KEYSTONE]
username=my_service_username
password=my_service_password
tenant_name=my_service_tenant_name
auth_url=http://keystone_url:5000/v2.0
You can override the configuration parameters by using environment variables:
export RABBITMQ_URL="amqp://openstack:openstack@hostname:5672"
almanach collector /path/to/almanach.cfgThe actual Docker configuration assume that you already have RabbitMQ (mandatory for Openstack) and MongoDB configured for Almanach.
export RABBITMQ_URL="amqp://guest:guest@messaging:5672/"
export MONGODB_URL="mongodb://almanach:almanach@database:27017/almanach"
docker-compose build
docker-compose upThe command docker-compose up starts 2 containers: the collector and the API server.
The environment variables RABBITMQ_URL and MONGODB_URL are mandatory.
Each OpenStack services (Nova, Cinder, Neutron) need to be configured to send notifications to the Almanach queue.
For example with Nova, add the topic "almanach" in the config file /etc/nova.conf:
notification_topics=almanachAlmanach requires a specific user to connect to the database. To create a new user, open a new MongoDB shell:
m = new Mongo()
m.getDB("almanach").createUser({user: "almanach", pwd: "almanach", roles: [{role: "readWrite", db: "almanach"}]})Each entity have at least these properties:
entity_id: Unique id for the entity (UUID)entity_type: "instance" or "volume"project_id: Tenant unique ID (UUID)start: Start date of the resource usageend: End date of the resource usage ornullif the resource still in use by the tenantname: Resource name
{
"entity_id": "UUID",
"entity_type": "instance",
"project_id": "UUID",
"start": "2014-01-01T06:00:00.000Z",
"end": null,
"last_event": "2014-01-01T06:00:00.000Z",
"flavor": "MyFlavor1",
"os": {
"distro": "ubuntu",
"version": "14.04"
},
"name": "my-virtual-machine.domain.tld"
}{
"entity_id": "UUID",
"entity_type": "volume",
"project_id": "UUID",
"start": "2014-01-01T06:00:00.000Z",
"end": null,
"last_event": "2014-01-01T06:00:00.000Z",
"volume_type": "MyVolumeType",
"size": 50,
"name": "my-virtual-machine.domain.tld-volume",
"attached_to": "UUID"
}Almanach will process those events:
compute.instance.create.endcompute.instance.delete.endcompute.instance.resize.confirm.endcompute.instance.rebuild.endvolume.create.endvolume.delete.endvolume.resize.endvolume.attach.endvolume.detach.endvolume.update.endvolume.existsvolume_type.create
Almanach is distributed under Apache 2.0 LICENSE.