From fcfa0f077df678b811f5f95ca1072953b70ec0f1 Mon Sep 17 00:00:00 2001 From: adriant Date: Thu, 12 Jun 2014 12:52:18 +1200 Subject: [PATCH] Renaming Artifice to Distil Lots of general rename changes, and a few pieces of minor tidy up. Change-Id: Ia88b75af0e2d294cfc57164ac42155234d8ba71a --- Makefile | 16 ++++++++-------- bin/web.py | 6 +++--- client/shell.py | 2 +- {artifice => distil}/__init__.py | 0 {artifice => distil}/api/__init__.py | 0 {artifice => distil}/api/helpers.py | 2 +- {artifice => distil}/api/web.py | 14 +++++++------- {artifice => distil}/auth.py | 0 {artifice => distil}/config.py | 0 {artifice => distil}/constants.py | 0 {artifice => distil}/database.py | 2 +- {artifice => distil}/helpers.py | 0 {artifice => distil}/initdb.py | 0 {artifice => distil}/interface.py | 0 {artifice => distil}/models/__init__.py | 4 ++-- {artifice => distil}/rates.py | 0 {artifice => distil}/transformers.py | 0 examples/csv_names.csv | 0 examples/csv_rates.csv | 10 ---------- examples/csv_rates.yaml | 6 ------ setup.py | 6 +++--- tests/__init__.py | 4 ++-- tests/constants.py | 2 +- tests/helpers.py | 2 +- tests/test_api.py | 20 ++++++++++---------- tests/test_database_module.py | 2 +- tests/test_interface.py | 4 ++-- tests/test_models.py | 2 +- tests/test_transformers.py | 14 +++++++------- 29 files changed, 51 insertions(+), 67 deletions(-) rename {artifice => distil}/__init__.py (100%) rename {artifice => distil}/api/__init__.py (100%) rename {artifice => distil}/api/helpers.py (98%) rename {artifice => distil}/api/web.py (98%) rename {artifice => distil}/auth.py (100%) rename {artifice => distil}/config.py (100%) rename {artifice => distil}/constants.py (100%) rename {artifice => distil}/database.py (99%) rename {artifice => distil}/helpers.py (100%) rename {artifice => distil}/initdb.py (100%) rename {artifice => distil}/interface.py (100%) rename {artifice => distil}/models/__init__.py (99%) rename {artifice => distil}/rates.py (100%) rename {artifice => distil}/transformers.py (100%) delete mode 100644 examples/csv_names.csv delete mode 100644 examples/csv_rates.csv delete mode 100644 examples/csv_rates.yaml diff --git a/Makefile b/Makefile index f740285..97efbc9 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,13 @@ VERSION=0.1 -NAME=openstack-artifice -INSTALL_PATH=/opt/stack/artifice +NAME=openstack-distil +INSTALL_PATH=/opt/stack/distil BILLING_PROGRAM=bill.py BINARY_PATH=/usr/local/bin WORK_DIR=./work -CONF_DIR=${WORK_DIR}/${INSTALL_PATH}/etc/artifice +CONF_DIR=${WORK_DIR}/${INSTALL_PATH}/etc/distil clean: @rm -rf ./work @@ -20,7 +20,7 @@ init: deb: clean init - @cp -r ./artifice \ + @cp -r ./distil \ ./scripts \ ./README.md \ ./INVOICES.md \ @@ -36,10 +36,10 @@ deb: clean init @cp -r ./packaging/fs/* ${WORK_DIR}/ @mkdir -p ${CONF_DIR} @mkdir -p ${WORK_DIR}/etc/init.d - @mkdir -p ${WORK_DIR}/etc/artifice - @chmod +x ${WORK_DIR}/etc/init.d/artifice - @cp ./examples/conf.yaml ${WORK_DIR}/etc/artifice/conf.yaml - @cp ./examples/csv_rates.yaml ${WORK_DIR}/etc/artifice/csv_rates.yaml + @mkdir -p ${WORK_DIR}/etc/distil + @chmod +x ${WORK_DIR}/etc/init.d/distil + @cp ./examples/conf.yaml ${WORK_DIR}/etc/distil/conf.yaml + @cp ./examples/csv_rates.yaml ${WORK_DIR}/etc/distil/csv_rates.yaml @fpm -s dir -t deb -n ${NAME} -v ${VERSION} \ --post-install=packaging/scripts/post_install.sh \ --depends 'libpq-dev' \ diff --git a/bin/web.py b/bin/web.py index b95f2ea..5f88059 100644 --- a/bin/web.py +++ b/bin/web.py @@ -1,12 +1,12 @@ #!/usr/bin/python -from artifice.api import web +from distil.api import web import yaml import sys import argparse -a = argparse.ArgumentParser("Web service for Artifice") +a = argparse.ArgumentParser("Web service for Distil") -a.add_argument("-c", "--config", dest="config", help="Path to config file", default="/etc/artifice/conf.yaml") +a.add_argument("-c", "--config", dest="config", help="Path to config file", default="/etc/distil/conf.yaml") a.add_argument("-i", "--interface", dest="ip", help="IP address to serve on.", default="0.0.0.0") a.add_argument("-p", "--port", help="port to serve on", default="8000") diff --git a/client/shell.py b/client/shell.py index 139a88c..2a1e8e8 100644 --- a/client/shell.py +++ b/client/shell.py @@ -40,7 +40,7 @@ if __name__ == '__main__': parser.add_argument("-c", "--config", dest="config", help="Config file", - default="/etc/artifice/conf.yaml") + default="/etc/distil/conf.yaml") # commands: subparsers = parser.add_subparsers(help='commands', dest='command') diff --git a/artifice/__init__.py b/distil/__init__.py similarity index 100% rename from artifice/__init__.py rename to distil/__init__.py diff --git a/artifice/api/__init__.py b/distil/api/__init__.py similarity index 100% rename from artifice/api/__init__.py rename to distil/api/__init__.py diff --git a/artifice/api/helpers.py b/distil/api/helpers.py similarity index 98% rename from artifice/api/helpers.py rename to distil/api/helpers.py index 9164b09..7defaf2 100644 --- a/artifice/api/helpers.py +++ b/distil/api/helpers.py @@ -2,7 +2,7 @@ from decorator import decorator import flask import itertools import json -from artifice.models import Tenant +from distil.models import Tenant def _validate(data, *args, **kwargs): diff --git a/artifice/api/web.py b/distil/api/web.py similarity index 98% rename from artifice/api/web.py rename to distil/api/web.py index bc10007..b7bc131 100644 --- a/artifice/api/web.py +++ b/distil/api/web.py @@ -1,12 +1,12 @@ import flask from flask import Flask, Blueprint -from artifice import database, config -from artifice.constants import iso_time, iso_date, dawn_of_time -from artifice.transformers import active_transformers -from artifice.rates import RatesFile -from artifice.models import SalesOrder, _Last_Run -from artifice.helpers import convert_to -from artifice.interface import Interface, timed +from distil import database, config +from distil.constants import iso_time, iso_date, dawn_of_time +from distil.transformers import active_transformers +from distil.rates import RatesFile +from distil.models import SalesOrder, _Last_Run +from distil.helpers import convert_to +from distil.interface import Interface, timed import sqlalchemy from sqlalchemy import create_engine, func from sqlalchemy.orm import scoped_session, create_session diff --git a/artifice/auth.py b/distil/auth.py similarity index 100% rename from artifice/auth.py rename to distil/auth.py diff --git a/artifice/config.py b/distil/config.py similarity index 100% rename from artifice/config.py rename to distil/config.py diff --git a/artifice/constants.py b/distil/constants.py similarity index 100% rename from artifice/constants.py rename to distil/constants.py diff --git a/artifice/database.py b/distil/database.py similarity index 99% rename from artifice/database.py rename to distil/database.py index 0c26407..573a8eb 100644 --- a/artifice/database.py +++ b/distil/database.py @@ -1,6 +1,6 @@ from sqlalchemy import func from .models import Resource, UsageEntry, Tenant, SalesOrder, _Last_Run -from artifice.constants import dawn_of_time +from distil.constants import dawn_of_time from datetime import timedelta import json import config diff --git a/artifice/helpers.py b/distil/helpers.py similarity index 100% rename from artifice/helpers.py rename to distil/helpers.py diff --git a/artifice/initdb.py b/distil/initdb.py similarity index 100% rename from artifice/initdb.py rename to distil/initdb.py diff --git a/artifice/interface.py b/distil/interface.py similarity index 100% rename from artifice/interface.py rename to distil/interface.py diff --git a/artifice/models/__init__.py b/distil/models/__init__.py similarity index 99% rename from artifice/models/__init__.py rename to distil/models/__init__.py index 0a05b20..934a18f 100644 --- a/artifice/models/__init__.py +++ b/distil/models/__init__.py @@ -17,13 +17,13 @@ class _Version(Base): """ A model that knows what version we are, stored in the DB. """ - __tablename__ = "artifice_database_version" + __tablename__ = "distil_database_version" id = Column(String(10), primary_key=True) class _Last_Run(Base): """Model to store time of last completed usage run.""" - __tablename__ = "artifice_last_run" + __tablename__ = "distil_last_run" id = Column(Integer, primary_key=True) last_run = Column(DateTime, nullable=False) diff --git a/artifice/rates.py b/distil/rates.py similarity index 100% rename from artifice/rates.py rename to distil/rates.py diff --git a/artifice/transformers.py b/distil/transformers.py similarity index 100% rename from artifice/transformers.py rename to distil/transformers.py diff --git a/examples/csv_names.csv b/examples/csv_names.csv deleted file mode 100644 index e69de29..0000000 diff --git a/examples/csv_rates.csv b/examples/csv_rates.csv deleted file mode 100644 index 027f2ce..0000000 --- a/examples/csv_rates.csv +++ /dev/null @@ -1,10 +0,0 @@ -region | m1_nano | duration | 0.32 -region | m1_micro | duration | 0.42 -region | m1_tiny | duration | 0.62 -region | m1_small | duration | 0.82 -region | m1_medium | duration | 1.02 -region | incoming_megabytes | bytes | 0.004 -region | outgoing_megabytes | bytes | 0.007 -region | storage_size | bytes per hour | 0.000513 -region | floating_ip | duration | 0.05 -region | volume_size | bytes per hour | 0.0076 diff --git a/examples/csv_rates.yaml b/examples/csv_rates.yaml deleted file mode 100644 index f187a66..0000000 --- a/examples/csv_rates.yaml +++ /dev/null @@ -1,6 +0,0 @@ ---- -storage.objects.size: 15 -m1.nano: 5 -network.incoming.bytes: 5 -network.outgoing.bytes: 1 -volume.size: 25 \ No newline at end of file diff --git a/setup.py b/setup.py index bee164a..83f46e1 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,12 @@ from setuptools import setup -setup(name='openstack-artifice', +setup(name='openstack-distil', version='0.1', description='Artifice, a set of APIs for creating billable items from Openstack-Ceilometer', author='Aurynn Shaw', author_email='aurynn@catalyst.net.nz', contributors=["Chris Forbes", "Adrian Turjak"], contributor_emails=["chris.forbes@catalyst.net.nz", "adriant@catalyst.net.nz"], - url='https://github.com/catalyst/artifice', - packages=["artifice", "artifice.api", "artifice.models"] + url='https://github.com/catalyst/distil', + packages=["distil", "distil.api", "distil.models"] ) diff --git a/tests/__init__.py b/tests/__init__.py index ef5cec8..cca0b23 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -3,8 +3,8 @@ from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker, scoped_session,create_session from sqlalchemy.pool import NullPool -from artifice.models import Resource, Tenant, UsageEntry, SalesOrder, Base -from artifice import config +from distil.models import Resource, Tenant, UsageEntry, SalesOrder, Base +from distil import config from .constants import DATABASE_NAME, PG_DATABASE_URI, MY_DATABASE_URI from .constants import config as test_config diff --git a/tests/constants.py b/tests/constants.py index 46a4766..f3680bf 100644 --- a/tests/constants.py +++ b/tests/constants.py @@ -1,5 +1,5 @@ -DATABASE_NAME = "test_artifice" +DATABASE_NAME = "test_distil" PG_DATABASE_URI = "postgresql://aurynn:postgres@localhost/%s" % DATABASE_NAME MY_DATABASE_URI = "mysql://root:password@localhost/%s" % DATABASE_NAME diff --git a/tests/helpers.py b/tests/helpers.py index 8fd9997..26cf48a 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -1,5 +1,5 @@ import mock -from artifice import models +from distil import models from datetime import timedelta import json diff --git a/tests/test_api.py b/tests/test_api.py index fa23f6e..ddf2a60 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1,10 +1,10 @@ from webtest import TestApp from . import test_interface, helpers, constants -from artifice.api import web -from artifice.api.web import get_app -from artifice import models -from artifice import interface -from artifice.helpers import convert_to +from distil.api import web +from distil.api.web import get_app +from distil import models +from distil import interface +from distil.helpers import convert_to from datetime import datetime from decimal import Decimal import unittest @@ -28,7 +28,7 @@ class TestApi(test_interface.TestInterface): usage = helpers.get_usage(self.start, self.end) - with mock.patch('artifice.interface.Artifice') as Artifice: + with mock.patch('distil.interface.Interface') as Interface: tenants = [] @@ -42,14 +42,14 @@ class TestApi(test_interface.TestInterface): t.description = tenant['description'] tenants.append(t) - artifice = mock.Mock(spec=interface.Artifice) + ceil_interface = mock.Mock(spec=interface.Interface) - artifice.tenants = tenants + ceil_interface.tenants = tenants - Artifice.return_value = artifice + Interface.return_value = ceil_interface # patch to mock out the novaclient call - with mock.patch('artifice.helpers.flavor_name') as flavor_name: + with mock.patch('distil.helpers.flavor_name') as flavor_name: flavor_name.side_effect = lambda x: x resp = self.app.post("/collect_usage") diff --git a/tests/test_database_module.py b/tests/test_database_module.py index a2c054a..77bd19f 100644 --- a/tests/test_database_module.py +++ b/tests/test_database_module.py @@ -1,5 +1,5 @@ from . import test_interface, helpers -from artifice import database +from distil import database from datetime import timedelta diff --git a/tests/test_interface.py b/tests/test_interface.py index db749bd..dcfe963 100644 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -1,6 +1,6 @@ import unittest -from artifice.models import Tenant as tenant_model -from artifice.models import UsageEntry, Resource, SalesOrder +from distil.models import Tenant as tenant_model +from distil.models import UsageEntry, Resource, SalesOrder from sqlalchemy.pool import NullPool from sqlalchemy import create_engine diff --git a/tests/test_models.py b/tests/test_models.py index d0a224c..381535b 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -2,7 +2,7 @@ import unittest from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker, scoped_session,create_session from sqlalchemy.pool import NullPool -from artifice.models import Resource, Tenant, UsageEntry, SalesOrder, Base +from distil.models import Resource, Tenant, UsageEntry, SalesOrder, Base import datetime import subprocess diff --git a/tests/test_transformers.py b/tests/test_transformers.py index 1410ae8..6693528 100644 --- a/tests/test_transformers.py +++ b/tests/test_transformers.py @@ -1,6 +1,6 @@ -import artifice.transformers -from artifice import constants -from artifice.constants import states +import distil.transformers +from distil import constants +from distil.constants import states import unittest import mock import datetime @@ -39,8 +39,8 @@ class TestMeter(object): class UptimeTransformerTests(unittest.TestCase): def _run_transform(self, data): - xform = artifice.transformers.Uptime() - with mock.patch('artifice.helpers.flavor_name') as flavor_name: + xform = distil.transformers.Uptime() + with mock.patch('distil.helpers.flavor_name') as flavor_name: flavor_name.side_effect = lambda x: x return xform.transform_usage('state', data, testdata.ts0, testdata.ts1) @@ -178,7 +178,7 @@ class GaugeMaxTransformerTests(unittest.TestCase): {'timestamp': testdata.t1, 'counter_volume': 6}, ] - xform = artifice.transformers.GaugeMax() + xform = distil.transformers.GaugeMax() usage = xform.transform_usage('some_meter', data, testdata.ts0, testdata.ts1) @@ -196,7 +196,7 @@ class GaugeMaxTransformerTests(unittest.TestCase): {'timestamp': testdata.t1, 'counter_volume': 25}, ] - xform = artifice.transformers.GaugeMax() + xform = distil.transformers.GaugeMax() usage = xform.transform_usage('some_meter', data, testdata.ts0, testdata.ts1)