Merge lp:~ionutbalutoiu/charms/trusty/glance/next into lp:~openstack-charmers-archive/charms/trusty/glance/next

Proposed by Ionut-Madalin Balutoiu
Status: Merged
Merged at revision: 152
Proposed branch: lp:~ionutbalutoiu/charms/trusty/glance/next
Merge into: lp:~openstack-charmers-archive/charms/trusty/glance/next
Diff against target: 80 lines (+41/-0)
2 files modified
hooks/glance_relations.py (+10/-0)
hooks/glance_utils.py (+31/-0)
To merge this branch: bzr merge lp:~ionutbalutoiu/charms/trusty/glance/next
Reviewer Review Type Date Requested Status
David Ames (community) Approve
Review via email: mp+276285@code.launchpad.net

Description of the change

Adds additional variables to the image-service relation. These are available only when a relation with Swift object storage is present.

In case any charm needs to generate temporary URLs from Glance with Swift backend, it needs a temp-url-key which must be posted to Swift with the glance account. (Details: http://docs.openstack.org/liberty/config-reference/content/object-storage-tempurl.html)

This is needed for OpenStack Ironic charm (http://bazaar.launchpad.net/~cloudbaseit/charms/trusty/ironic/trunk/view/head:/hooks/ironic_context.py#L76), but might also be generally useful.

To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #12926 glance-next for ionutbalutoiu mp276285
    LINT FAIL: lint-test failed

LINT Results (max last 2 lines):
make: *** [lint] Error 1
ERROR:root:Make target returned non-zero.

Full lint test output: http://paste.ubuntu.com/13010274/
Build: http://10.245.162.77:8080/job/charm_lint_check/12926/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #12002 glance-next for ionutbalutoiu mp276285
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/12002/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #7669 glance-next for ionutbalutoiu mp276285
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/7669/

Revision history for this message
David Ames (thedac) wrote :

Thanks for participating in the charm ecosystem! This MP looks good with the exception of the lint failure. The lint failure is a simple flake8 check.

You can run this with:

flake8 --exclude hooks/charmhelpers,tests/charmhelpers actions hooks unit_tests tests

Once that is fixed we can merge it.

review: Needs Fixing
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #12928 glance-next for ionutbalutoiu mp276285
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/12928/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #12004 glance-next for ionutbalutoiu mp276285
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/12004/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #7671 glance-next for ionutbalutoiu mp276285
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/7671/

Revision history for this message
David Ames (thedac) wrote :

Ionut-Madalin,

This looks good. I tested manually. Will merge.

Thanks again for participating in the charm community.

review: Approve
152. By David Ames

[ionutbalutoiu, r=thedac] Adds additional variables to the image-service relation. These are available only when a relation with Swift object storage is present.
In case any charm needs to generate temporary URLs from Glance with Swift backend, it needs a temp-url-key which must be posted to Swift with the glance account. (Details: http://docs.openstack.org/liberty/config-reference/content/object-storage-tempurl.html)
This is needed for OpenStack Ironic charm (http://bazaar.launchpad.net/~cloudbaseit/charms/trusty/ironic/trunk/view/head:/hooks/ironic_context.py#L76), but might also be generally useful.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/glance_relations.py'
2--- hooks/glance_relations.py 2015-10-07 20:47:28 +0000
3+++ hooks/glance_relations.py 2015-10-30 22:12:28 +0000
4@@ -26,6 +26,7 @@
5 setup_ipv6,
6 REQUIRED_INTERFACES,
7 check_optional_relations,
8+ swift_temp_url_key
9 )
10 from charmhelpers.core.hookenv import (
11 config,
12@@ -222,6 +223,13 @@
13 juju_log("%s: image-service_joined: To peer glance-api-server=%s" %
14 (CHARM, relation_data['glance-api-server']))
15
16+ if ('object-store' in CONFIGS.complete_contexts() and
17+ 'identity-service' in CONFIGS.complete_contexts()):
18+ relation_data.update({
19+ 'swift-temp-url-key': swift_temp_url_key(),
20+ 'swift-container': 'glance'
21+ })
22+
23 relation_set(relation_id=relation_id, **relation_data)
24
25
26@@ -238,6 +246,8 @@
27 juju_log('swift relation incomplete')
28 return
29
30+ [image_service_joined(rid) for rid in relation_ids('image-service')]
31+
32 CONFIGS.write(GLANCE_API_CONF)
33
34
35
36=== modified file 'hooks/glance_utils.py'
37--- hooks/glance_utils.py 2015-10-06 14:55:52 +0000
38+++ hooks/glance_utils.py 2015-10-30 22:12:28 +0000
39@@ -39,6 +39,7 @@
40 service_restart,
41 lsb_release,
42 write_file,
43+ pwgen
44 )
45
46 from charmhelpers.contrib.openstack import (
47@@ -460,3 +461,33 @@
48 return status_get()
49 else:
50 return 'unknown', 'No optional relations'
51+
52+
53+def swift_temp_url_key():
54+ """Generate a temp URL key, post it to Swift and return its value.
55+ If it is already posted, the current value of the key will be returned.
56+ """
57+ keystone_ctxt = context.IdentityServiceContext(service='glance',
58+ service_user='glance')()
59+ if not keystone_ctxt:
60+ log('Missing identity-service relation. Skipping generation of '
61+ 'swift temporary url key.')
62+ return
63+
64+ auth_url = '%s://%s:%s/v2.0/' % (keystone_ctxt['service_protocol'],
65+ keystone_ctxt['service_host'],
66+ keystone_ctxt['service_port'])
67+ from swiftclient import client
68+ swift_connection = client.Connection(
69+ authurl=auth_url, user='glance', key=keystone_ctxt['admin_password'],
70+ tenant_name=keystone_ctxt['admin_tenant_name'], auth_version='2.0')
71+
72+ account_stats = swift_connection.head_account()
73+ if 'x-account-meta-temp-url-key' in account_stats:
74+ log("Temp URL key was already posted.")
75+ return account_stats['x-account-meta-temp-url-key']
76+
77+ temp_url_key = pwgen(length=64)
78+ swift_connection.post_account(headers={'x-account-meta-temp-url-key':
79+ temp_url_key})
80+ return temp_url_key

Subscribers

People subscribed via source and target branches