diff --git a/.gitignore b/.gitignore index 1270860..b07e3bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,9 @@ .tox .vagrant *.pyc +.venv +*.egg-info +*.egg +.eggs +.*.swp +build diff --git a/README.rst b/README.rst index 0ae7dda..9ac27c0 100644 --- a/README.rst +++ b/README.rst @@ -39,15 +39,15 @@ The installation of Vagrant is described at https://docs.vagrantup.com/v2/instal $ vagrant up -Login with :code:`vagrant ssh`, change into the directory :code:`/home/vagrant/src` and +Login with :code:`vagrant ssh`, change into the directory :code:`/vagrant` and open a new screen or tmux session. Aftwards run the worker, producer, and tracker services in the foreground, each service in a separate window. .. code:: - $ python worker.py - $ python tracker.py - $ python producer.py + $ python openstack_application_tutorial/worker.py + $ python openstack_application_tutorial/tracker.py + $ python openstack_application_tutorial/producer.py RabbitMQ server ~~~~~~~~~~~~~~~ diff --git a/Vagrantfile b/Vagrantfile index 5153aa1..fad005e 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -17,8 +17,6 @@ BOX = "ubuntu/trusty64" Vagrant.configure(2) do |config| config.vm.box = BOX - config.vm.synced_folder '.', '/vagrant', disabled: true - config.vm.synced_folder 'src', '/home/vagrant/src' config.vm.network "forwarded_port", guest: 15672, host: 15672 config.vm.provider "virtualbox" do |vb| vb.customize ["modifyvm", :id, "--memory", "2048"] diff --git a/ansible/playbook.yaml b/ansible/playbook.yaml index e34fb98..dc92cb8 100644 --- a/ansible/playbook.yaml +++ b/ansible/playbook.yaml @@ -3,8 +3,20 @@ tasks: - apt: update-cache=yes upgrade=yes - - apt: name=rabbitmq-server state=latest - - apt: name=python-pillow state=latest + - apt: name={{ item }} state=latest + with_items: + - expect + - git + - ibmysqlclient-dev + - mysql-client + - mysql-server + - python-dev + - python-kombu + - python-mysqldb + - python-pillow + - python-sqlalchemy + - python-virtualenv + - rabbitmq-server - service: name=rabbitmq-server state=started enabled=yes - rabbitmq_user: user=guest password=secretsecret @@ -16,12 +28,6 @@ write_priv=.* state=present - rabbitmq_plugin: names=rabbitmq_management state=enabled - - apt: name=python-kombu state=latest - - apt: name=mysql-server state=present - - apt: name=mysql-client state=present - - apt: name=python-mysqldb state=present - - apt: name=python-sqlalchemy state=present - - apt: name=expect state=present - copy: src=files/my.cnf dest=/etc/my.cnf - service: name=mysql state=restarted enabled=yes - copy: src=files/mysql_secure_installation.sh diff --git a/openstack_application_tutorial/__init__.py b/openstack_application_tutorial/__init__.py new file mode 100644 index 0000000..4c5705a --- /dev/null +++ b/openstack_application_tutorial/__init__.py @@ -0,0 +1,17 @@ +# 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 pbr.version + + +name = 'openstack-application-tutorial' +__version__ = pbr.version.VersionInfo(name).version_string() diff --git a/src/models.py b/openstack_application_tutorial/models.py similarity index 100% rename from src/models.py rename to openstack_application_tutorial/models.py diff --git a/src/producer.py b/openstack_application_tutorial/producer.py old mode 100755 new mode 100644 similarity index 98% rename from src/producer.py rename to openstack_application_tutorial/producer.py index 2ccf989..989509d --- a/src/producer.py +++ b/openstack_application_tutorial/producer.py @@ -24,8 +24,8 @@ from kombu.pools import producers from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker -import models -import queues +from openstack_application_tutorial import models +from openstack_application_tutorial import queues def initialize_logging(): diff --git a/src/queues.py b/openstack_application_tutorial/queues.py similarity index 100% rename from src/queues.py rename to openstack_application_tutorial/queues.py diff --git a/src/tracker.py b/openstack_application_tutorial/tracker.py old mode 100755 new mode 100644 similarity index 96% rename from src/tracker.py rename to openstack_application_tutorial/tracker.py index 9d683f7..3246138 --- a/src/tracker.py +++ b/openstack_application_tutorial/tracker.py @@ -23,8 +23,8 @@ from kombu.mixins import ConsumerMixin from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker -import models -import queues +from openstack_application_tutorial import models +from openstack_application_tutorial import queues class Tracker(ConsumerMixin): diff --git a/src/worker.py b/openstack_application_tutorial/worker.py old mode 100755 new mode 100644 similarity index 98% rename from src/worker.py rename to openstack_application_tutorial/worker.py index b3339c9..738eac0 --- a/src/worker.py +++ b/openstack_application_tutorial/worker.py @@ -27,7 +27,7 @@ import kombu from kombu.mixins import ConsumerMixin from kombu.pools import producers -import queues +from openstack_application_tutorial import queues class JuliaSet(object): diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..372e659 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,8 @@ +pbr>=0.6,!=0.7,<1.0 +anyjson +amqp +argparse +kombu +mysql +pillow +sqlalchemy diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..8fcea97 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,42 @@ +[metadata] +name = openstack-application-tutorial +summary = OpenStack Application Tutorial +description-file = + README.rst +author = Christian Berendt +author-email = christian@berendt.io +home-page = https://www.berendt.io +classifier = + Environment :: OpenStack + Intended Audience :: Information Technology + Intended Audience :: System Administrators + License :: OSI Approved :: Apache Software License + Operating System :: POSIX :: Linux + Programming Language :: Python + Programming Language :: Python :: 2 + Programming Language :: Python :: 2.7 + Programming Language :: Python :: 2.6 + +[files] +packages = openstack_application_tutorial + +[global] +setup-hooks = + pbr.hooks.setup_hook + +[entry_points] +console_scripts = + oat-producer = openstack_application_tutorial.producer:main + oat-tracker = openstack_application_tutorial.tracker:main + oat-worker = openstack_application_tutorial.worker:main + +#[build_sphinx] +#source-dir = doc/source +#build-dir = doc/build +#all_files = 1 + +#[upload_sphinx] +#upload-dir = doc/build/html + +[wheel] +universal = 1 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..ee06f22 --- /dev/null +++ b/setup.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. +# +# 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 setuptools + +# In python < 2.7.4, a lazy loading of package `pbr` will break +# setuptools if some other modules registered functions in `atexit`. +# solution from: http://bugs.python.org/issue15881#msg170215 +try: + import multiprocessing # noqa +except ImportError: + pass + +setuptools.setup( + setup_requires=['pbr'], + pbr=True) diff --git a/test-requirements.txt b/test-requirements.txt index 499e39c..0a5b877 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,2 +1 @@ hacking -pbr>=0.6,!=0.7,<1.0 diff --git a/tox.ini b/tox.ini index 33ddbed..9a0344d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,12 @@ [tox] minversion = 1.6 -#envlist = lint +envlist = lint skipsdist = True [testenv] -usedevelop = False +usedevelop = True deps = -r{toxinidir}/test-requirements.txt + -r{toxinidir}/requirements.txt install_command = pip install {opts} {packages} [testenv:venv]