Working deb install on Devstack
This commit is contained in:
parent
164139067a
commit
00bf9fc0a2
23
README.md
23
README.md
@ -28,11 +28,14 @@ Artifice requires:
|
||||
* pyaml
|
||||
* mock
|
||||
* requests
|
||||
*
|
||||
* sqlalchemy >= 0.8.0
|
||||
* OpenStack Grizzly. *currently untested with Havana*
|
||||
* Openstack-Keystone
|
||||
* Openstack-Ceilometer
|
||||
|
||||
Despite using SQLAlchemy, Artifice does NOT currently support SQLite or MySQL. Instead, it takes advantage of range exclusive
|
||||
columns in Postgres, which is not supported on other systems.
|
||||
|
||||
## Configuration
|
||||
|
||||
Configuring Artifice is handled through its primary configuration file, stored in `/etc/openstack/artifice.conf`.
|
||||
@ -45,7 +48,7 @@ This is a yaml-format config file, in the format of:
|
||||
database: artifice
|
||||
host: localhost
|
||||
password: aurynn
|
||||
port: '5433'
|
||||
port: '5432'
|
||||
username: aurynn
|
||||
# Configuration passed to the invoice system. This is an arbitrary dictionary
|
||||
# and may be anything that the invoice object may require.
|
||||
@ -135,6 +138,22 @@ Actions one can perform with Artifice are:
|
||||
* *usage*
|
||||
|
||||
|
||||
## Running Tests
|
||||
|
||||
The tests are currently expected to run with Nosetests, against a pre-provisioned database.
|
||||
|
||||
### Expected environment
|
||||
|
||||
The test environment expects that the *DATABASE_URL* envar will be populated.
|
||||
*DATABASE_URL* **must** be populated in the form:
|
||||
|
||||
export DATABASE_URL=postgres://user:password@server/database
|
||||
|
||||
|
||||
Provisioning the database is handled via:
|
||||
|
||||
|
||||
|
||||
### Future things
|
||||
|
||||
Eventually we also want Artifice to:
|
||||
|
10
bin/bill.py
10
bin/bill.py
@ -20,7 +20,7 @@ import yaml
|
||||
date_format = "%Y-%m-%dT%H:%M:%S"
|
||||
other_date_format = "%Y-%m-%dT%H:%M:%S.%f"
|
||||
|
||||
date_fmt_fnc = lambda x: datetime.datetime.strptime(date_fmt)
|
||||
date_fmt_fnc = lambda x: datetime.datetime.strptime(date_format)
|
||||
|
||||
if __name__ == '__main__':
|
||||
import argparse
|
||||
@ -54,7 +54,13 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
# Make ourselves a nice interaction object
|
||||
n = interface.Artifice(conf["username"], conf["password"], conf["admin_tenant"])
|
||||
# Password needs to be loaded from /etc/artifice/database
|
||||
fh = open(conf["database"]["password_path"])
|
||||
password = fh.read()
|
||||
fh.close()
|
||||
# Make ourselves a nice interaction object
|
||||
conf["database"]["password"] = password
|
||||
n = interface.Artifice(conf)
|
||||
tenants = args.tenants
|
||||
if not args.tenants:
|
||||
# only parse this list of tenants
|
||||
|
@ -59,8 +59,12 @@ if __name__ == '__main__':
|
||||
# Whoops
|
||||
print "couldn't load %s " % args.config
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
fh = open(conf["database"]["password_path"])
|
||||
password = fh.read()
|
||||
fh.close()
|
||||
# Make ourselves a nice interaction object
|
||||
conf["database"]["password"] = password
|
||||
instance = interface.Artifice(conf)
|
||||
tenants = args.tenants
|
||||
if not args.tenants:
|
||||
@ -88,4 +92,4 @@ if __name__ == '__main__':
|
||||
invoice.bill(usage.volumes)
|
||||
invoice.bill(usage.objects)
|
||||
|
||||
print "Total invoice value: %s" % invoice.total()
|
||||
print "Total invoice value: %s" % invoice.total()
|
||||
|
@ -4,9 +4,9 @@ ceilometer:
|
||||
database:
|
||||
database: artifice
|
||||
host: localhost
|
||||
password: aurynn
|
||||
port: '5433'
|
||||
username: aurynn
|
||||
password_path: /etc/artifice/database
|
||||
port: '5432'
|
||||
username: artifice
|
||||
invoice_object:
|
||||
delimiter: ','
|
||||
output_file: '%(tenant)s-%(start)s-%(end)s.csv'
|
||||
@ -19,8 +19,8 @@ invoice_object:
|
||||
- amount
|
||||
- cost
|
||||
rates:
|
||||
file: /opt/stack/artifice/etc/artifice/csv_rates.csv
|
||||
names: /opt/stack/artifice/etc/artifice/csv_names.csv
|
||||
file: /etc/artifice/csv_rates.csv
|
||||
names: /etc/artifice/csv_names.csv
|
||||
main:
|
||||
invoice:object: billing.csv_invoice:Csv
|
||||
openstack:
|
||||
|
@ -21,13 +21,19 @@ virtualenv <%= install_path %>/env
|
||||
|
||||
cat > /usr/local/bin/artifice-bill <<EOF
|
||||
#!/bin/bash
|
||||
<%=install_path%>/env/bin/python <%=install_path%>/bin/bill.py $@
|
||||
<%=install_path%>/env/bin/python <%=install_path%>/bin/bill.py \$@
|
||||
|
||||
EOF
|
||||
|
||||
cat > /usr/local/bin/artifice-usage <<EOF
|
||||
#!/bin/bash
|
||||
<%=install_path%>/env/bin/python <%=install_path%>/bin/usage.py $@
|
||||
<%=install_path%>/env/bin/python <%=install_path%>/bin/usage.py \$@
|
||||
EOF
|
||||
|
||||
chmod 0755 /usr/local/bin/artifice-usage
|
||||
chmod 0755 /usr/local/bin/artifice-bill
|
||||
|
||||
cp <%=install_path%>/etc/artifice/conf.yaml /etc/artifice/conf.yaml
|
||||
cp <%=install_path%>/etc/artifice/database /etc/artifice/database
|
||||
# chown 0640 /etc/artifice/database
|
||||
|
||||
|
@ -3,6 +3,9 @@
|
||||
# Loads a SQL script into postgres that creates the artifice DB.
|
||||
# Post-install script is going to load all the DB stuff via pythons
|
||||
|
||||
if [ ! -e /etc/artifice ]; then
|
||||
mkdir /etc/artifice
|
||||
fi
|
||||
|
||||
|
||||
if [ -e <%=install_path%>/etc/artifice/database ]; then
|
||||
@ -23,4 +26,4 @@ CREATE DATABASE <%=pg_database%>;
|
||||
CREATE EXTENSION btree_gist;
|
||||
CREATE USER <%=pg_user%> WITH ENCRYPTED PASSWORD '$PASSWORD';
|
||||
ALTER DATABASE <%=pg_database%> OWNER TO <%=pg_user%>;
|
||||
EOF
|
||||
EOF
|
||||
|
Loading…
x
Reference in New Issue
Block a user