GitHub

Original file line numberDiff line numberDiff line change

@@ -37,8 +37,17 @@ deploy: create-tarball

3737

@juju set ubuntu-reviews build_label=r$(REVIEWS_REVNO)

3838

@juju deploy gunicorn

3939

@juju deploy nrpe-external-master

40+

@juju deploy postgresql

4041

@juju add-relation ubuntu-reviews gunicorn

4142

@juju add-relation ubuntu-reviews nrpe-external-master

43+

@juju add-relation ubuntu-reviews postgresql:db

44+

@juju set postgresql extra-packages=postgresql-9.1-debversion

45+

@echo "Once the services are related, run 'make setup-db'"

46+
47+

setup-db:

48+

@echo "Creating custom debversion postgres type and syncing the ubuntu-reviews database."

49+

@juju run --service postgresql 'psql -U postgres ubuntu-reviews -c "CREATE EXTENSION debversion;"'

50+

@juju run --unit=ubuntu-reviews/0 "hooks/syncdb"

4251

@echo See the README for explorations after deploying.

4352
4453

curl:

Original file line numberDiff line numberDiff line change

@@ -2,5 +2,5 @@

22
33

urlpatterns = patterns(

44

'',

5-

url(r'^$', include('clickreviews.api.urls'), name='api'),

5+

url(r'^', include('clickreviews.api.urls'), name='api'),

66

)

Original file line numberDiff line numberDiff line change

@@ -3,7 +3,13 @@

33

import sys

44
55

if __name__ == "__main__":

6-

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "clickreviews.settings")

6+

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "clickreviewsproject.settings")

7+

extra_paths = [

8+

'/srv/click-reviews.ubuntu.com/code/current/branches/scaclient/',

9+

'/srv/click-reviews.ubuntu.com/code/current/branches/piston-mini-client/',

10+

'/srv/click-reviews.ubuntu.com/code/current/branches/django-piston/',

11+

]

12+

sys.path.extend(extra_paths)

713
814

from django.core.management import execute_from_command_line

915
Original file line numberDiff line numberDiff line change

@@ -0,0 +1 @@

1+

hooks.py

Original file line numberDiff line numberDiff line change

@@ -0,0 +1 @@

1+

hooks.py

Original file line numberDiff line numberDiff line change

@@ -15,3 +15,6 @@ provides:

1515

nrpe-external-master:

1616

interface: nrpe-external-master

1717

scope: container

18+

requires:

19+

db:

20+

interface: pgsql

Original file line numberDiff line numberDiff line change

@@ -3,13 +3,13 @@

33
44

vars:

55

- app_label: click-reviews.ubuntu.com

6+

- code_archive: "{{ build_label }}/rnr-server.tgz"

67
78

roles:

89

- role: wsgi-app

910

listen_port: 8080

1011

python_path: "{{ application_dir }}/django-project:{{ current_code_dir }}/src"

1112

wsgi_application: clickreviewsproject.wsgi:application

12-

code_archive: "{{ build_label }}/rnr-server.tgz"

1313

when: build_label != ''

1414
1515

- role: nrpe-external-master

@@ -25,6 +25,7 @@

2525

- python-django=1.5.4-1ubuntu1~ctools0

2626

- python-tz

2727

- python-pip

28+

- python-psycopg2

2829

tags:

2930

- install

3031

- upgrade-charm

@@ -46,13 +47,24 @@

4647

tags:

4748

- install

4849

- upgrade-charm

50+

- db-relation-changed

4951

notify:

5052

- Restart wsgi

53+
5154

# XXX Normally our deployment build would ensure these are all available in the tarball.

5255

- name: Install any non-distro dependencies (Don't depend on pip for a real deployment!)

5356

pip: name={{ item.key }} version={{ item.value }}

5457

with_dict:

5558

south: 0.7.6

59+

django-openid-auth: 0.2

5660

tags:

5761

- install

5862

- upgrade-charm

63+
64+

- name: sync the database

65+

django_manage: >

66+

command="syncdb --noinput"

67+

app_path="{{ application_dir }}/django-project"

68+

pythonpath="{{ code_dir }}/current/src"

69+

tags:

70+

- syncdb

Original file line numberDiff line numberDiff line change

@@ -1,6 +1,31 @@

11

DEBUG = True

22

TEMPLATE_DEBUG = DEBUG

33

SECRET_KEY = '{{ django_secret_key }}'

4+
5+

{% if 'db' in relations %}

6+

DATABASES = {

7+

{% for dbrelation in relations['db'] %}

8+

{% if loop.first %}

9+

{% set services=relations['db'][dbrelation] %}

10+

{% for service in services %}

11+

{% if service.startswith('postgres') %}

12+

{% set dbdetails = services[service] %}

13+

{% if 'database' in dbdetails %}

14+

'default': {

15+

'ENGINE': 'django.db.backends.postgresql_psycopg2',

16+

'NAME': '{{ dbdetails["database"] }}',

17+

'HOST': '{{ dbdetails["host"] }}',

18+

'USER': '{{ dbdetails["user"] }}',

19+

'PASSWORD': '{{ dbdetails["password"] }}',

20+

}

21+

{% endif %}

22+

{% endif %}

23+

{% endfor %}

24+

{% endif %}

25+

{% endfor %}

26+

}

27+

{% endif %}

28+
429

TIME_ZONE = 'UTC'

530

ROOT_URLCONF = 'clickreviewsproject.urls'

631

WSGI_APPLICATION = 'clickreviewsproject.wsgi.application'

@@ -12,8 +37,8 @@ INSTALLED_APPS = (

1237

'django_openid_auth',

1338

'django.contrib.messages',

1439

'django.contrib.staticfiles',

40+

'reviewsapp',

1541

'clickreviews',

16-

'south',

1742

)

1843

AUTHENTICATION_BACKENDS = (

1944

'django_openid_auth.auth.OpenIDBackend',

Read the original on github.com ↗