Merge lp:~doanac/ubuntu-ci-services-itself/json-jsonp-status into lp:ubuntu-ci-services-itself

Proposed by Andy Doan
Status: Merged
Approved by: Chris Johnston
Approved revision: 301
Merged at revision: 299
Proposed branch: lp:~doanac/ubuntu-ci-services-itself/json-jsonp-status
Merge into: lp:ubuntu-ci-services-itself
Diff against target: 175 lines (+63/-0)
9 files modified
charms/precise/restish/config.yaml (+4/-0)
charms/precise/restish/hooks/hooks.py (+13/-0)
charms/precise/restish/metadata.yaml (+3/-0)
charms/precise/webui/hooks/hooks.py (+35/-0)
charms/precise/webui/metadata.yaml (+2/-0)
juju-deployer/branch-source-builder.yaml.tmpl (+1/-0)
juju-deployer/image-builder.yaml.tmpl (+1/-0)
juju-deployer/relations.yaml (+3/-0)
juju-deployer/test-runner.yaml.tmpl (+1/-0)
To merge this branch: bzr merge lp:~doanac/ubuntu-ci-services-itself/json-jsonp-status
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Andy Doan (community) Approve
Evan (community) Approve
Review via email: mp+208915@code.launchpad.net

Commit message

integrate monitoring api into webui

Provide a simple mechansim for the webui to get monitor the status of other services.
(restish only for this change)

Description of the change

provides the charming logic required to fix:

 https://bugs.launchpad.net/bugs/1285360

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:300
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/265/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/265/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Evan (ev) wrote :

Looks good. +1

review: Approve
Revision history for this message
Evan (ev) wrote :

110 +@hooks.hook('json_status-relation-changed')
111 +def json_status_relation_changed():
112 + json_status_relation_joined()

Minor nit, but couldn't you just decorate json_status_relation_joined() with hooks.hook('json_status-relation-changed')?

Revision history for this message
Andy Doan (doanac) wrote :

On 03/03/2014 03:10 AM, Evan Dandrea wrote:
> 110 +@hooks.hook('json_status-relation-changed')
> 111 +def json_status_relation_changed():
> 112 + json_status_relation_joined()
>
> Minor nit, but couldn't you just decorate json_status_relation_joined() with hooks.hook('json_status-relation-changed')?

I wasn't positive if was safe with the hooks.hook decorator to have it
twice for a function. I'm re-doplying this morning, so it should be easy
to find out :)

301. By Andy Doan

use one hook function for joined/changed

as noted by evan

Revision history for this message
Andy Doan (doanac) wrote :

revno 301 fixes ev's comment. he's already acked the patch.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:301
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/267/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/267/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:301
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/271/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/271/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'charms/precise/restish/config.yaml'
--- charms/precise/restish/config.yaml 2014-02-18 23:42:52 +0000
+++ charms/precise/restish/config.yaml 2014-03-03 17:27:54 +0000
@@ -28,6 +28,10 @@
28 type: string28 type: string
29 description: "PYTHONPATH specification for the service. Can include paths relative to local bzr directory"29 description: "PYTHONPATH specification for the service. Can include paths relative to local bzr directory"
3030
31 json_status_path:
32 type: string
33 description: "relative path of a URL that reports the health status of this service"
34
31 # required for rabbitmq-server charm:35 # required for rabbitmq-server charm:
32 amqp-user:36 amqp-user:
33 type: string37 type: string
3438
=== modified file 'charms/precise/restish/hooks/hooks.py'
--- charms/precise/restish/hooks/hooks.py 2014-02-18 23:42:52 +0000
+++ charms/precise/restish/hooks/hooks.py 2014-03-03 17:27:54 +0000
@@ -135,6 +135,19 @@
135 pass135 pass
136136
137137
138def json_status_relation_joined(config):
139 path = config.get('json_status_path')
140 if path:
141 port = config['port']
142 host = subprocess.check_output(['unit-get', 'public-address']).strip()
143 if not host:
144 juju_info('no public address found, using private')
145 host = subprocess.check_output(
146 ['unit-get', 'private-address']).strip()
147 url = 'http://%s:%s/%s' % (host, port, path)
148 _relation_set({'status-url': url})
149
150
138def wsgi_relation_joined(config):151def wsgi_relation_joined(config):
139 sdir = _service_dir(config)152 sdir = _service_dir(config)
140153
141154
=== added symlink 'charms/precise/restish/hooks/json_status-relation-joined'
=== target is u'hooks.py'
=== modified file 'charms/precise/restish/metadata.yaml'
--- charms/precise/restish/metadata.yaml 2014-01-16 16:52:53 +0000
+++ charms/precise/restish/metadata.yaml 2014-03-03 17:27:54 +0000
@@ -13,6 +13,9 @@
13 wsgi:13 wsgi:
14 interface: wsgi14 interface: wsgi
15 scope: container15 scope: container
16 json_status:
17 interface: json_status
18 optional: true
16requires:19requires:
17 amqp:20 amqp:
18 interface: rabbitmq21 interface: rabbitmq
1922
=== modified file 'charms/precise/webui/hooks/hooks.py'
--- charms/precise/webui/hooks/hooks.py 2014-02-17 10:13:29 +0000
+++ charms/precise/webui/hooks/hooks.py 2014-03-03 17:27:54 +0000
@@ -2,6 +2,7 @@
22
3import distutils.dir_util3import distutils.dir_util
4import grp4import grp
5import json
5import os6import os
6import pwd7import pwd
7import re8import re
@@ -26,12 +27,46 @@
26site_name = "ci-airlines.canonical.com"27site_name = "ci-airlines.canonical.com"
27site_path = "/srv/{}".format(site_name)28site_path = "/srv/{}".format(site_name)
2829
30json_status_file = os.path.join(site_path, 'status_urls.json')
31
29config_data = config_get()32config_data = config_get()
3033
31web_uid = pwd.getpwnam('www-data')[2]34web_uid = pwd.getpwnam('www-data')[2]
32web_gid = grp.getgrnam('www-data')[2]35web_gid = grp.getgrnam('www-data')[2]
3336
3437
38@hooks.hook('json_status-relation-joined')
39@hooks.hook('json_status-relation-changed')
40def json_status_relation_joined():
41 url = charmhelpers.core.hookenv.relation_get('status-url')
42 unit = charmhelpers.core.hookenv.remote_unit()
43 log('status URL is: %s' % url)
44
45 data = {}
46 if os.path.exists(json_status_file):
47 data = json.load(open(json_status_file))
48 data[charmhelpers.core.hookenv.relation_id()] = {
49 'url': url,
50 'unit': unit,
51 }
52
53 with open(json_status_file, 'w') as f:
54 json.dump(data, f)
55
56
57@hooks.hook('json_status-relation-broken')
58def json_status_relation_broken():
59 if not os.path.exists(json_status_file):
60 return
61
62 data = json.load(open(json_status_file))
63 rid = charmhelpers.core.hookenv.relation_id()
64 if rid in data:
65 del data[rid]
66 with open(json_status_file, 'w') as f:
67 json.dump(data, f)
68
69
35@hooks.hook()70@hooks.hook()
36def install():71def install():
37 if os.path.exists(site_path):72 if os.path.exists(site_path):
3873
=== added symlink 'charms/precise/webui/hooks/json_status-relation-broken'
=== target is u'hooks.py'
=== added symlink 'charms/precise/webui/hooks/json_status-relation-changed'
=== target is u'hooks.py'
=== added symlink 'charms/precise/webui/hooks/json_status-relation-joined'
=== target is u'hooks.py'
=== modified file 'charms/precise/webui/metadata.yaml'
--- charms/precise/webui/metadata.yaml 2014-01-23 17:11:17 +0000
+++ charms/precise/webui/metadata.yaml 2014-03-03 17:27:54 +0000
@@ -10,3 +10,5 @@
10 website:10 website:
11 interface: http11 interface: http
12 scope: container12 scope: container
13 json_status:
14 interface: json_status
1315
=== modified file 'juju-deployer/branch-source-builder.yaml.tmpl'
--- juju-deployer/branch-source-builder.yaml.tmpl 2014-02-25 23:16:13 +0000
+++ juju-deployer/branch-source-builder.yaml.tmpl 2014-03-03 17:27:54 +0000
@@ -10,6 +10,7 @@
10 python_path: ./branch-source-builder:./ci-utils10 python_path: ./branch-source-builder:./ci-utils
11 # need non-default package python-amqplib for this service11 # need non-default package python-amqplib for this service
12 packages: "python-webtest python-mock python-jinja2 python-amqplib"12 packages: "python-webtest python-mock python-jinja2 python-amqplib"
13 json_status_path: api/v1/status
13 bsb-gunicorn:14 bsb-gunicorn:
14 charm: gunicorn15 charm: gunicorn
15 branch: lp:charms/precise/gunicorn@2816 branch: lp:charms/precise/gunicorn@28
1617
=== modified file 'juju-deployer/image-builder.yaml.tmpl'
--- juju-deployer/image-builder.yaml.tmpl 2014-02-28 09:25:47 +0000
+++ juju-deployer/image-builder.yaml.tmpl 2014-03-03 17:27:54 +0000
@@ -9,6 +9,7 @@
9 tarball: ${CI_PAYLOAD_URL}9 tarball: ${CI_PAYLOAD_URL}
10 python_path: ./image-builder:./ci-utils10 python_path: ./image-builder:./ci-utils
11 packages: "python-webtest python-mock python-jinja2 python-amqplib"11 packages: "python-webtest python-mock python-jinja2 python-amqplib"
12 json_status_path: api/v1/status
12 imagebuild-gunicorn:13 imagebuild-gunicorn:
13 charm: gunicorn14 charm: gunicorn
14 branch: lp:charms/precise/gunicorn@2815 branch: lp:charms/precise/gunicorn@28
1516
=== modified file 'juju-deployer/relations.yaml'
--- juju-deployer/relations.yaml 2014-01-30 13:12:40 +0000
+++ juju-deployer/relations.yaml 2014-03-03 17:27:54 +0000
@@ -7,3 +7,6 @@
7 - ["imagebuild-restish:lander-jenkins", lander-jenkins-sub]7 - ["imagebuild-restish:lander-jenkins", lander-jenkins-sub]
8 - ["ts-django:lander-jenkins", lander-jenkins-sub]8 - ["ts-django:lander-jenkins", lander-jenkins-sub]
9 - ["tr-restish:lander-jenkins", lander-jenkins-sub]9 - ["tr-restish:lander-jenkins", lander-jenkins-sub]
10 - ["imagebuild-restish:json_status", "webui-app:json_status"]
11 - ["tr-restish:json_status", "webui-app:json_status"]
12 - ["bsb-restish:json_status", "webui-app:json_status"]
1013
=== modified file 'juju-deployer/test-runner.yaml.tmpl'
--- juju-deployer/test-runner.yaml.tmpl 2014-02-25 23:16:13 +0000
+++ juju-deployer/test-runner.yaml.tmpl 2014-03-03 17:27:54 +0000
@@ -14,6 +14,7 @@
14 branch: ${CI_BRANCH}14 branch: ${CI_BRANCH}
15 tarball: ${CI_PAYLOAD_URL}15 tarball: ${CI_PAYLOAD_URL}
16 python_path: test_runner:ci-utils16 python_path: test_runner:ci-utils
17 json_status_path: api/v1/status
1718
18 # python-webtest is required for tests19 # python-webtest is required for tests
1920

Subscribers

People subscribed via source and target branches